MFC 建立鍵盤按鍵觸發事件

2021-08-26 15:15:26 字數 1797 閱讀 5551

描述:在mfc中通過按鍵盤某些按鍵觸發一些事件

資源檢視----dialog----指定介面----類嚮導----虛函式----pretranslatemessage

找到自動生成的方法,新增方式如下:

bool ctakephoto::pretranslatemessage(msg* pmsg)

if(pmsg->wparam==vk_space )//空格鍵

}return cdialog::pretranslatemessage(pmsg);

}

按鍵的巨集定義可供參考:

#define vk_clear          0x0c

#define vk_return 0x0d

#define vk_shift 0x10

#define vk_control 0x11

#define vk_menu 0x12

#define vk_pause 0x13

#define vk_capital 0x14

#define vk_kana 0x15

#define vk_hangeul 0x15 /* old name - should be here for compatibility */

#define vk_hangul 0x15

#define vk_junja 0x17

#define vk_final 0x18

#define vk_hanja 0x19

#define vk_kanji 0x19

#define vk_escape 0x1b

#define vk_convert 0x1c

#define vk_nonconvert 0x1d

#define vk_accept 0x1e

#define vk_modechange 0x1f

#define vk_space 0x20

#define vk_prior 0x21

#define vk_next 0x22

#define vk_end 0x23

#define vk_home 0x24

#define vk_left 0x25

#define vk_up 0x26

#define vk_right 0x27

#define vk_down 0x28

#define vk_select 0x29

#define vk_print 0x2a

#define vk_execute 0x2b

#define vk_snapshot 0x2c

#define vk_insert 0x2d

#define vk_delete 0x2e

#define vk_help 0x2f

MFC 鍵盤響應事件

鍵盤響應有三個函式 1 wm keydown void cmyview onkeydown uint nchar uint nrepcnt uint nflags 2 wm char void cmyview onchar uint nchar uint nrepcnt uint nflags 3 ...

滑鼠與按鍵 事件觸發順序

事件觸發順序 之前研究過input文字框的事件觸發順序,今天突然想起來,就做個總結。type text name id txt var txt document.queryselector txt txt.onmousedown function txt.onmouseup function txt...

滑鼠與按鍵 事件觸發順序

var txt document.queryselector txt txt.onmousedown function txt.onmouseup function txt.onfocus function txt.onclick function txt.onkeydown function tx...