-
instantiate a button.. and create your own WndProc that will handle the messages for that button
then prevProc = SetWindowLong(hButtn, GWL_WNDPROC, (long)NewWndProc);
this will let you capture the messages..
inside your new window procedure make sure you pass the messages onto the control when you have done your handling by using CallWindowProc() (or something like that).
make sure you set the window proc back to what it was before destroying the control!
this is just to give you the idea... i can't remember all the function names and parameters.. but they should be pretty close.
hope this helps
U.
-
To add to Uraldor's info:
1. Create the control normally.
2. Create your own DIY wndproc for the button control eg BtnProc.
3. Declare a WNDPROC variable to store the original wndproc eg
WNDPROC OldCntrlProc=(WNDPROC)SetWindowLong(hBtn,GWL_WNDPR OC,(LONG)BtnProc);
The return value cast may not be necessary in 'C'. Also there is a new fn, SetWindowLongPtr, that
supercedes SetWindowLong (get ready for 64bit...) that you may also wish to look at.
4. Then in BtnProc:
Code:
LRESULT CALLBACK BtnProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDBLCLK: //optional
case WM_LBUTTONDOWN:
{
SendMessage(hwnd,WM_SYSCOMMAND,0xF012,0); /*0xF012=SC_MOVE+HTCAPTION*/
return 0;
}
default: /*pass unhandled msgs to system for default handling*/
return CallWindowProc(OldCntrlProc,hwnd,uMsg,wParam,lParam);
}
}
Same as any other wndproc, except for the default handling fn. When you are done with the control, restore the original wndproc:
SetWindowLong(hBtn,GWL_WNDPROC,(LONG)OldCntrlProc) ;
Hope that's of some use to you.
-