kbdproc.c

来自「WINDOWS下的ZIP解压软件,我是个学生,请让我加入这个网站学习」· C语言 代码 · 共 63 行

C
63
字号
#include "wizunzip.h"

/* Keyboard procedure used to sub-class all windows which can be
 * tab stops.
 */

/* Keyboard procedure
 * This function allows the user to tab and back-tab among the 
 * listbox, four command buttons,and message window.  
 * It traps VK_TAB messages and sets the
 * focus on the next or previous window as required.
 * Skip any disabled buttons.
 */
long FAR PASCAL KbdProc(HWND hWnd, WORD wMessage, WORD wParam, LONG lParam)
{
    int nID = GetWindowWord(hWnd, GWW_ID); /* child window ID no. */
    int nTabStopTableIndex = nID - TABSTOP_ID_BASE;
    int nNextTabStopTableIndex = nTabStopTableIndex;

    if (wMessage == WM_KEYDOWN)
    {
        if (wParam == VK_TAB)
        {
            int nRelIndex = /* forward or backward ? */
                    (int)(GetKeyState(VK_SHIFT) < 0 ? -1 : 1);

            do {
                nNextTabStopTableIndex += nRelIndex;
                if (nNextTabStopTableIndex < 0)
                    nNextTabStopTableIndex = TABSTOP_TABLE_ENTRIES-1;
                else if (nNextTabStopTableIndex >= TABSTOP_TABLE_ENTRIES)
                    nNextTabStopTableIndex = 0;
            
            } while (!IsWindowEnabled(TabStopTable[nNextTabStopTableIndex].hWnd));

            SetFocus(TabStopTable[nNextTabStopTableIndex].hWnd);
        }
        else if (wParam == VK_F1)
        {
           /* If Shift-F1, turn help mode on and set help cursor */ 
           if (GetKeyState(VK_SHIFT)<0)
           {
               uf.fHelp = TRUE;
               SetCursor(hHelpCursor);
           }
           else
           {
               /* If F1 without shift, then call up help main index topic */ 
               WinHelp(hWndMain, szHelpFileName, HELP_INDEX, 0L);
           }
        }
        else if ((wParam == VK_ESCAPE) && uf.fHelp)
        {
               /* Escape during help mode: turn help mode off */
               uf.fHelp = FALSE;
               SetCursor((HCURSOR)GetClassWord(hWndMain,GCW_HCURSOR));
        }
    }

    return CallWindowProc(TabStopTable[nTabStopTableIndex].lpfnOldFunc,
                            hWnd, wMessage, wParam, lParam);
}            

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?