Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    win32 - working with window's handle

    This is programming in C++ .Net on XP/win2k3.

    Could someone point me to resources describing what kind of API is available to work on a window's handle pointer (for example, using Process:GetProcessByID(id) and then referencing the MainWindowHandle member of the Process object)? e.g. once I get a window's handle, what can I do with it?

    One example of something I'd like to do is having gotten the handle to a window in a process I have access to, I'd like to change the way the top bar is painted (lets say from the theme'd blue to a red). Is this possible? What kinds of other operations can one do on a window handle?

    Any kinds of docs would be greatly appreciated. Searching the MSDN doesn't result in too much useful info.

  • #2
    New Coder
    Join Date
    Nov 2004
    Location
    Netherlands
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you just want to get the window handle, it might be easier to use EnumWindows() or FindWindow(), which would return the window handle. You can use either the window class name or window text to find or identify a window, in example:
    Code:
    BOOL CALLBACK EnumWindowsProc(HWND winh, LPARAM lParam)
    {
     char class_name[MAX_PATH];
     
     GetClassName(winh, class_name, MAX_PATH);
     
     if(!stricmp(class_name, "EDIT")) puts("Edit found");
     
     return TRUE; //to continue enumerating windows
    }
    
    int main()
    {
     EnumWindows(EnumWindowsProc, NULL);
     
     return 0;
    }

  • #3
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks... I'm pretty clear on how to get a window handle. What I'm unclear about is, well, why one would want the window handle? What can one do with it? Does the question make sense? The problem is because handles are void * usually on the MSDN doc, the trail of functionality grinds to a halt once one finally gets the handle, because searching for functions that take void * pointers is fruitless. Thanks in advance.

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Windows handles (HWND) are used for all of the window-management APIs. These are functions that operate on a window.. things like creating, destroying, moving, getting locations, etc... You should search the msdn for window and window class functions.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •