Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

winhtky.c File Reference

#include "precomp.h"

Go to the source code of this file.

Functions

PWND HotKeyToWindow (DWORD key)
PHOTKEYSTRUCT HotKeyHelper (PWND pwnd)
UINT DWP_SetHotKey (PWND pwnd, DWORD dwKey)
UINT DWP_GetHotKey (PWND pwnd)


Function Documentation

UINT DWP_GetHotKey PWND  pwnd  ) 
 

Definition at line 242 of file winhtky.c.

References HotKeyHelper(), tagHOTKEYSTRUCT::key, NULL, and UINT.

Referenced by xxxDefWindowProc().

00244 { 00245 PHOTKEYSTRUCT phk; 00246 00247 if ((phk = HotKeyHelper(pwnd)) == NULL) 00248 return 0; 00249 00250 return phk->key; 00251 }

UINT DWP_SetHotKey PWND  pwnd,
DWORD  dwKey
 

Definition at line 96 of file winhtky.c.

References BOOL, FALSE, gcHotKey, gcHotKeyAlloc, gpHotKeyList, HotKeyHelper(), HOTKEYSTRUCT, HotKeyToWindow(), tagHOTKEYSTRUCT::key, LOBYTE, Lock, NULL, tagHOTKEYSTRUCT::spwnd, TestWF, TRUE, UINT, Unlock, and WFCHILD.

Referenced by xxxCreateWindowEx(), xxxDefWindowProc(), and xxxDestroyWindow().

00099 { 00100 PHOTKEYSTRUCT phk; 00101 BOOL fKeyExists = FALSE; 00102 PWND pwndTemp; 00103 00104 /* 00105 * Filter out invalid hotkeys 00106 */ 00107 if (LOBYTE(dwKey) == VK_ESCAPE || 00108 LOBYTE(dwKey) == VK_SPACE || 00109 LOBYTE(dwKey) == VK_TAB || 00110 LOBYTE(dwKey) == VK_PACKET) { 00111 00112 return (UINT)-1; 00113 } 00114 00115 /* 00116 * Don't allow hotkeys for children 00117 */ 00118 if (TestWF(pwnd, WFCHILD)) 00119 return 0; 00120 00121 /* 00122 * Check if the hot key exists and is assigned to a different pwnd 00123 */ 00124 if (dwKey != 0) { 00125 00126 pwndTemp = HotKeyToWindow(dwKey); 00127 00128 if ((pwndTemp != NULL) && (pwndTemp != pwnd)) 00129 fKeyExists = TRUE; 00130 } 00131 00132 /* 00133 * Get the hotkey assigned to the window, if any 00134 */ 00135 if ((phk = HotKeyHelper(pwnd)) == NULL) { 00136 00137 /* 00138 * Window doesn't exist in the hotkey list and key is being set 00139 * to zero, so just return. 00140 */ 00141 if (dwKey == 0) 00142 return 1; 00143 00144 /* 00145 * Allocate and point to a spot for the new hotkey 00146 */ 00147 if (gcHotKey >= gcHotKeyAlloc) { 00148 00149 if (gcHotKeyAlloc) { 00150 00151 phk = (PHOTKEYSTRUCT)UserReAllocPool( 00152 (HANDLE)gpHotKeyList, 00153 gcHotKeyAlloc * sizeof(HOTKEYSTRUCT), 00154 (gcHotKey + 1) * sizeof(HOTKEYSTRUCT), TAG_HOTKEY); 00155 00156 if (phk != NULL) { 00157 00158 gpHotKeyList = phk; 00159 phk = &gpHotKeyList[gcHotKey++]; 00160 gcHotKeyAlloc = gcHotKey; 00161 00162 } else { 00163 00164 return 0; 00165 } 00166 00167 } else { 00168 00169 UserAssert(gpHotKeyList == NULL); 00170 UserAssert(gcHotKey == 0); 00171 00172 phk = (PHOTKEYSTRUCT)UserAllocPool(sizeof(HOTKEYSTRUCT), 00173 TAG_HOTKEY); 00174 00175 if (phk != NULL) { 00176 00177 gpHotKeyList = phk; 00178 gcHotKey = 1; 00179 gcHotKeyAlloc = 1; 00180 00181 } else { 00182 00183 return 0; 00184 } 00185 } 00186 00187 } else { 00188 phk = &gpHotKeyList[gcHotKey++]; 00189 } 00190 } 00191 00192 if (dwKey == 0) { 00193 00194 /* 00195 * The hotkey for this window is being deleted. Copy the last item 00196 * on the list on top of the one being deleted. 00197 */ 00198 if (--gcHotKey) { 00199 00200 Lock(&phk->spwnd, gpHotKeyList[gcHotKey].spwnd); 00201 Unlock(&gpHotKeyList[gcHotKey].spwnd); 00202 00203 phk->key = gpHotKeyList[gcHotKey].key; 00204 phk = (PHOTKEYSTRUCT)UserReAllocPool((HANDLE)gpHotKeyList, 00205 gcHotKeyAlloc * sizeof(HOTKEYSTRUCT), 00206 gcHotKey * sizeof(HOTKEYSTRUCT), TAG_HOTKEY); 00207 00208 if (phk != NULL) { 00209 gpHotKeyList = phk; 00210 gcHotKeyAlloc = gcHotKey; 00211 } 00212 00213 } else { 00214 00215 Unlock(&gpHotKeyList[gcHotKey].spwnd); 00216 UserFreePool((HANDLE)gpHotKeyList); 00217 gpHotKeyList = NULL; 00218 gcHotKeyAlloc = 0; 00219 } 00220 00221 } else { 00222 00223 /* 00224 * Add the window and key to the list 00225 */ 00226 phk->spwnd = NULL; 00227 Lock(&phk->spwnd, pwnd); 00228 phk->key = dwKey; 00229 } 00230 00231 return fKeyExists ? 2 : 1; 00232 }

PHOTKEYSTRUCT HotKeyHelper PWND  pwnd  ) 
 

Definition at line 60 of file winhtky.c.

References gcHotKey, gpHotKeyList, NULL, and tagHOTKEYSTRUCT::spwnd.

Referenced by DWP_GetHotKey(), and DWP_SetHotKey().

00062 { 00063 PHOTKEYSTRUCT phk; 00064 int count; 00065 00066 count = gcHotKey; 00067 00068 if (gpHotKeyList == NULL) 00069 return 0; 00070 00071 phk = gpHotKeyList; 00072 00073 while (count) { 00074 if (phk->spwnd == pwnd) 00075 return phk; 00076 phk++; 00077 count--; 00078 } 00079 00080 return 0; 00081 }

PWND HotKeyToWindow DWORD  key  ) 
 

Definition at line 26 of file winhtky.c.

References gcHotKey, gpHotKeyList, tagHOTKEYSTRUCT::key, NULL, tagHOTKEYSTRUCT::spwnd, TestWF, and WFVISIBLE.

Referenced by DWP_SetHotKey(), and xxxScanSysQueue().

00028 { 00029 PHOTKEYSTRUCT phk; 00030 int ckeys; 00031 00032 ckeys = gcHotKey; 00033 00034 if (ckeys == 0) 00035 return 0; 00036 00037 phk = gpHotKeyList; 00038 00039 while (ckeys) { 00040 if (phk->key == key) 00041 return TestWF(phk->spwnd, WFVISIBLE) ? phk->spwnd : NULL; 00042 phk++; 00043 ckeys--; 00044 } 00045 00046 return 0; 00047 }


Generated on Sat May 15 19:46:09 2004 for test by doxygen 1.3.7