Archived

This topic is now archived and is closed to further replies.

Enselic

Win32: Did someone click my ListBox?

Recommended Posts

Enselic    829
Is there anyway to determine if the user clicks (i.e. Selects a new item) in a Listbox? It won''t work with catching the WM_LBUTTONDOWN message since that only works when you click on the dialog but not the Listbox. One solution would be to have a timer constantcly checking what item is selected but that sounds unnessecary. If it isn''t obvious, I don''t use MFC, pure Win32 API... Anyone know how to do this properly? ____________________ ____ ___ __ _ Enselic''s Corner - My site. Go test my game Spatra and see if you can beat it onto the Official Spatra Top 10. CodeSampler.com - Great site with source for specific tasks in DirectX and OpenGL.

Share this post


Link to post
Share on other sites
pag    100
quote:

Listboxes send a LBN_SELCHANGE message (trough WM_COMMAND).



however that message is only being sent when the user selects another item. But maybe thats what you want?

if not there is WM_PARENTNOTIFY where:>

WM_PARENTNOTIFY
fwEvent = LOWORD(wParam); // event flags
idChild = HIWORD(wParam); // identifier of child window
lValue = lParam; // child handle, or cursor coordinates

fwEvent

Value of the low-order word of wParam. Specifies the event for which the parent is being notified. This parameter can be one of the following values:

Value Meaning
WM_CREATE The child window is being created.
WM_DESTROY The child window is being destroyed.
WM_LBUTTONDOWN The user has placed the cursor over the child window and has clicked the left mouse button.
WM_MBUTTONDOWN The user has placed the cursor over the child window and has clicked the middle mouse button.
WM_RBUTTONDOWN The user has placed the cursor over the child window and has clicked the right mouse button.


idChild

Value of the high-order word of wParam. If the fwEvent parameter is the WM_CREATE or WM_DESTROY value, idChild specifies the identifier of the child window. Otherwise, idChild is undefined.

lValue

Contains the handle of the child window, if the fwEvent parameter is the WM_CREATE or WM_DESTROY value; otherwise, lValue
contains the x- and y-coordinates of the cursor. The x-coordinate is in the low-order word and the y-coordinate is in the high-order word.



Return Values

If an application processes this message, it should return zero.

Remarks

This message is also sent to all ancestor windows of the child window, including the top-level window.
All child windows, except those that have the WS_EX_NOPARENTNOTIFY extended window style, send this message to their parent windows. By default, child windows in a dialog box have the WS_EX_NOPARENTNOTIFY style, unless the CreateWindowEx function is called to create the child window without this style.



[edited by - pag on May 28, 2003 10:59:52 AM]

Share this post


Link to post
Share on other sites