问题描述
我在对话框上放了几个按钮,然后还设置了加速键,但按加速键有时候不是很灵。是不是跟焦点有关?我如何解决这个问题呢?我需要只要我的程序在前台运行,不过鼠标的焦点在哪个位置,按快捷键都可以执行代码?应该怎么做呢?
解决方案
解决方案二:
该回复于2008-06-16 09:03:36被版主删除
解决方案三:
该回复于2008-06-13 13:14:41被版主删除
解决方案四:
该回复于2008-06-16 08:36:16被版主删除
解决方案五:
响应WM_HOTKEY消息了吗?WM_HOTKEYTheWM_HOTKEYmessageispostedwhentheuserpressesahotkeyregisteredbytheRegisterHotKeyfunction.Themessageisplacedatthetopofthemessagequeueassociatedwiththethreadthatregisteredthehotkey.AwindowreceivesthismessagethroughitsWindowProcfunction.LRESULTCALLBACKWindowProc(HWNDhwnd,//handletowindowUINTuMsg,//WM_HOTKEYWPARAMwParam,//hotkeyidentifierLPARAMlParam//optionsandvirtual-keycode);ParameterswParamSpecifiestheidentifierofthehotkeythatgeneratedthemessage.Ifthemessagewasgeneratedbyasystem-definedhotkey,thisparameterwillbeoneofthefollowingvalues.ValueMeaningIDHOT_SNAPDESKTOPThe"snapdesktop"hotkeywaspressed.IDHOT_SNAPWINDOWThe"snapwindow"hotkeywaspressed.lParamThelow-orderwordspecifiesthekeysthatweretobepressedincombinationwiththekeyspecifiedbythehigh-orderwordtogeneratetheWM_HOTKEYmessage.Thiswordcanbeoneormoreofthefollowingvalues.ValueMeaningMOD_ALTEitherALTkeywashelddown.MOD_CONTROLEitherCTRLkeywashelddown.MOD_SHIFTEitherSHIFTkeywashelddown.MOD_WINEitherWINDOWSkeywashelddown.ThesekeysarelabeledwiththeMicrosoftWindowslogo.Thehigh-orderwordspecifiesthevirtualkeycodeofthehotkey.RemarksWM_HOTKEYisunrelatedtotheWM_GETHOTKEYandWM_SETHOTKEYhotkeys.TheWM_HOTKEYmessageissentforgenerichotkeyswhiletheWM_SETHOTKEYandWM_GETHOTKEYmessagesrelatetowindowactivationhotkeys.
解决方案六:
我用的是加速键啊,不是WM_HOTKEY消息WM_HOTKEY消息怎么用
解决方案七:
该回复于2008-06-16 08:57:30被版主删除
解决方案八:
解决方案九:
你首先要在加速键(Acclerator)那里定义两个快捷键啊!