I am experimenting to trap windows messages send to a listbox control;
I have found the IMessageFilter interface to do this for me.
I have also read "about listboxes" (MSDN Library> Control Library> ListBox> about ListBoxes)
where I see the message codes like LB_ADDFILE,LB_GETCOUNT,LBN_DBLCLK and window message WM_HSCROLL etc etc
But I can not find where these codes are defined , what DLL to add in "Using .... "
Where can I find a list to see the actual values.
Without this information I cannot even compile my testprogram.
Help..
Loading
Sam HobbsPosted Aug 19, 2011, 6:45 PM
If you look up a message such as the WM_COMMAND Message in the MSDN then it will say:
#define WM_COMMAND 0x0111
If they don't, they will at least say the header is:
Winuser.h (include Windows.h)
so then you know to look in Winuser.h. Do you now how to find the Windows SDK headers? Hint: there is a folder in your system's "Program Files (x86)" folder for "Microsoft SDKs"; look there.
First note that a Windows Forms ListBox is probably not a Windows ListBox, so messages such as LBN_DBLCLK apparently are never sent. I am not sure, but if you are unable to get messages such as that then it is at least beyond my knowledge for figuring out how to do it.
If the ListBox is in the same applicaiton, then you can override it's WndProc. The following is a simple sample. Do you know how to use a control that is derived from another control, such as the following?
namespace _136891_trapping_windows_messages
{
class ListBoxSpy : ListBox
{
private const int WM_SETFOCUS = 0x0007;
private const int WM_KILLFOCUS = 0x0008;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SETFOCUS:
System.Diagnostics.Debug.Print("Set focus");
break;
case WM_KILLFOCUS:
System.Diagnostics.Debug.Print("Kill focus");
break;
}
base.WndProc(ref m);
}
}
}
peter croesPosted Aug 19, 2011, 11:25 AM
I saved the the headerfile...
Thanks
VulpesPosted Aug 19, 2011, 11:07 AM
There's a copy here:
http://www.woodmann.com/fravia/sources/WINUSER.H