Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6738981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:26:00+00:00 2026-05-26T11:26:00+00:00

How can I programatically find the handle of a user control in a webpage

  • 0

How can I programatically find the handle of a user control in a webpage running on IE?

I’m able to find it using Spy++ but since the handle keeps changing I’m stuck.

I’ve been trying using FindWindow() but no luck 🙁 I also wonder if I am doing something wrong or it simply only work for Windows…

Thanks in advance,

Zubrowka

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:26:00+00:00Added an answer on May 26, 2026 at 11:26 am

    I had a similar problem finding a PDF ActiveX Control inside a IE control in WPF.

    To overcome the problem I used the EnumChildWindows API to find the correct child window and thus get its handle.

    I’ll include as much code as I can.

    private static IntPtr FindPdfControlWindow(IntPtr parentHandle)
    {
        IntPtr result = IntPtr.Zero;
        IntPtr matchPointer = IntPtr.Zero;
        try
        {
            //allocate unmanaged memory for the result of the callback delegate
            matchPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            Marshal.WriteIntPtr(matchPointer, IntPtr.Zero)
    
            //instantiate the delegate and pass to the API
            NativeMethods.EnumWindowProc windowChecker = CheckForPdfControlWindow;
            if (!NativeMethods.EnumChildWindows(parentHandle, 
                                                    windowChecker, 
                                                    matchPointer))
        }
        finally
        {
            if (matchPointer != IntPtr.Zero) Marshal.FreeHGlobal(matchPointer);
        }
        return result;
    }
    
    private static bool CheckForPdfControlWindow(IntPtr handle,
                                                    IntPtr matchPointer)
    {
        int captionLength = NativeMehtods.GetWindowTextLength(handle);
        if (captionLength > 0)
        {
            StringBuilder buffer = new StringBuilder(captionLength + 1);
            NativeMethods.GetWindowText(handle, buffer, buffer.Capacity);
            if (buffer.ToString().Contains("Adobe"))
            {
                Marhsal.WriteIntPtr(matchPointer, handle)
                return false;
            }
        }
        return true;
    }
    
    private static class NativeMethods
    {
        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool EnumChildWindows(IntPtr window,
                                                        EnumWindowProc callback,
                                                        IntPtr i);
    
        internal delegate bool EnumWindowProc(IntPtr hWnd, IntPtr parameter);
    
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSer.Auto)]
        internal static extern int GetWindowTextLength(IntPtr hWnd);
    
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        internal static extern int GetWindowText(IntPtr hWnd,
                                                   StringBuilder lpString,
                                                   int nMaxCount);
    }
    

    transcribed in a rush so I hope it is both helpful and accurate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I create a very simple socket connection, how can one programatically: Find out
How can I programatically cause a control's tooltip to show in a Winforms app
can anyone tell me how can I (programatically) add the current/selected user to a
I've been looking everywhere but can't seem to find any examples/tutorials for my situation
How can I programatically find the CPU time which is displayed in System Idle
How can I programatically find whether MS-office is installed on a machine, and if
I created a user control in Silverlight, so now I can siply reuse it
Hi All, How can I programatically get the Computer description? I'm using C# and
I know I can programatically make the taskbar item for a particular window start
Is there a way I can programatically move my screens in relation to each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.