Changeset 2261 for trunk/src/user32/winaccel.cpp
- Timestamp:
- Dec 30, 1999, 10:31:03 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/winaccel.cpp
r1429 r2261 1 /* $Id: winaccel.cpp,v 1. 2 1999-10-24 12:30:29sandervl Exp $ */1 /* $Id: winaccel.cpp,v 1.3 1999-12-30 09:31:03 sandervl Exp $ */ 2 2 /* 3 * Win32 accel artor key functions for OS/24 * 5 * Copyright 1999 Sandervan Leeuwen3 * Win32 accelerator key functions for OS/2 4 * 5 * Copyright 1999 Bart van Leeuwen 6 6 * 7 7 * … … 12 12 #include <misc.h> 13 13 #include <win32wbase.h> 14 15 //****************************************************************************** 16 //****************************************************************************** 14 #include <winaccel.h> 15 16 /***************************************************************************** 17 * Name : HACCEL WIN32API LoadAcceleratorsA 18 * Purpose : Load accelerator resource and return handle to it 19 * Parameters: HINSTANCE hinst, LPCSTR lpszAcc 20 * Variables : 21 * Result : Global Handle of resource 22 * Remark : see code 23 * Status : OK 24 * 25 * Author : Bart van Leeuwen [Sun, 1998/12/26 17:01] 26 *****************************************************************************/ 17 27 HACCEL WIN32API LoadAcceleratorsA(HINSTANCE hinst, LPCSTR lpszAcc) 18 28 { … … 24 34 return(rc); 25 35 } 26 //****************************************************************************** 27 //****************************************************************************** 36 /***************************************************************************** 37 * Name : HACCEL WIN32API LoadAcceleratorsW 38 * Purpose : Load accelerator resource and return handle to it 39 * Parameters: HINSTANCE hinst, LPCSTR lpszAcc 40 * Variables : 41 * Result : Global Handle of resource 42 * Remark : see code 43 * Status : OK 44 * 45 * Author : Bart van Leeuwen [Sun, 1998/12/26 17:01] 46 *****************************************************************************/ 47 28 48 HACCEL WIN32API LoadAcceleratorsW(HINSTANCE hinst, LPCWSTR lpszAccel) 29 49 { … … 31 51 32 52 rc = (HACCEL)FindResourceW(hinst, lpszAccel, RT_ACCELERATORW); 53 33 54 34 55 dprintf(("LoadAcceleratorsW returned %d\n", rc)); … … 41 62 Win32Resource *winres; 42 63 43 if(HIWORD(haccel) == 0) {44 dprintf(("DestroyAcceleratorTable: invalid haccel %x", haccel));45 SetLastError(ERROR_INVALID_PARAMETER);46 return FALSE;47 }48 64 dprintf(("DestroyAcceleratorTable %x\n", haccel)); 49 65 winres = (Win32Resource *)haccel; … … 51 67 return TRUE; 52 68 } 53 //****************************************************************************** 54 //TODO: Do more than just return? 55 //****************************************************************************** 69 /***************************************************************************** 70 * Name : int WIN32API TranslateAcceleratorA 71 * Purpose : Translate WM_*KEYDOWN messages to WM_COMMAND messages 72 * according to Accelerator table 73 * Parameters: HWND hwnd, HACCEL haccel, LPMSG lpmsg 74 * Variables : 75 * Result : int FALSE (no accelerator found) TRUE (accelerator found) 76 * Remark : if a accelerator is found it is not neccesarely executed 77 * depends on window stat 78 * Status : finished but not fully tested 79 * 80 * Author : Bart van Leeuwen [Sun, 1998/12/26 17:01] 81 *****************************************************************************/ 56 82 int WIN32API TranslateAcceleratorA(HWND hwnd, HACCEL haccel, LPMSG lpmsg) 57 83 { 58 Win32BaseWindow *window; 59 60 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 61 if(!window) { 62 //Msg for (non-client) child of our frame window 63 // dprintf(("TranslateAcceleratorA, window %x not found", hwnd)); 64 return FALSE; 84 Win32BaseWindow *window,*parentWindow,*childWindow; 85 LPWINACCEL lpAccelTbl; 86 WINACCEL tmpAccel; 87 HACCEL temp2; 88 HGLOBAL GlobHandle; 89 HWND hwndMenu,parent,child,msgHwnd; 90 int i,keyMask; 91 INT16 menuStat; 92 BOOL sendMessage; 93 94 95 //bvl: check if messages come from keyboard 96 if ((lpmsg->message != WM_KEYDOWN && 97 lpmsg->message != WM_SYSKEYDOWN)) 98 { 99 //dprintf(("TranslateAcceleratorA called by invalid message")); 100 SetLastError(ERROR_SUCCESS); 101 return FALSE; 102 } 103 104 window = Win32BaseWindow::GetWindowFromHandle(lpmsg->hwnd); 105 106 if(!window) 107 { 108 dprintf(("TranslateAcceleratorA, window %x not found", hwnd)); 109 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 110 return FALSE; 65 111 } 66 if(window->GetAccelTable() != haccel) { 67 dprintf(("TranslateAcceleratorA %X %X %X", hwnd, haccel, lpmsg->hwnd)); 68 window->SetAccelTable(haccel); 69 } 70 71 //SvL: OS/2 automatically translates accelerator keys 112 113 //bvl: Get memory pointer here 114 GlobHandle = LoadResource(NULL,haccel); 115 lpAccelTbl = (LPWINACCEL) LockResource(GlobHandle); 116 117 keyMask=0; 118 if(GetKeyState(VK_SHIFT) & 0x8000) keyMask |= FSHIFT; 119 if(GetKeyState(VK_CONTROL) & 0x8000) keyMask |= FCONTROL; 120 if(GetKeyState(VK_MENU) & 0x8000) keyMask |= FALT; 121 122 i=0; 123 do 124 { 125 if ((lpAccelTbl[i].key == lpmsg->wParam)&&(keyMask == (lpAccelTbl[i].fVirt & 126 (FSHIFT | FCONTROL | FALT)))) 127 { 128 //bvl: Accelerator found 129 dprintf(("Accelerator found for command: %X",lpAccelTbl[i].cmd)); 130 //bvl: this is not right, check control and win stat 131 // SendMessageA(hwnd,WM_COMMAND,lpAccelTbl[i].cmd,0x00010000L); 132 133 sendMessage = FALSE; 134 135 if (window->isFrameWindow()) 136 { 137 if ( !window->IsIconic() ) 138 { 139 //bvl: this is a frame window so just use that menuhandle 140 hwndMenu = window->GetMenu(); 141 if ( hwndMenu == NULL ) 142 { 143 //bvl: window does not have a menu so command isn't a menu 144 dprintf(("framenomenu")); 145 sendMessage = TRUE; 146 } 147 else 148 { 149 //bvl: get menuitem status 150 menuStat = GetMenuState(hwndMenu,lpAccelTbl[i++].cmd,MF_BYCOMMAND); 151 //bvl: -1 means no menu Item 152 if( !menuStat == -1) 153 { 154 if( menuStat & !(MF_DISABLED|MF_GRAYED) ) 155 { 156 //bvl: its a menu item and its enabled 157 dprintf(("framemenu")); 158 sendMessage = TRUE; 159 } 160 else 161 { 162 //bvl: its a menu Item but disabled 163 sendMessage = FALSE; 164 } 165 } 166 else 167 { 168 //bvl: the message is probably not a menu msg so process it 169 dprintf(("framemenunoitem")); 170 sendMessage = TRUE; 171 } 172 } 173 } 174 } 175 else 176 { 177 //bvl: the message is probably not a menu msg so process it 178 dprintf(("noframe")); 179 sendMessage = TRUE; 180 } 181 182 if ( sendMessage ) 183 { 184 //bvl: previous checks indicated that command can be send. 185 SendMessageA(hwnd,WM_COMMAND,lpAccelTbl[i].cmd,0x00010000L); 186 return TRUE; 187 188 } 189 } 190 191 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0); 192 193 SetLastError(ERROR_SUCCESS); 72 194 return FALSE; 73 195 } 74 //****************************************************************************** 75 //****************************************************************************** 196 /***************************************************************************** 197 * Name : int WIN32API TranslateAcceleratorA 198 * Remark : See TranslateAcceleratorA 199 * Status : finished but not fully tested 200 * 201 * Author : Bart van Leeuwen [Sun, 1998/12/26 17:01] 202 *****************************************************************************/ 203 76 204 int WIN32API TranslateAcceleratorW( HWND hwnd, HACCEL hAccel, LPMSG lpMsg) 77 205 {
Note:
See TracChangeset
for help on using the changeset viewer.