i want hook window creation in mfc program.
is there way that?
use setwindowhookex install cbtproc.
here's sample code. call installhook()
beginning of program, , monitor hcbt_createwnd
notification code. can cancel window creation returning nonzero function, described in docs.
lresult callback mycbthook(int ncode, wparam wparam, lparam lparam) { switch(ncode) { case hcbt_createwnd: { hwnd hwnd = (hwnd)wparam; trace("a window being created, hwnd = %p\n", hwnd); break; } } return callnexthookex( 0, ncode, wparam, lparam ); } void installhook() { setwindowshookex(wh_cbt, mycbthook, 0, getcurrentthreadid()); }
Comments
Post a Comment