c++ - Find button clicked event's cause in WindowProc -
i'm learning windows-based gui in c++, set simple project window inside button (and i'm able detect when button clicked). now, in window's windowproc
, i'd find "cause" fired wm_command, cause mean want find if button clicked mouse, or if user set on focus , pressed enter(or space) here piece of windowproc
:
int ucontrol::wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { outputdebugstringnewline((uwindowsdebughelper::getmessagestring(message) + text(" ") + this->gettype()).c_str()); //this writes on vs output window code of message string, example writes "wm_command" when received, instead of "273" switch (message) { case wm_close: destroywindow(hwnd); break; case wm_destroy: postquitmessage(0); break; case wm_command: if(lparam != 0) { if(hiword(wparam) == bn_clicked) { ucontrol* ctrl = this->findcontrol((hwnd)lparam); __raise ctrl->click(ctrl, ueventargs::empty); } } break; default: break; } if(this->_nativewndproc != null) return this->_nativewndproc(hwnd, message, wparam, lparam); else return defwindowproc(hwnd, message, wparam, lparam); }
hiword(wparam) bn_clicked when click button mouse, bn_clicked when "click" space key.
how can distinguish event cause?
how can distinguish event cause?
bn_clicked
not provide information. have track wm_lbutton(down/up)
, wm_key(down/up)
messages separately figure out going on. helps distinguish between mouse/keyboard clicks. davidheffernan said, there other ways click on buttons, and/or simulate bn_clicked
directly, without going through mouse/keyboard @ all.
Comments
Post a Comment