»ç¿ëÀÚ ÆíÁý °¡´ÉÇÑ ¾×¼¿·¯·¹ÀÌÅÍ ¸¸µé±â

ÀÌ ¿¹Á¦¿¡¼­´Â »ç¿ëÀÚ°¡ ¸Þ´º Ç׸ñ¿¡ ¿¬°á µÈ ¾×¼¿·¯·¹ÀÌÅ͸¦ º¯°æÇÒ ¼ö ÀÖ´Â ´ëÈ­ »óÀÚ¸¦ ±¸¼º ÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù. ´ëÈ­ »óÀÚ°¡ Æ÷ÇÔ µÈ ¸Þ´º Ç׸ñ, ctrl, alt ¹× shift Å°¸¦ ¼±Åà Çϱâ À§ÇÑ Å° ¹× È®ÀζõÀÇ À̸§À» Æ÷ÇÔ ÇÏ´Â ÄÞº¸ »óÀÚ ÄÞº¸ »óÀÚ ±¸¼º µË´Ï´Ù. ´ÙÀ½ ±×¸²¿¡¼­´Â ´ëÈ­ »óÀÚ¸¦ º¸¿© ÁÝ´Ï´Ù.

¸®¼Ò½º Á¤ÀÇ ÆÄÀÏ¿¡¼­ ´ëÈ­ »óÀÚ¸¦ Á¤ÀÇ ÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÖ´Â ¿¹Á¦.

EdAccelBox ´ëÈ­ »óÀÚ 5, 17, 193, 114 ½ºÅ¸ÀÏ DS_MODALFRAME (ko) | WS_POPUP (KO) | WS_VISIBLE (KO) | WS_CAPTION ĸ¼ÇÀº "ÆíÁý °¡¼Ó±â" ½ÃÀÛ COMBOBOX IDD_MENUITEMS, 10, 22, 52, 53, CBS_SIMPLE (ko) | CBS_SORT | WS_VSCROLL | 
                        WS_TABSTOP Á¦¾î "Á¦¾î", IDD_CNTRL, "¹öÆ°", BS_AUTOCHECKBOX (ko) | WS_TABSTOP, 76, 35, 40, 10 Á¦¾î "Alt", IDD_ALT, "¹öÆ°" BS_AUTOCHECKBOX (ko) | WS_TABSTOP, 76, 48, 40, 10 Á¦¾î "±³´ë", IDD_SHIFT, "¹öÆ°", BS_AUTOCHECKBOX (ko) | WS_TABSTOP, 76, 61, 40, 10 COMBOBOX IDD_KEYSTROKES, 58, CBS_SIMPLE, 58, 22, 124 (KO) | CBS_SORT | WS_VSCROLL | 
                        WS_TABSTOP Ǫ½Ã¹öÆ° "Ok", IDOK, 43, 92, 40, 14 Ǫ½Ã¹öÆ° "Ãë¼Ò", IDCANCEL, 103, 92, 40, 14 LTEXT "Ç׸ñ ¼±ÅÃ:", 101, 10, 12, 43, 8 LTEXT "Å° ¼±ÅÃ:", 102, 123, 12, 60, 8 ³¡ 
 

ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ¸Þ´º ¸ðÀ½Àº ¹®ÀÚ ÇÏÀ§ ¸Þ´º Ç׸ñÀ»°¡Áö°í ¹Ù·Î ¿¬°ü.

MainMenu ¸Þ´º {Æ˾÷ "¾ÚÇÁ;¹®ÀÚ"{MENUITEM" ¹× Regular\tF5 ", IDM_REGULAR MENUITEM" & Bold\tCtrl + B ", IDM_BOLD MENUITEM" & Italic\tCtrl + I ", IDM_ITALIC MENUITEM" & Underline\tCtrl + U ", IDM_ULINE}
} FontAccel ¾×¼¿·¯·¹ÀÌÅÍ {VK_F5, IDM_REGULAR, ¿ì¸® ¸ðµÎÀÇ VIRTKEY VIRTKEY, Á¦¾î, IDM_BOLD, "B" "³ª", IDM_ITALIC, ÄÁÆ®·Ñ, VIRTKEY "U", IDM_ULINE, ÄÁÆ®·Ñ, VIRTKEY} 
 

¸Þ´º ÅÛÇø´¿¡ ´ë ÇÑ ¸Þ´º Ç׸ñ °ªÀº ´ÙÀ½°ú °°Àº ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ Çì´õ ÆÄÀÏ¿¡ Á¤ÀÇ µÈ »ó¼ö.

# define IDM_REGULAR 1100
# define IDM_BOLD 1200
# define IDM_ITALIC 1300
# define IDM_ULINE 1400

´ëÈ­ »óÀÚ¿¡¼­´Â ÀÀ¿ë ÇÁ·Î±×·¥ Á¤ÀÇ VKEY ±¸Á¶ÀÇ ¹è¿­À» °¢ Å° ÀÔ·Â ÅؽºÆ® ¹®ÀÚ¿­ ¹× °¡¼Ó±â ÅؽºÆ® ¹®ÀÚ¿­À» Æ÷ÇÔ ÇÕ´Ï´Ù. ´ëÈ­ »óÀÚ¸¦ ¸¸µé ¶§ ¹è¿­À» ±¸¹® ºÐ¼® ÇÏ °í ¼±Åà Ű ÀÔ·Â ÄÞº¸ »óÀÚ¿¡ °¢ Å° ÀÔ·Â ÅؽºÆ® ¹®ÀÚ¿­À» Ãß°¡ ÇÕ´Ï´Ù. È®ÀÎ ´ÜÃ߸¦ Ŭ¸¯ ÇÏ¸é ´ëÈ­ »óÀÚ ¼±ÅÃµÈ Å° ÅؽºÆ® ¹®ÀÚ¿­À» ã½À´Ï´Ù ÇÏ °í ÇØ´ç °¡¼Ó±â-ÅؽºÆ® ¹®ÀÚ¿­À» °Ë»ö ÇÕ´Ï´Ù. ´ëÈ­ »óÀÚ´Â »ç¿ëÀÚ°¡ ¼±ÅÃÇÑ ¸Þ´º Ç׸ñÀÇ ÅؽºÆ®¸¦ °¡¼Ó±â ÅؽºÆ® ¹®ÀÚ¿­À» Ãß°¡ ÇÕ´Ï´Ù. ´ÙÀ½ ¿¹Á¦¿¡¼­´Â VKEY ±¸Á¶Ã¼ÀÇ ¹è¿­À» º¸¿© ÁÝ´Ï´Ù.:

/ / VKey Á¶È¸ Áö¿ø # define MAXKEYS 25 typedef struct _VKEYS {char * pKeyName; 
    char * pKeyString; 
} VKEYS; 
 
VKEYS vkeys [MAXKEYS] = {"BkSp", "´Ù½Ã °ø°£", "PgUp", "Page Up", "PgDn", "Page Down", "Á¾·á", "³¡", "Ȩ", "Ȩ", "Lft", "¿ÞÂÊ", "ÃÖ´ë", "ÃÖ´ë", "Rgt", "Right", "Dn", "¾Æ·¡", "±â´É", "»ðÀÔ", "Del", "»èÁ¦", "º¹¼ö" "°öÇϱâ", "Ãß°¡", "Ãß°¡", "Sub", "»©±â", "DecPt", "¼Ò¼öÁ¡", "Div", "³ª´©±â", "F2", "F2", "f 3À»", "f 3", "F5", "F5", "F6", "F6", "F7", "F7", "F8", "F8", "F9", "F9", "F11", "F11", "F12", "F12"} 
 

´ëÈ­ »óÀÚ ÃʱâÈ­ ÇÁ·Î½ÃÀú Ç׸ñ ¼±Åà ÇÏ °í ¼±Åà Ű ÀÔ·Â ÄÞº¸ »óÀÚ¸¦ ä¿ó´Ï´Ù. »ç¿ëÀÚ°¡ ¸Þ´º Ç׸ñ ¹× °ü·ÃµÈ °¡¼Ó±â¸¦ ¼±Åà ÈÄ ´ëÈ­ »óÀÚ °Ë»ç ÇÏ´Â »ç¿ëÀÚÀÇ ¼±Åà ´ëÈ­ »óÀÚ¿¡¼­ ÄÁÆ®·Ñ ¸Þ´º Ç׸ñÀÇ ÅؽºÆ®¸¦ ¾÷µ¥ÀÌÆ® ÇÏ °í »ç¿ëÀÚ Á¤ÀÇ »õ °¡¼Ó±â¸¦ Æ÷ÇÔ ÇÏ´Â »õ ¾×¼¿·¯·¹ÀÌÅÍ Å° Å×À̺íÀ» ¸¸µì´Ï´Ù. ´ÙÀ½ ¿¹Á¦¿¡¼­´Â ´ëÈ­ »óÀÚ ÇÁ·Î½ÃÀú¸¦ º¸¿© ÁÝ´Ï´Ù. Âü°í ÃʱâÈ­ ÇØ¾ß ÇÕ´Ï´Ù hwndMain â ÇÁ·Î½ÃÀú¿¡¼­.

 // Global variables 
 
HWND hwndMain;      // handle to main window 
HACCEL haccel;      // handle to accelerator table 
 
// Dialog-box procedure 
 
BOOL CALLBACK EdAccelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{ 
    int nCurSel;            // index of list box item 
    UINT idItem;            // menu-item identifier 
    UINT uItemPos;          // menu-item position 
    UINT i, j = 0;          // loop counters 
    static UINT cItems;     // count of items in menu 
    char szTemp[32];        // temporary buffer 
    char szAccelText[32];   // buffer for accelerator text 
    char szKeyStroke[16];   // buffer for keystroke text 
    static char szItem[32]; // buffer for menu-item text 
    HWND hwndCtl;           // handle to control window 
    static HMENU hmenu;     // handle to "Character" menu 
    PCHAR pch, pch2;        // pointers for string copying 
    WORD wVKCode;           // accelerator virtual-key code 
    BYTE fAccelFlags;       // fVirt flags for ACCEL structure 
    LPACCEL lpaccelNew;     // address of new accelerator table 
    HACCEL haccelOld;       // handle to old accelerator table 
    int cAccelerators;      // number of accelerators in table 
    static BOOL fItemSelected = FALSE; // item selection flag 
    static BOOL fKeySelected = FALSE;  // key selection flag 
 
    switch (uMsg) 
    { 
        case WM_INITDIALOG: 
 
            // Get the handle to the menu-item combo box. 
 
            hwndCtl = GetDlgItem(hwndDlg, IDD_MENUITEMS); 
 
            // Get the handle to the Character submenu and
            // count the number of items it has. In this example, 
            // the menu has position 0. You must alter this value 
            // if you add additional menus. 
            hmenu = GetSubMenu(GetMenu(hwndMain), 0); 
            cItems = GetMenuItemCount(hmenu); 
 
            // Get the text of each item, strip out the '&' and 
            // the accelerator text, and add the text to the 
            // menu-item combo box. 
 
            for (i = 0; i < cItems; i++) 
            { 
                if (!(GetMenuString(hmenu, i, szTemp, 
                        sizeof(szTemp), MF_BYPOSITION))) 
                    continue; 
                for (pch = szTemp, pch2 = szItem; *pch != '\0'; ) 
                { 
                    if (*pch != '&') 
                    { 
                        if (*pch == '\t') 
                        { 
                            *pch = '\0'; 
                            *pch2 = '\0'; 
                        } 
                        else *pch2++ = *pch++; 
                    } 
                    else pch++; 
                } 
                SendMessage(hwndCtl, CB_ADDSTRING, 0, 
                    (LONG) (LPSTR) szItem); 
            } 
 
            // Now fill the keystroke combo box with the list of 
            // keystrokes that will be allowed for accelerators. 
            // The list of keystrokes is in the application-defined 
            // structure called "vkeys". 
 
            hwndCtl = GetDlgItem(hwndDlg, IDD_KEYSTROKES); 
            for (i = 0; i < MAXKEYS; i++) 
            {
                SendMessage(hwndCtl, CB_ADDSTRING, 0, 
                    (LONG) (LPSTR) vkeys[i].pKeyString); 
            }
 
            return TRUE; 
 
        case WM_COMMAND: 
            switch (LOWORD(wParam)) 
            { 
                case IDD_MENUITEMS: 
 
                    // The user must select an item from the combo 
                    // box. This flag is checked during IDOK
                    // processing to be sure a selection was made. 
 
                    fItemSelected = TRUE; 
                    return 0; 
 
                case IDD_KEYSTROKES: 
 
                    // The user must select an item from the combo
                    // box. This flag is checked during IDOK
                    // processing to be sure a selection was made. 
 
                    fKeySelected = TRUE; 
 
                    return 0; 
 
                case IDOK: 
 
                    // If the user has not selected a menu item 
                    // and a keystroke, display a reminder in a 
                    // message box. 
 
                    if (!fItemSelected || !fKeySelected) 
                    { 
                        MessageBox(hwndDlg, 
                            "Item or key not selected.", NULL, 
                            MB_OK); 
                        return 0; 
                    } 
 
                    // Determine whether the CTRL, ALT, and SHIFT 
                    // keys are selected. Concatenate the 
                    // appropriate strings to the accelerator- 
                    // text buffer, and set the appropriate 
                    // accelerator flags. 
 
                    szAccelText[0] = '\0'; 
                    hwndCtl = GetDlgItem(hwndDlg, IDD_CNTRL); 
                    if (SendMessage(hwndCtl, BM_GETCHECK, 0, 0) == 1) 
                    { 
                        lstrcat(szAccelText, "Ctl+"); 
                        fAccelFlags |= FCONTROL; 
                    } 
                    hwndCtl = GetDlgItem(hwndDlg, IDD_ALT); 
                    if (SendMessage(hwndCtl, BM_GETCHECK, 0, 0) == 1) 
                    { 
                        lstrcat(szAccelText, "Alt+"); 
                        fAccelFlags |= FALT; 
                    } 
                    hwndCtl = GetDlgItem(hwndDlg, IDD_SHIFT); 
                    if (SendMessage(hwndCtl, BM_GETCHECK, 0, 0) == 1) 
                    { 
                        lstrcat(szAccelText, "Shft+"); 
                        fAccelFlags |= FSHIFT; 
                    } 
 
                    // Get the selected keystroke, and look up the 
                    // accelerator text and the virtual-key code 
                    // for the keystroke in the vkeys structure. 
 
                    hwndCtl = GetDlgItem(hwndDlg, IDD_KEYSTROKES); 
                    nCurSel = (int) SendMessage(hwndCtl, 
                        CB_GETCURSEL, 0, 0); 
                    SendMessage(hwndCtl, CB_GETLBTEXT, 
                        nCurSel, (LONG) (LPSTR) szKeyStroke); 
                    for (i = 0; i < MAXKEYS; i++) 
                    { 
                        if(lstrcmp(vkeys[i].pKeyString, szKeyStroke) 
                            == 0) 
                        { 
                            lstrcpy(szKeyStroke, vkeys[i].pKeyName); 
                            break; 
                        } 
                    } 
 
                    // Concatenate the keystroke text to the 
                    // "Ctl+","Alt+", or "Shft+" string. 
 
                    lstrcat(szAccelText, szKeyStroke); 
 
                    // Determine the position in the menu of the 
                    // selected menu item. Menu items in the 
                    // "Character" menu have positions 0,2,3, and 4. 
 
                    if (lstrcmp(szItem, "Regular") == 0) 
                        uItemPos = 0; 
                    else if (lstrcmp(szItem, "Bold") == 0) 
                        uItemPos = 2; 
                    else if (lstrcmp(szItem, "Italic") == 0) 
                        uItemPos = 3; 
                    else if (lstrcmp(szItem, "Underline") == 0) 
                        uItemPos = 4; 
 
                    // Get the string that corresponds to the 
                    // selected item. 
 
                    GetMenuString(hmenu, uItemPos, szItem, 
                        sizeof(szItem), MF_BYPOSITION); 
 
                    // Append the new accelerator text to the 
                    // menu-item text. 
 
                    for (pch = szItem; *pch != '\t'; pch++); 
                        ++pch; 
 
                    for (pch2 = szAccelText; *pch2 != '\0'; pch2++) 
                        *pch++ = *pch2; 
                    *pch = '\0'; 
 
                    // Modify the menu item to reflect the new 
                    // accelerator text. 
 
                    idItem = GetMenuItemID(hmenu, uItemPos); 
                    ModifyMenu(hmenu, idItem, MF_BYCOMMAND | 
                        MF_STRING, idItem, szItem); 
 
                    // Reset the selection flags. 
 
                    fItemSelected = FALSE; 
                    fKeySelected = FALSE; 
 
                    // Save the current accelerator table. 
 
                    haccelOld = haccel; 
 
                    // Count the number of entries in the current 
                    // table, allocate a buffer for the table, and 
                    // then copy the table into the buffer. 
 
                    cAccelerators = CopyAcceleratorTable( 
                        haccelOld, NULL, 0); 
                    lpaccelNew = (LPACCEL) LocalAlloc(LPTR, 
                        cAccelerators * sizeof(ACCEL)); 
 
                    if (lpaccelNew != NULL) 
                    {
                        CopyAcceleratorTable(haccel, lpaccelNew, 
                            cAccelerators); 
                    }
 
                    // Find the accelerator that the user modified 
                    // and change its flags and virtual-key code 
                    // as appropriate. 
 
                    for (i = 0; (lpaccelNew[i].cmd == 
                                (WORD) idItem) 
                            && (i < (UINT) cAccelerators); i++) 
                    { 
                        lpaccelNew[i].fVirt = fAccelFlags; 
                        lpaccelNew[i].key = wVKCode; 
                    } 
 
                    // Create the new accelerator table, and 
                    // destroy the old one. 
 
                    DestroyAcceleratorTable(haccelOld); 
                    haccel = CreateAcceleratorTable(lpaccelNew, 
                        cAccelerators); 
 
                    // Destroy the dialog box. 
 
                    EndDialog(hwndDlg, TRUE); 
                    return 0; 
 
                case IDCANCEL: 
                    EndDialog(hwndDlg, TRUE); 
                    return TRUE; 
 
                default: 
                    break; 
            } 
        default: 
            break; 
    } 
    return FALSE; 
} 
 

 

Index