Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How I can get control's id property via api

How I can get control's id property via api

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marco2250
    wrote on last edited by
    #1

    Hi all. How I can get control's id "(Name)" property of a control of other process (vb6 app) via windows api? Please, help me. Thx in advance. Best Regards, Marco Alves.

    P 1 Reply Last reply
    0
    • M Marco2250

      Hi all. How I can get control's id "(Name)" property of a control of other process (vb6 app) via windows api? Please, help me. Thx in advance. Best Regards, Marco Alves.

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      Sorry, Marco ... i'm gonna sound stupid, but i'm not sure what you mean? Could you be more specific? :confused: :doh:

      Only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

      M 1 Reply Last reply
      0
      • P Programm3r

        Sorry, Marco ... i'm gonna sound stupid, but i'm not sure what you mean? Could you be more specific? :confused: :doh:

        Only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

        M Offline
        M Offline
        Marco2250
        wrote on last edited by
        #3

        first, thank you for your reply. Sorry, because I've a bad english. But trying to do my best. :) Okay, suppose I have a VB6 app. I put a listview on my form and name it lvwProducts. Now, I compile and run this simple app. Now, in another app (a C# .NET 2005 app) I want do get the name of that listview, i.e., the name of the listview that is on another process (my vb6 app). First, I got the handle. with the listview handle I want to get its name. get it? Ah, I've downloaded a code from http://blogs.msdn.com/brianmcm/ but it only works if the listview is on an .NET process. but, in my case, the other process was written in vb6. to use that code I do something like that: string controlName = GetWinFormsId.WinFormsUtilities.GetWinFormsId(hWnd) // where hWnd is the handle of my listview. the code is here (sorry, I don't know how to format the code here): ********************** using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.Text; namespace GetWinFormsId { /// /// Summary description for WinFormsUtilities. /// public class WinFormsUtilities { private static int GetControlNameMessage = 0; static WinFormsUtilities() { GetControlNameMessage = NativeMethods.RegisterWindowMessage("WM_GETCONTROLNAME"); } public static string GetWinFormsId(IntPtr hWnd) { return XProcGetControlName(hWnd, GetControlNameMessage); } protected static string XProcGetControlName(IntPtr hwnd, int msg) { //define the buffer that will eventually contain the desired window's WinFormsId byte[] bytearray = new byte[65535]; //allocate space in the target process for the buffer as shared memory IntPtr bufferMem = IntPtr.Zero; //base address of the allocated region for the buffer IntPtr written = IntPtr.Zero; //number of bytes written to memory IntPtr retHandle = IntPtr.Zero; bool retVal; //creating and reading from a shared memory region is done differently in Win9x then in newer OSs IntPtr processHandle = IntPtr.Zero; IntPtr fileHandle = IntPtr.Zero; if (!(Environment.OSVersion.Platform == PlatformID.Win32Windows)) { try { uint size; //the amount of memory to be allocated size = 65536;

        P M 2 Replies Last reply
        0
        • M Marco2250

          first, thank you for your reply. Sorry, because I've a bad english. But trying to do my best. :) Okay, suppose I have a VB6 app. I put a listview on my form and name it lvwProducts. Now, I compile and run this simple app. Now, in another app (a C# .NET 2005 app) I want do get the name of that listview, i.e., the name of the listview that is on another process (my vb6 app). First, I got the handle. with the listview handle I want to get its name. get it? Ah, I've downloaded a code from http://blogs.msdn.com/brianmcm/ but it only works if the listview is on an .NET process. but, in my case, the other process was written in vb6. to use that code I do something like that: string controlName = GetWinFormsId.WinFormsUtilities.GetWinFormsId(hWnd) // where hWnd is the handle of my listview. the code is here (sorry, I don't know how to format the code here): ********************** using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.Text; namespace GetWinFormsId { /// /// Summary description for WinFormsUtilities. /// public class WinFormsUtilities { private static int GetControlNameMessage = 0; static WinFormsUtilities() { GetControlNameMessage = NativeMethods.RegisterWindowMessage("WM_GETCONTROLNAME"); } public static string GetWinFormsId(IntPtr hWnd) { return XProcGetControlName(hWnd, GetControlNameMessage); } protected static string XProcGetControlName(IntPtr hwnd, int msg) { //define the buffer that will eventually contain the desired window's WinFormsId byte[] bytearray = new byte[65535]; //allocate space in the target process for the buffer as shared memory IntPtr bufferMem = IntPtr.Zero; //base address of the allocated region for the buffer IntPtr written = IntPtr.Zero; //number of bytes written to memory IntPtr retHandle = IntPtr.Zero; bool retVal; //creating and reading from a shared memory region is done differently in Win9x then in newer OSs IntPtr processHandle = IntPtr.Zero; IntPtr fileHandle = IntPtr.Zero; if (!(Environment.OSVersion.Platform == PlatformID.Win32Windows)) { try { uint size; //the amount of memory to be allocated size = 65536;

          P Offline
          P Offline
          Programm3r
          wrote on last edited by
          #4

          Yeah, I get it .... but I'm sad to say that I have no idea, how to accomplish this... :confused::confused: ...

          Have you tried to google it???

          Good Luck Sorry I couldn't help

          Only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

          1 Reply Last reply
          0
          • M Marco2250

            first, thank you for your reply. Sorry, because I've a bad english. But trying to do my best. :) Okay, suppose I have a VB6 app. I put a listview on my form and name it lvwProducts. Now, I compile and run this simple app. Now, in another app (a C# .NET 2005 app) I want do get the name of that listview, i.e., the name of the listview that is on another process (my vb6 app). First, I got the handle. with the listview handle I want to get its name. get it? Ah, I've downloaded a code from http://blogs.msdn.com/brianmcm/ but it only works if the listview is on an .NET process. but, in my case, the other process was written in vb6. to use that code I do something like that: string controlName = GetWinFormsId.WinFormsUtilities.GetWinFormsId(hWnd) // where hWnd is the handle of my listview. the code is here (sorry, I don't know how to format the code here): ********************** using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.Text; namespace GetWinFormsId { /// /// Summary description for WinFormsUtilities. /// public class WinFormsUtilities { private static int GetControlNameMessage = 0; static WinFormsUtilities() { GetControlNameMessage = NativeMethods.RegisterWindowMessage("WM_GETCONTROLNAME"); } public static string GetWinFormsId(IntPtr hWnd) { return XProcGetControlName(hWnd, GetControlNameMessage); } protected static string XProcGetControlName(IntPtr hwnd, int msg) { //define the buffer that will eventually contain the desired window's WinFormsId byte[] bytearray = new byte[65535]; //allocate space in the target process for the buffer as shared memory IntPtr bufferMem = IntPtr.Zero; //base address of the allocated region for the buffer IntPtr written = IntPtr.Zero; //number of bytes written to memory IntPtr retHandle = IntPtr.Zero; bool retVal; //creating and reading from a shared memory region is done differently in Win9x then in newer OSs IntPtr processHandle = IntPtr.Zero; IntPtr fileHandle = IntPtr.Zero; if (!(Environment.OSVersion.Platform == PlatformID.Win32Windows)) { try { uint size; //the amount of memory to be allocated size = 65536;

            M Offline
            M Offline
            Mila025
            wrote on last edited by
            #5

            Hi, I don't know what is your goal, if you already have handle to the list. But a bit info about interprocess communications you can find e.g. here: Interprocess Communication[^] Shared Memory Through Memory-mapped Files[^]

            ----------- Mila

            M 1 Reply Last reply
            0
            • M Mila025

              Hi, I don't know what is your goal, if you already have handle to the list. But a bit info about interprocess communications you can find e.g. here: Interprocess Communication[^] Shared Memory Through Memory-mapped Files[^]

              ----------- Mila

              M Offline
              M Offline
              Marco2250
              wrote on last edited by
              #6

              My goal is to confirm if the control name of the current hWnd is the name that I want to.

              D 1 Reply Last reply
              0
              • M Marco2250

                My goal is to confirm if the control name of the current hWnd is the name that I want to.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                If you have the control's window handle, compare its ID using GetDlgCtrlID().


                "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                "Judge not by the eye but by the heart." - Native American Proverb

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups