00099 {
00100
PHOTKEYSTRUCT phk;
00101
BOOL fKeyExists =
FALSE;
00102
PWND pwndTemp;
00103
00104
00105
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
00117
00118
if (
TestWF(pwnd, WFCHILD))
00119
return 0;
00120
00121
00122
00123
00124
if (dwKey != 0) {
00125
00126 pwndTemp =
HotKeyToWindow(dwKey);
00127
00128
if ((pwndTemp !=
NULL) && (pwndTemp != pwnd))
00129 fKeyExists =
TRUE;
00130 }
00131
00132
00133
00134
00135
if ((phk =
HotKeyHelper(pwnd)) ==
NULL) {
00136
00137
00138
00139
00140
00141
if (dwKey == 0)
00142
return 1;
00143
00144
00145
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
00196
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
00225
00226 phk->
spwnd =
NULL;
00227
Lock(&phk->
spwnd, pwnd);
00228 phk->
key = dwKey;
00229 }
00230
00231
return fKeyExists ? 2 : 1;
00232 }