I have a program which consists of two windows (hWnd, and picturewind). I would like to write code which takes an action every time a person clicks inside of the second window (picturewind) but not when the person clicks in the first window (hWnd). Can anyone tell me how I am to determine when the second window has been clicked in, as apposed to the first?

How do I determine which window has been clicked in? (Note: I'm aware of the function GetActiveWindow, but I don't know how to use it properly to achieve the above result)

I'm using win32/C++, thanks.

You need to capture one of the mouse events, such WM_LBUTTONUP On that page in MSDN you will also find links to all the other mouse events that you will want to study.

You need to capture one of the mouse events, such WM_LBUTTONUP On that page in MSDN you will also find links to all the other mouse events that you will want to study.

i dont know about C/C++ but in C#/Java/VB (.NET Appis) mouse events work only in form, i mean it wont catch any event out of program, also if use your method the focus will be lost and simply program will stay stand by and will not do any action i think...

>> I would like to write code which takes an action every time a person clicks inside of the second window (picturewind) but not when the person clicks in the first window (hWnd)

Its a little unclear what the above means. In which program is the actions to be taken? If in the second window then its just standard mouse events. But if you want to do something in the first window when the mouse is clicked in the second, then its just slightly more complex. In the second window capture the mouse events as before but send a message to the first window letting it know about the events.

i dont know about C/C++ but in C#/Java/VB (.NET Appis) mouse events work only in form, i mean it wont catch any event out of program, also if use your method the focus will be lost and simply program will stay stand by and will not do any action i think...

C/C++ can grab mouse events globally by installing Windows Hooks

I'm aware of the mouse events (such as WM_LBUTTONDOWN), my question is, how do I recognize which window the mouse event occured in.

If a person were to click in the second window, how do I determine the mouse event (WM_LBUTTONDOWN, for example) came from the second window, and not from the first.

How do I determine which window sent the mouse event in the first place? Thank you for your replies by the way.

The first parameter to WinProc() is the handle to the window to which WM_LBUTTONDOWN event was sent.

Thank you so much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.