Capture window change

Hello;

I have a simple gui application that should act according to desktop windows changes including other applications windows not only my program windows. What the program do is that if the user :

* Open a new window
* Minimize any existing window
* Maximize any existing window
* Or close any existing window

Than the function dosomething should be called. Like this example :

1
2
3
4
5
6
7
8
9
10
11
12
13
while(GetMessage(&msg, 0,0,0))
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
// ...
switch(msg)
{
    case XXX: // What should I put here ?
        dosomething();
    break;

}


Regards
What you want is not a simple message pump + window procedure. What you want probably requires a CBT hook or some other type of hook. Read about them and see if it fits your needs: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644977(v=vs.85).aspx
Ok, if I am understanding you you want your program to be able to close/modify another window even though the window is not your program. eg. Your program will close all open browsers. If this is the case then there might be something you can do.

You need to go trough each open window and decide if you want to do anything with it.

http://www.cplusplus.com/forum/windows/25280/

In the example, in the function EnumWindowsProc the hwnd is the handle to the currently being processed window. EnumWindows goes through each top-level window. So, in the example every window you would see on the taskbar is processed

Now that you have the hwnd you can just cal functions like DestroyWindow()/MoveWindow() or whatever.
Last edited on
Topic archived. No new replies allowed.