...

View Full Version : win32 - working with window's handle



cybertank
02-04-2005, 03:17 AM
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.

Dr. Evil
02-04-2005, 09:15 AM
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:


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;
}

cybertank
02-04-2005, 01:12 PM
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.

aman
02-05-2005, 11:59 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum