Ignore:
Timestamp:
Jul 31, 2003, 5:58:58 PM (22 years ago)
Author:
sandervl
Message:

KOMH: DBCS updates/fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/winaccel.cpp

    r9974 r10190  
    1 /* $Id: winaccel.cpp,v 1.11 2003-04-02 12:58:02 sandervl Exp $ */
     1/* $Id: winaccel.cpp,v 1.12 2003-07-31 15:56:47 sandervl Exp $ */
    22/*
    33 * Win32 accelerator key functions for OS/2
     
    1818#include <misc.h>
    1919#include <heapstring.h>
    20 #include "win32wbase.h"
    2120#include <win\winnls.h>
    2221
     
    2423#include "dbglocal.h"
    2524
    26 /**********************************************************************
    27  *           KBD_translate_accelerator
    28  *
    29  * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP  -messages
    30  */
    31 static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
    32                                       BYTE fVirt,WORD key,WORD cmd)
    33 {
    34     BOOL sendmsg = FALSE;
    35 
    36     if(msg->wParam == key)
    37     {
    38         if (msg->message == WM_CHAR) {
    39             if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
    40             {
    41                 dprintf(("TranslateAccelerator: found accel for WM_CHAR: ('%c')\n", msg->wParam&0xff));
    42                 sendmsg=TRUE;
    43             }
    44         }
    45         else
    46         {
    47             if(fVirt & FVIRTKEY) {
    48                 INT mask = 0;
    49                 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
    50                 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
    51                 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
    52 
    53                 if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
    54                         sendmsg=TRUE;
    55                 else    dprintf(("TranslateAccelerator: but incorrect SHIFT/CTRL/ALT-state %x != %x", mask, fVirt));
    56             }
    57             else
    58             {
    59                 if (!(msg->lParam & 0x01000000))  /* no special_key */
    60                 {
    61                     if ((fVirt & FALT) && (msg->lParam & 0x20000000))
    62                     {                                                   /* ^^ ALT pressed */
    63                         dprintf(("TranslateAccelerator: found accel for Alt-%c\n", msg->wParam&0xff));
    64                         sendmsg=TRUE;
    65                     }
    66                 }
    67             }
    68         }
    69 
    70         if (sendmsg)      /* found an accelerator, but send a message... ? */
    71         {
    72             INT  iSysStat,iStat,mesg=0;
    73             HMENU hMenu;
    74 
    75             if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) {
    76                 mesg=1;
    77             }
    78             else
    79                 if (GetCapture())
    80                     mesg=2;
    81                 else
    82                 if (!IsWindowEnabled(hWnd))
    83                     mesg=3;
    84                 else
    85                 {
    86                     Win32BaseWindow *window;
    87 
    88                     window = Win32BaseWindow::GetWindowFromHandle(hWnd);
    89                     if(!window) {
    90                         return FALSE; //should never happen! (already checked)
    91                     }
    92 
    93                     hMenu = GetMenu(hWnd);
    94 
    95                     iSysStat = (window->GetSysMenu()) ? GetMenuState(GetSubMenu(window->GetSysMenu(), 0),
    96                                                                      cmd, MF_BYCOMMAND) : -1 ;
    97                     iStat = (hMenu) ? GetMenuState(hMenu, cmd, MF_BYCOMMAND) : -1 ;
    98 
    99                     if (iSysStat!=-1)
    100                     {
    101                         if (iSysStat & (MF_DISABLED|MF_GRAYED))
    102                             mesg=4;
    103                         else
    104                             mesg=WM_SYSCOMMAND;
    105                     }
    106                     else
    107                     {
    108                         if (iStat!=-1)
    109                         {
    110                             if (IsIconic(hWnd)) {
    111                                 mesg=5;
    112                             }
    113                             else
    114                             {
    115                                 if (iStat & (MF_DISABLED|MF_GRAYED))
    116                                     mesg=6;
    117                                 else
    118                                     mesg=WM_COMMAND;
    119                             }
    120                         }
    121                         else
    122                             mesg=WM_COMMAND;
    123                     }
    124                     RELEASE_WNDOBJ(window);
    125                 }
    126                 if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
    127                 {
    128                     SendMessageA(hWnd, mesg, cmd, 0x00010000L);
    129                 }
    130                 else
    131                 {
    132                     /*  some reasons for NOT sending the WM_{SYS}COMMAND message:
    133                      *   #0: unknown (please report!)
    134                      *   #1: for WM_KEYUP,WM_SYSKEYUP
    135                      *   #2: mouse is captured
    136                      *   #3: window is disabled
    137                      *   #4: it's a disabled system menu option
    138                      *   #5: it's a menu option, but window is iconic
    139                      *   #6: it's a menu option, but disabled
    140                      */
    141                     if(mesg==0)
    142                             dprintf(("ERROR: unknown reason - please report!"));
    143                     else    dprintf(("but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg));
    144 
    145                 }
    146                 return TRUE;
    147             }
    148             dprintf(("TranslateAccelerator: not match for %x %x %x", fVirt, key, cmd));
    149     }
    150     return FALSE;
    151 }
    152 /*****************************************************************************
    153  * Name      : int WIN32API TranslateAcceleratorA
    154  * Purpose   : Translate WM_*KEYDOWN messages to WM_COMMAND messages
    155  *             according to Accelerator table
    156  * Parameters: HWND hwnd, HACCEL haccel, LPMSG lpmsg
    157  * Variables :
    158  * Result    : int FALSE (no accelerator found) TRUE (accelerator found)
    159  * Remark    : if a accelerator is found it is not neccesarely executed
    160  *             depends on window stat
    161  *
    162  *****************************************************************************/
    163 INT WINAPI TranslateAcceleratorA(HWND hWnd, HACCEL hAccel, LPMSG msg)
    164 {
    165     /* YES, Accel16! */
    166     LPACCEL lpAccelTbl;
    167     int i;
    168 
    169     SetLastError(ERROR_SUCCESS);
    170     if (msg == NULL)
    171     {
    172           dprintf(("TranslateAcceleratorAmsg null; should hang here to be win compatible"));
    173           SetLastError(ERROR_INVALID_PARAMETER);
    174           return 0;
    175     }
    176     if (!hAccel || !(lpAccelTbl = (LPACCEL)GlobalLock(hAccel)))
    177     {
    178           dprintf(("TranslateAcceleratorA: invalid accel handle=%x", hAccel));
    179           SetLastError(ERROR_INVALID_PARAMETER);
    180           return 0;
    181     }
    182     if(!IsWindow(hWnd)) {
    183           dprintf(("TranslateAccelerator, window %x not found", hWnd));
    184           SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    185           return 0;
    186     }
    187     if ((msg->message != WM_KEYDOWN &&
    188          msg->message != WM_KEYUP &&
    189          msg->message != WM_SYSKEYDOWN &&
    190          msg->message != WM_SYSKEYUP &&
    191          msg->message != WM_CHAR))
    192     {
    193           return 0;
    194     }
    195 
    196 /*    TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
    197       "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%lx\n",
    198       hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam); */
    199 
    200     i = 0;
    201     do
    202     {
    203         if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
    204                                       lpAccelTbl[i].key,lpAccelTbl[i].cmd))
    205         {
    206             return 1;
    207         }
    208     }
    209     while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
    210 
    211 //    WARN_(accel)("couldn't translate accelerator key\n");
    212     return 0;
    213 }
    21425/**********************************************************************
    21526 *                      LoadAccelerators32W     [USER.177]
Note: See TracChangeset for help on using the changeset viewer.