现在的位置: 首页 > 综合 > 正文

为你的程序加上加速键

2013年10月13日 ⁄ 综合 ⁄ 共 503字 ⁄ 字号 评论关闭
1.添加加速键资源
2.  hAccel =LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCEL));
3.修改消息循环以便处理加速键信息
    while (GetMessage (&msg, NULL, 00))
     
{
        
if(!TranslateAccelerator(hwnd,hAccel,&msg))
         
{
          TranslateMessage (
&msg) ;
          DispatchMessage (
&msg) ;
         }

     }

4.处理WM_COMMAND来响应加速键

void HelloWin_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
    
switch(id)
    
{
    
case IDA_SMALL:
        MessageBox(hwnd,__TEXT(
"F11"),__TEXT("F11"),0);
        
break;
    }

}

抱歉!评论已关闭.