static LRESULT HostWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WNDPROC fnOldProc; fnOldProc = (WNDPROC)GetPropW(hwnd, WNDPROP_SCCTRLW); if (!fnOldProc) return DefWindowProcW(hwnd, uMsg, wParam, lParam); switch (uMsg) { case WM_NCDESTROY: // detach RemovePropW(hwnd, WNDPROP_SCCTRLW); CallWindowProcW(fnOldProc, hwnd, uMsg, wParam, lParam); SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)fnOldProc); return 0; case WM_ERASEBKGND: if (wParam) { RECT rc; if (GetClientRect(hwnd, &rc)) { SetBkColor((HDC)wParam, ml_color(WADLG_WNDBG)); ExtTextOutW((HDC)wParam, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0); } } return 1; case WM_SETFOCUS: if (htmlControl) { htmlControl->setFocus(TRUE); return 0; } break; } return CallWindowProcW(fnOldProc, hwnd, uMsg, wParam, lParam); }
static LRESULT WINAPI cb_newProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { WNDPROC oldproc = (WNDPROC)GetProp(hwnd,WDL_UTF8_OLDPROCPROP); if (!oldproc) return 0; if (msg==WM_NCDESTROY) { SetWindowLongPtr(hwnd, GWLP_WNDPROC,(INT_PTR)oldproc); RemoveProp(hwnd,WDL_UTF8_OLDPROCPROP); RemoveProp(hwnd,WDL_UTF8_OLDPROCPROP "W"); } else if (msg == CB_ADDSTRING || msg == CB_INSERTSTRING || msg == LB_ADDSTRING || msg == LB_INSERTSTRING) { char *str=(char*)lParam; if (lParam && WDL_HasUTF8(str)) { MBTOWIDE(wbuf,str); if (wbuf_ok) { WNDPROC oldprocW = (WNDPROC)GetProp(hwnd,WDL_UTF8_OLDPROCPROP "W"); LRESULT rv=CallWindowProcW(oldprocW ? oldprocW : oldproc,hwnd,msg,wParam,(LPARAM)wbuf); MBTOWIDE_FREE(wbuf); return rv; } MBTOWIDE_FREE(wbuf); } } else if (msg == CB_GETLBTEXT && lParam) { WNDPROC oldprocW = (WNDPROC)GetProp(hwnd,WDL_UTF8_OLDPROCPROP "W"); LRESULT l = CallWindowProcW(oldprocW ? oldprocW : oldproc,hwnd,CB_GETLBTEXTLEN,wParam,0); if (l != CB_ERR) { WIDETOMB_ALLOC(tmp,l+1); if (tmp) { LRESULT rv=CallWindowProcW(oldprocW ? oldprocW : oldproc,hwnd,msg,wParam,(LPARAM)tmp)+1; if (rv>=0) { *(char *)lParam=0; rv=WideCharToMultiByte(CP_UTF8,0,tmp,-1,(char *)lParam,((int)l+1)*3 + 32,NULL,NULL); if (rv>0) rv--; } WIDETOMB_FREE(tmp); return rv; } } } else if (msg == CB_GETLBTEXTLEN) { WNDPROC oldprocW = (WNDPROC)GetProp(hwnd,WDL_UTF8_OLDPROCPROP "W"); return CallWindowProcW(oldprocW ? oldprocW : oldproc,hwnd,msg,wParam,lParam) * 3 + 32; // make sure caller allocates a lot extra } return CallWindowProc(oldproc,hwnd,msg,wParam,lParam); }
static LRESULT CALLBACK PxTabProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { PxTabObject* self = (PxTabObject*)GetWindowLongPtrW(hwnd, GWLP_USERDATA); switch (msg) { case OCM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: return FALSE; case TCN_SELCHANGE: { int iIndex = TabCtrl_GetCurSel(self->hWin); PxTabPage_GotSelected(PyList_GetItem(self->pyPages, iIndex)); break; } } } } return CallWindowProcW(self->fnOldWinProcedure, hwnd, msg, wParam, lParam); }
static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) { struct wined3d_wndproc *entry; struct wined3d_device *device; BOOL unicode; WNDPROC proc; wined3d_wndproc_mutex_lock(); entry = wined3d_find_wndproc(window); if (!entry) { wined3d_wndproc_mutex_unlock(); ERR("Window %p is not registered with wined3d.\n", window); return DefWindowProcW(window, message, wparam, lparam); } device = entry->device; unicode = entry->unicode; proc = entry->proc; wined3d_wndproc_mutex_unlock(); if (device) return device_process_message(device, window, unicode, message, wparam, lparam, proc); if (unicode) return CallWindowProcW(proc, window, message, wparam, lparam); return CallWindowProcA(proc, window, message, wparam, lparam); }
static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); WCHAR *msg; int sel, len; switch (uMsg) { case WM_MOUSEMOVE: sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam); SendMessageW(hwnd, LB_SETCURSEL, sel, 0); break; case WM_LBUTTONDOWN: sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0); if (sel < 0) break; len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg)); ShowWindow(hwnd, SW_HIDE); HeapFree(GetProcessHeap(), 0, msg); break; default: return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam); } return 0; }
static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { WNDPROC OrigWndProc = This->OrigWndProc; switch( uMsg ) { case WM_DESTROY: IOCS_Detach( This ); break; case WM_SIZE: { RECT r; r.left = r.top = 0; r.right = LOWORD( lParam ); r.bottom = HIWORD( lParam ); IOCS_OnSize( This, &r ); } break; case WM_SHOWWINDOW: IOCS_OnShow( This, (BOOL) wParam ); break; case WM_PAINT: IOCS_OnDraw( This ); break; } return CallWindowProcW( OrigWndProc, hWnd, uMsg, wParam, lParam ); }
static DWORD WINAPI wa_newWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_WA_IPC) { switch (lParam) { case IPC_MBOPEN: case IPC_MBOPENREAL: if (!wParam || wParam == 32) { if (wParam == 32/* || g_config->ReadInt("mbautoswitch", 1)*/) // TODO: read this config value { SendMessage(SampleHTTP.hwndLibraryParent, WM_ML_IPC, (WPARAM)nowPlayingId, ML_IPC_SETCURTREEITEM); } } else { //Navigate((char *)wParam); } break; } } if (waProc) return CallWindowProcW(waProc, hwnd, msg, wParam, lParam); else return DefWindowProc(hwnd, msg, wParam, lParam); }
LRESULT CALLBACK ruler_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static WNDPROC pPrevRulerProc; static LONG EditLeftmost; static BOOL NewMetrics; switch(msg) { case WM_USER: if(wParam) { EditLeftmost = ((POINTL*)wParam)->x; pPrevRulerProc = (WNDPROC)lParam; } NewMetrics = TRUE; break; case WM_PAINT: paint_ruler(hWnd, EditLeftmost, NewMetrics); break; default: return CallWindowProcW(pPrevRulerProc, hWnd, msg, wParam, lParam); } return 0; }
static LRESULT CALLBACK CFont_WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { HANDLE_MSG (hwnd, WM_KILLFOCUS, CFont_OnKillFocus); default: return CallWindowProcW((WNDPROC)GetWindowLongPtrW(hwnd, GWLP_USERDATA), hwnd, msg, wParam, lParam); } }
LRESULT CALLBACK UnicodeSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT Result; switch(msg) { case WM_GETTEXT: printf("UnicodeSubclassProc calling SavedWindowProc\n"); Result = CallWindowProcW(SavedWndProcW, hWnd, msg, wParam, lParam); printf("UnicodeSubclassProc Unicode window text \"%S\"\n", (LPWSTR) lParam); break; default: Result = CallWindowProcW(SavedWndProcW, hWnd, msg, wParam, lParam); break; } return Result; }
static LRESULT CALLBACK new_nav_dialog_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { switch (msg) { case DM_SETDEFID: ok( IsWindowEnabled( GetDlgItem(hwnd, wp) ), "button is not enabled\n" ); break; } return CallWindowProcW( old_nav_dialog_proc, hwnd, msg, wp, lp ); }
BOOL CALLBACK AP_Win32Dialog_Stylist::s_treeProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { if (msg == WM_LBUTTONDBLCLK) { // The user has double clicked on a tree item AP_Win32Dialog_Stylist * pThis = (AP_Win32Dialog_Stylist *)GetWindowLongPtrW(hWnd,GWLP_USERDATA); if (pThis->_styleClicked()) pThis->Apply(); return 1; } return CallWindowProcW(hTreeProc, hWnd, msg, wParam, lParam); }
static LRESULT CallParentWndProc(WNDPROC pfnParentWndProc, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT rc; if (!pfnParentWndProc) pfnParentWndProc = GetPickerInfo(hWnd)->pfnParentWndProc; if (IsWindowUnicode(hWnd)) rc = CallWindowProcW(pfnParentWndProc, hWnd, message, wParam, lParam); else rc = CallWindowProcA(pfnParentWndProc, hWnd, message, wParam, lParam); return rc; }
static INT_PTR CALLBACK DTPProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_KEYDOWN: /* Stop the timer when the user is about to change the time */ if ((wParam != VK_LEFT) & (wParam != VK_RIGHT)) KillTimer(GetParent(hwnd), ID_TIMER); break; } return CallWindowProcW(pOldWndProc, hwnd, uMsg, wParam, lParam); }
LRESULT APIENTRY CAutoComplete::ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CAutoComplete *pThis = reinterpret_cast<CAutoComplete *>(GetWindowLongPtrW(hwnd, GWLP_USERDATA)); WCHAR *msg; int sel, len; switch (uMsg) { case WM_MOUSEMOVE: { sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam); SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0); }; break; case WM_LBUTTONDOWN: { sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0); if (sel < 0) break; len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, 0); msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR)); if (msg) { SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(pThis->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(pThis->hwndEdit, EM_SETSEL, 0, wcslen(msg)); ShowWindow(hwnd, SW_HIDE); HeapFree(GetProcessHeap(), 0, msg); } else { TRACE("HeapAlloc failed to allocate %d bytes\n", (len + 1) * sizeof(WCHAR)); } }; break; default: return CallWindowProcW(pThis->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam); } return 0; }
LRESULT StBrowserPlugin::stWndProc(HWND theWnd, UINT theMsg, WPARAM theParamW, LPARAM theParamL) { if(theMsg == WM_ERASEBKGND) { return 1; } else if(theMsg == WM_PAINT && !myIsActive) { RECT aRect; GetClientRect(theWnd, &aRect); HDC aDevCtx = GetDC(theWnd); FillRect(aDevCtx, &aRect, myBackBrush); ReleaseDC(theWnd, aDevCtx); return 0; } return CallWindowProcW(myProcOrig, theWnd, theMsg, theParamW, theParamL); }
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WNDPROC oldwndproc; static WCHAR s_szNode[256]; oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (uMsg) { case WM_KEYUP: if (wParam == VK_RETURN) { GetWindowTextW(hwnd, s_szNode, COUNT_OF(s_szNode)); SelectNode(g_pChildWnd->hTreeWnd, s_szNode); } break; default: break; } return CallWindowProcW(oldwndproc, hwnd, uMsg, wParam, lParam); }
static LRESULT WINAPI syslink_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; msg.id = 0; add_message(sequences, SYSLINK_SEQ_INDEX, &msg); defwndproc_counter++; ret = CallWindowProcW(syslink_oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { tooltip_data *data = GetPropW(hwnd, wszTooltipData); TRACE("%d %p\n", msg, data); if(msg == TTM_WINDOWFROMPOINT) { RECT rect; POINT *pt = (POINT*)lParam; TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y); GetWindowRect(data->doc->hwnd, &rect); if(rect.left <= pt->x && pt->x <= rect.right && rect.top <= pt->y && pt->y <= rect.bottom) return (LPARAM)data->doc->hwnd; } return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam); }
LRESULT CALLBACK NzWindowImpl::MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { NzWindowImpl* me; if (message == WM_CREATE) { me = reinterpret_cast<NzWindowImpl*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams); SetWindowLongPtr(window, GWL_USERDATA, reinterpret_cast<LONG_PTR>(me)); } else me = reinterpret_cast<NzWindowImpl*>(GetWindowLongPtr(window, GWL_USERDATA)); if (me) { if (me->HandleMessage(window, message, wParam, lParam)) return 0; else if (me->m_callback) return CallWindowProcW(reinterpret_cast<WNDPROC>(me->m_callback), window, message, wParam, lParam); } return DefWindowProcW(window, message, wParam, lParam); }
/*********************************************************************** * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy * control. */ static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC); TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n", hwnd, superClassWndProc, uMsg, wParam, lParam); if (uMsg == WM_KEYDOWN) { HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND); UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam); } else if (uMsg == WM_MOUSEWHEEL) { HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND); UPDOWN_MouseWheel(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam); } return CallWindowProcW( superClassWndProc, hwnd, uMsg, wParam, lParam); }
static LRESULT CALLBACK DevView_EditWndProc(HWND hwndEdit, UINT nMessage, WPARAM wParam, LPARAM lParam) { struct DevViewInfo *pDevViewInfo; struct DevViewEntry *pEnt; LRESULT rc; HWND hwndDevView; LONG_PTR l; l = GetWindowLongPtr(hwndEdit, GWLP_USERDATA); pEnt = (struct DevViewEntry *) l; if (IsWindowUnicode(hwndEdit)) rc = CallWindowProcW(pEnt->pfnEditWndProc, hwndEdit, nMessage, wParam, lParam); else rc = CallWindowProcA(pEnt->pfnEditWndProc, hwndEdit, nMessage, wParam, lParam); if (nMessage == WM_SETTEXT) { hwndDevView = GetParent(hwndEdit); pDevViewInfo = GetDevViewInfo(hwndDevView); DevView_TextChanged(hwndDevView, pEnt - pDevViewInfo->pEntries, (LPCTSTR) lParam); } return rc; }
LRESULT CALLBACK newEditProc(HWND hEdit, UINT message, WPARAM wParam, LPARAM lParam){ //новый процесс обработки эдита INT keyCode = (INT)wParam; switch (message){ case WM_KEYDOWN:{ if (keyCode == VK_SHIFT || keyCode == VK_PAUSE || keyCode==VK_CONTROL){ //если нажимаются допустимые клавиши SetHotKeyToReg(keyCode); //заносим новую горяцую клавишу в реестр SetHotKeyToEdit(hEdit); // выводим в эдит pInitHotKeyDll(keyCode,hEdit); // экспортируем в длл } break; } case WM_MBUTTONDOWN:{ //тоже самое с средн.кн.мыши SetHotKeyToReg(VK_MBUTTON); SetHotKeyToEdit(hEdit); pInitHotKeyDll(VK_MBUTTON,hEdit); } default: return CallWindowProcW((WNDPROC)glbOldEditProc, hEdit, message, wParam, lParam); } return 0; }
/* Window procedure for autocompletion */ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW); LPOLESTR strs; HRESULT hr; WCHAR hwndText[255]; WCHAR *hwndQCText; RECT r; BOOL control, filled, displayall = FALSE; int cpt, height, sel; if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); switch (uMsg) { case CB_SHOWDROPDOWN: ShowWindow(This->hwndListBox, SW_HIDE); break; case WM_KILLFOCUS: if ((This->options & ACO_AUTOSUGGEST) && ((HWND)wParam != This->hwndListBox)) { ShowWindow(This->hwndListBox, SW_HIDE); } return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); case WM_KEYUP: GetWindowTextW( hwnd, hwndText, 255); switch(wParam) { case VK_RETURN: /* If quickComplete is set and control is pressed, replace the string */ control = GetKeyState(VK_CONTROL) & 0x8000; if (control && This->quickComplete) { hwndQCText = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR)); sel = sprintfW(hwndQCText, This->quickComplete, hwndText); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText); SendMessageW(hwnd, EM_SETSEL, 0, sel); HeapFree(GetProcessHeap(), 0, hwndQCText); } ShowWindow(This->hwndListBox, SW_HIDE); return 0; case VK_LEFT: case VK_RIGHT: return 0; case VK_UP: case VK_DOWN: /* Two cases here : - if the listbox is not visible, displays it with all the entries if the style ACO_UPDOWNKEYDROPSLIST is present but does not select anything. - if the listbox is visible, change the selection */ if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST)) && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) ) { /* We must display all the entries */ displayall = TRUE; } else { if (IsWindowVisible(This->hwndListBox)) { int count; count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0); /* Change the selection */ sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0); if (wParam == VK_UP) sel = ((sel-1)<0)?count-1:sel-1; else sel = ((sel+1)>= count)?-1:sel+1; SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0); if (sel != -1) { WCHAR *msg; int len; len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0); msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR)); SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg)); HeapFree(GetProcessHeap(), 0, msg); } else { SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup); SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup)); } } return 0; } break; case VK_BACK: case VK_DELETE: if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) { ShowWindow(This->hwndListBox, SW_HIDE); return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); } if (This->options & ACO_AUTOAPPEND) { DWORD b; SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, 0); if (b>1) { hwndText[b-1] = '\0'; } else { hwndText[0] = '\0'; SetWindowTextW(hwnd, hwndText); } } break; default: ; } SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0); HeapFree(GetProcessHeap(), 0, This->txtbackup); This->txtbackup = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(hwndText)+1)*sizeof(WCHAR)); lstrcpyW(This->txtbackup, hwndText); /* Returns if there is no text to search and we doesn't want to display all the entries */ if ((!displayall) && (! *hwndText) ) break; IEnumString_Reset(This->enumstr); filled = FALSE; for(cpt = 0;;) { ULONG fetched; hr = IEnumString_Next(This->enumstr, 1, &strs, &fetched); if (hr != S_OK) break; if (strstrW(strs, hwndText) == strs) { if (!filled && (This->options & ACO_AUTOAPPEND)) { SetWindowTextW(hwnd, strs); SendMessageW(hwnd, EM_SETSEL, lstrlenW(hwndText), lstrlenW(strs)); if (!(This->options & ACO_AUTOSUGGEST)) break; } if (This->options & ACO_AUTOSUGGEST) { SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); cpt++; } filled = TRUE; } } if (This->options & ACO_AUTOSUGGEST) { if (filled) { height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0); SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0); GetWindowRect(hwnd, &r); SetParent(This->hwndListBox, HWND_DESKTOP); /* It seems that Windows XP displays 7 lines at most and otherwise displays a vertical scroll bar */ SetWindowPos(This->hwndListBox, HWND_TOP, r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)), SWP_SHOWWINDOW ); } else { ShowWindow(This->hwndListBox, SW_HIDE); } } break; case WM_DESTROY: { WNDPROC proc = This->wpOrigEditProc; RemovePropW(hwnd, autocomplete_propertyW); SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)proc); This->hwndEdit = NULL; if (This->hwndListBox) DestroyWindow(This->hwndListBox); IAutoComplete2_Release((IAutoComplete2 *)This); return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam); } default: return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); } return 0; }
longptr_t EditListControl::windowProcImpl(HWND window, uint32_t message, uintptr_t wParam, longptr_t lParam) { return CallWindowProcW(getOldProc(), window, message, wParam, lParam); }
/** * Helper: Subclassed Windows WNDPROC */ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (::GetPropW(hwnd, kWatch) > (HANDLE)0x0) { // Watcher stuff switch (uMsg) { case WM_WINDOWPOSCHANGING: { /* XXX Fix this bit to something more reasonable The following code kinda replicates the way mozilla gets the window state. We intensionally "hide" the SW_SHOWMINIMIZED here. This indeed might cause some side effects, but if it didn't we couldn't open menus due to bugzilla #435848. This might defeat said bugfix completely reverting to old behavior, but only when we're active, of course. */ WINDOWPOS *wp = reinterpret_cast<WINDOWPOS*>(lParam); if (wp == 0) { goto WndProcEnd; } if (wp->flags & SWP_FRAMECHANGED && ::IsWindowVisible(hwnd)) { WINDOWPLACEMENT pl; pl.length = sizeof(WINDOWPLACEMENT); ::GetWindowPlacement(hwnd, &pl); if (pl.showCmd == SW_SHOWMINIMIZED) { return 0; } } break; } case WM_WINDOWPOSCHANGED: { /* XXX Fix this bit to something more reasonable The following code kinda replicates the way mozilla gets the window state. We intensionally "hide" the SW_SHOWMINIMIZED here. This indeed might cause some side effects, but if it didn't we couldn't open menus due to bugzilla #435848,. This might defeat said bugfix completely reverting to old behavior, but only when we're active, of course. */ WINDOWPOS *wp = reinterpret_cast<WINDOWPOS*>(lParam); if (wp == 0) { goto WndProcEnd; } if (wp->flags & SWP_SHOWWINDOW) { // Shown again, unexpectedly that is, so release PostMessage(hwnd, WM_TRAYCALLBACK, 0, 1); } else if (wp->flags & SWP_FRAMECHANGED && ::IsWindowVisible(hwnd)) { WINDOWPLACEMENT pl; pl.length = sizeof(WINDOWPLACEMENT); ::GetWindowPlacement(hwnd, &pl); if (pl.showCmd == SW_SHOWMINIMIZED && (gWatchMode & kTrayOnMinimize)) { PostMessage(hwnd, WM_TRAYCALLBACK, 0, 0); // We're active, ignore return 0; } } break; } // case WM_WINDOWPOSCHANGED case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: // Frame button clicked if (wParam == HTCLOSE && (gWatchMode & kTrayOnClose)) { PostMessage(hwnd, WM_TRAYCALLBACK, 0, 0); return TRUE; } break; case WM_SYSCOMMAND: // Window menu if (wParam == SC_CLOSE && (gWatchMode & kTrayOnClose)) { PostMessage(hwnd, WM_TRAYCALLBACK, 0, 0); return 0; } break; } } if (::GetPropW(hwnd, kIcon) == (HANDLE)0x1) { // Icon stuff // This is a badly documented custom broadcast message by explorer if (uMsg == WM_TASKBARCREATED) { // Try to get the platform icon NOTIFYICONDATAW *iconData = reinterpret_cast<NOTIFYICONDATAW*>(GetPropW(hwnd, kIconData)); if (iconData == 0) { goto WndProcEnd; } // The taskbar was (re)created. Add ourselves again. Shell_NotifyIconW(NIM_ADD, iconData); } // We got clicked. How exciting, isn't it. else if (uMsg == WM_TRAYMESSAGE) { mouseevent_t *event = new(std::nothrow) mouseevent_t; if (!event) { goto WndProcEnd; } event->clickCount = 0; switch (LOWORD(lParam)) { case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: case WM_CONTEXTMENU: case NIN_KEYSELECT: event->clickCount = 1; break; case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: event->clickCount = 2; break; } switch (LOWORD(lParam)) { case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: event->button = 0; break; case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: event->button = 1; break; case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: case WM_CONTEXTMENU: case NIN_KEYSELECT: event->button = 2; break; } if (event->clickCount) { POINT wpt; if (GetCursorPos(&wpt) == TRUE) { event->x = wpt.x; event->y = wpt.y; event->keys = 0; if (::GetKeyState(VK_CONTROL) & 0x8000) { event->keys += (1<<0); } if (::GetKeyState(VK_MENU) & 0x8000) { event->keys += (1<<1); } if (::GetKeyState(VK_SHIFT) & 0x8000) { event->keys += (1<<2); } PostMessage(hwnd, WM_TRAYCALLBACK, 1, (LPARAM)event); } else { delete event; } } return 0; } // Window title changed else if (uMsg == WM_SETTEXT) { NOTIFYICONDATAW *iconData = reinterpret_cast<NOTIFYICONDATAW*>(GetPropW(hwnd, kIconData)); if (iconData == 0) { goto WndProcEnd; } // First, let the original wndproc process this message, // so that we may query the thing afterwards ;) // this is required because we cannot know the encoding of this message for sure ;) LRESULT rv; WNDPROC oldWindowProc = reinterpret_cast<WNDPROC>(::GetPropW(hwnd, kOldProc)); if (oldWindowProc != 0) { rv = CallWindowProcW(oldWindowProc, hwnd, uMsg, wParam, lParam); } else { rv = DefWindowProcW(hwnd, uMsg, wParam, lParam); } if (::GetWindowTextW(hwnd, iconData->szTip, 127) != 0) { iconData->szTip[128] = '\0'; Shell_NotifyIconW(NIM_MODIFY, iconData); } return rv; } } // Need to handle this in or own message or crash! // See https://bugzilla.mozilla.org/show_bug.cgi?id=671266 if (uMsg == WM_TRAYCALLBACK) { if (wParam == 0) { minimize_callback_t callback = reinterpret_cast<minimize_callback_t>(::GetPropW(hwnd, kWatchMinimizeProc)); if (callback) { callback(hwnd, (int)lParam); } } else if (wParam == 1) { mouseevent_t *event = reinterpret_cast<mouseevent_t*>(lParam); mouseevent_callback_t callback = reinterpret_cast<mouseevent_callback_t>(::GetPropW(hwnd, kIconMouseEventProc)); if (event && callback) { // SFW/PM is a win32 hack, so that the context menu is hidden when loosing focus. ::SetForegroundWindow(hwnd); callback(hwnd, event); ::PostMessage(hwnd, WM_NULL, 0, 0L); } delete event; } return 0; } WndProcEnd: // Call the old WNDPROC or at lest DefWindowProc WNDPROC oldProc = reinterpret_cast<WNDPROC>(::GetPropW(hwnd, kOldProc)); if (oldProc != 0) { return ::CallWindowProcW(oldProc, hwnd, uMsg, wParam, lParam); } return ::DefWindowProcW(hwnd, uMsg, wParam, lParam); }
/* * period: move and select the text in the next field to the right if * the current field is not empty(l!=0), we are not in the * left most position, and nothing is selected(startsel==endsel) * * spacebar: same behavior as period * * alpha characters: completely ignored * * digits: accepted when field text length < 2 ignored otherwise. * when 3 numbers have been entered into the field the value * of the field is checked, if the field value exceeds the * maximum value and is changed the field remains the current * field, otherwise focus moves to the field to the right * * tab: change focus from the current ipaddress control to the next * control in the tab order * * right arrow: move to the field on the right to the left most * position in that field if no text is selected, * we are in the right most position in the field, * we are not in the right most field * * left arrow: move to the field on the left to the right most * position in that field if no text is selected, * we are in the left most position in the current field * and we are not in the left most field * * backspace: delete the character to the left of the cursor position, * if none are present move to the field on the left if * we are not in the left most field and delete the right * most digit in that field while keeping the cursor * on the right side of the field */ LRESULT CALLBACK IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND Self = (HWND)GetPropW (hwnd, IP_SUBCLASS_PROP); IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (Self, 0); CHAR c = (CHAR)wParam; INT index, len = 0, startsel, endsel; IPPART_INFO *part; TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam); if ( (index = IPADDRESS_GetPartIndex(infoPtr, hwnd)) < 0) return 0; part = &infoPtr->Part[index]; if (uMsg == WM_CHAR || uMsg == WM_KEYDOWN) { len = GetWindowTextLengthW (hwnd); SendMessageW(hwnd, EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); } switch (uMsg) { case WM_CHAR: if(isdigit(c)) { if(len == 2 && startsel==endsel && endsel==len) { /* process the digit press before we check the field */ int return_val = CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam); /* if the field value was changed stay at the current field */ if(!IPADDRESS_ConstrainField(infoPtr, index)) IPADDRESS_GotoNextField (infoPtr, index, POS_DEFAULT); return return_val; } else if (len == 3 && startsel==endsel && endsel==len) IPADDRESS_GotoNextField (infoPtr, index, POS_SELALL); else if (len < 3) break; } else if(c == '.' || c == ' ') { if(len && startsel==endsel && startsel != 0) { IPADDRESS_GotoNextField(infoPtr, index, POS_SELALL); } } else if (c == VK_BACK) break; return 0; case WM_KEYDOWN: switch(c) { case VK_RIGHT: if(startsel==endsel && startsel==len) { IPADDRESS_GotoNextField(infoPtr, index, POS_LEFT); return 0; } break; case VK_LEFT: if(startsel==0 && startsel==endsel && index > 0) { IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT); return 0; } break; case VK_BACK: if(startsel==endsel && startsel==0 && index > 0) { IPPART_INFO *prev = &infoPtr->Part[index-1]; WCHAR val[10]; if(GetWindowTextW(prev->EditHwnd, val, 5)) { val[lstrlenW(val) - 1] = 0; SetWindowTextW(prev->EditHwnd, val); } IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT); return 0; } break; } break; case WM_KILLFOCUS: if (IPADDRESS_GetPartIndex(infoPtr, (HWND)wParam) < 0) IPADDRESS_Notify(infoPtr, EN_KILLFOCUS); break; case WM_SETFOCUS: if (IPADDRESS_GetPartIndex(infoPtr, (HWND)wParam) < 0) IPADDRESS_Notify(infoPtr, EN_SETFOCUS); break; } return CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam); }
/********************************************************************** * The dialog subclass window proc. */ LRESULT CALLBACK THEMING_DialogSubclassProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, ULONG_PTR dwRefData) { HTHEME theme = GetWindowTheme ( hWnd ); static const WCHAR themeClass[] = { 'W','i','n','d','o','w',0 }; BOOL themingActive = IsThemeDialogTextureEnabled (hWnd); BOOL doTheming = themingActive && (theme != NULL); LRESULT result; switch (msg) { case WM_CREATE: result = THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); theme = OpenThemeData( hWnd, themeClass ); return result; case WM_DESTROY: CloseThemeData ( theme ); SetWindowTheme( hWnd, NULL, NULL ); OpenThemeData( hWnd, NULL ); return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); case WM_THEMECHANGED: CloseThemeData ( theme ); OpenThemeData( hWnd, themeClass ); InvalidateRect( hWnd, NULL, TRUE ); return 0; case WM_SYSCOLORCHANGE: if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); /* Do nothing. When themed, a WM_THEMECHANGED will be received, too, * which will do the repaint. */ break; case WM_ERASEBKGND: if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); { RECT rc; WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC); if (!CallWindowProcW(dlgp, hWnd, msg, wParam, lParam)) { /* Draw background*/ GetClientRect (hWnd, &rc); if (IsThemePartDefined (theme, WP_DIALOG, 0)) /* Although there is a theme for the WINDOW class/DIALOG part, * but I[res] haven't seen Windows using it yet... Even when * dialog theming is activated, the good ol' BTNFACE * background seems to be used. */ #if 0 DrawThemeBackground (theme, (HDC)wParam, WP_DIALOG, 0, &rc, NULL); #endif return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); else /* We might have gotten a TAB theme class, so check if we can * draw as a tab page. */ if (IsThemePartDefined (theme, TABP_BODY, 0)) DrawThemeBackground (theme, (HDC)wParam, TABP_BODY, 0, &rc, NULL); else return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam); } return 1; }
LRESULT CALLBACK CMessageLoopHook::ProcessMessage ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { CMessageLoopHook * pThis; // Get a pointer to ourself. pThis = CMessageLoopHook::GetSingletonPtr ( ); if ( pThis ) pThis->m_ProcessMessageTimer.Reset(); // Alternate alt-tab system if ( pThis && hwnd == pThis->GetHookedWindowHandle () ) { if ( uMsg == WM_ACTIVATE && LOWORD(wParam) == WA_ACTIVE ) { GetVideoModeManager()->OnGainFocus(); } if ( uMsg == WM_ACTIVATE && LOWORD(wParam) == WA_INACTIVE ) { GetVideoModeManager()->OnLoseFocus(); } if ( uMsg == WM_PAINT ) { GetVideoModeManager()->OnPaint(); } } // Log our state if ( uMsg == WM_KILLFOCUS || (uMsg == WM_ACTIVATE && LOWORD(wParam) == WA_INACTIVE) ) { CSetCursorPosHook::GetSingleton ().DisableSetCursorPos (); } else if ( uMsg == WM_SETFOCUS || (uMsg == WM_ACTIVATE && LOWORD(wParam) != WA_INACTIVE) ) { if ( !g_pCore->GetLocalGUI ()->InputGoesToGUI () ) CSetCursorPosHook::GetSingleton ().EnableSetCursorPos (); } // Prevent GTA from knowing about kill focuses. Prevents pausing. if ( uMsg == WM_KILLFOCUS || (uMsg == WM_ACTIVATE && LOWORD(wParam) == WA_INACTIVE) ) { return true; } // Disable the system context menu by clicking in the process icon or pressing ALT+SPACE. if ( uMsg == WM_SYSCOMMAND ) { if ( wParam == 0xF093 || wParam == SC_KEYMENU || wParam == SC_MOUSEMENU ) return 0; } // Quit message? if ( uMsg == WM_CLOSE ) { g_pCore->Quit (); } if ( uMsg == WM_COPYDATA ) { PCOPYDATASTRUCT pCDS = (PCOPYDATASTRUCT) lParam; if ( pCDS->dwData == URI_CONNECT ) { LPSTR szConnectInfo = (LPSTR) pCDS->lpData; CCommandFuncs::Connect ( szConnectInfo ); } } // Make sure our pointers are valid. if ( pThis != NULL && hwnd == pThis->GetHookedWindowHandle () && g_pCore->AreModulesLoaded() ) { g_pCore->UpdateIsWindowMinimized (); // Force update of stuff if ( uMsg == WM_TIMER && wParam == IDT_TIMER1 ) g_pCore->WindowsTimerHandler(); // Used for 'minimized before first game' pulses // Handle IME if input is not for the GUI if ( !g_pCore->GetLocalGUI ()->InputGoesToGUI () ) { if ( uMsg == WM_KEYDOWN ) { // Recover virtual key if ( wParam == VK_PROCESSKEY ) wParam = MapVirtualKey ( lParam >> 16, MAPVK_VSC_TO_VK_EX ); } if ( uMsg == WM_IME_STARTCOMPOSITION || uMsg == WM_IME_ENDCOMPOSITION || uMsg == WM_IME_COMPOSITION ) { // Cancel, stop, block and ignore HIMC himc = ImmGetContext ( hwnd ); ImmNotifyIME ( himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0 ); ImmReleaseContext ( hwnd, himc ); return true; } } // Pass escape keyup to onClientKey if ( uMsg == WM_KEYUP && wParam == VK_ESCAPE ) { g_pCore->GetKeyBinds()->TriggerKeyStrokeHandler ( "escape", uMsg == WM_KEYDOWN, true ); return true; } // Suppress auto repeat of escape and console toggle keys if ( ( uMsg == WM_KEYDOWN || uMsg == WM_CHAR ) && ( wParam == VK_ESCAPE || wParam == VK_F8 || wParam == '`' ) ) { bool bFirstHit = ( lParam & 0x40000000 ) ? false:true; if ( !bFirstHit ) return true; } // Slightly hacky way of suppressing escape character when console is closed with escape key if ( uMsg == WM_CHAR && wParam == VK_ESCAPE ) { bool bTemp = ms_bIgnoreNextEscapeCharacter; ms_bIgnoreNextEscapeCharacter = false; if ( bTemp ) return true; } if ( CKeyBinds::IsFakeCtrl_L ( uMsg, wParam, lParam ) ) return true; // See if this is message was caused by our asynchronous sockets if ( uMsg >= WM_ASYNCTRAP && uMsg <= ( WM_ASYNCTRAP + 511 )) { /* ACHTUNG: uMsg - 10? Windows seems to add 10 or there's a bug in the message code. Hack! */ // Let the CTCPManager handle it CTCPManager::GetSingletonPtr ()->HandleEvent ( ( uMsg - WM_ASYNCTRAP ), wParam, lParam ); } bool bWasCaptureKey = false; CMainMenu* pMainMenu = g_pCore->GetLocalGUI ()->GetMainMenu (); if ( pMainMenu ) { CSettings* pSettings = pMainMenu->GetSettingsWindow (); if ( pSettings ) { if ( uMsg == WM_KEYDOWN && wParam == VK_ESCAPE && GetJoystickManager ()->IsCapturingAxis () ) { GetJoystickManager ()->CancelCaptureAxis ( true ); return true; } bWasCaptureKey = ( pSettings->IsCapturingKey () && pSettings->ProcessMessage ( uMsg, wParam, lParam ) ); if ( !bWasCaptureKey ) { // If Escape is pressed and we're playing ingame, we show/hide the menu if ( uMsg == WM_KEYDOWN && wParam == VK_ESCAPE && g_pCore->IsConnected () ) { // Hide the console CConsoleInterface* pConsole = g_pCore->GetConsole (); if ( pConsole->IsVisible () ) { ms_bIgnoreNextEscapeCharacter = true; pConsole->SetVisible ( false ); return true; } // The mainmenu makes sure it isn't hidden if UseIngameButtons == false if ( !CCore::GetSingleton().IsOfflineMod () ) { if ( g_pCore->GetKeyBinds()->TriggerKeyStrokeHandler ( "escape", uMsg == WM_KEYDOWN, true ) ) { // Stop chat input if ( CLocalGUI::GetSingleton ().IsChatBoxInputEnabled () ) { CLocalGUI::GetSingleton ().SetChatBoxInputEnabled ( false ); return true; } CLocalGUI::GetSingleton ().SetMainMenuVisible ( !CLocalGUI::GetSingleton ().IsMainMenuVisible () ); } return true; } } else if ( uMsg == WM_KEYDOWN && wParam == VK_ESCAPE && !g_pCore->IsConnected () ) { // If Escape is pressed and we're not playing ingame, hide certain windows CLocalGUI::GetSingleton ().GetMainMenu ()->OnEscapePressedOffLine (); } // If CTRL and Tab are pressed, Trigger a skip if ( ( uMsg == WM_KEYDOWN && wParam == VK_TAB ) ) { eSystemState systemState = g_pCore->GetGame ()->GetSystemState (); if ( systemState == 7 || systemState == 8 || systemState == 9 ) { short sCtrlState = GetKeyState ( VK_CONTROL ); short sShiftState = GetKeyState ( VK_SHIFT ); if ( sCtrlState & 0x8000 ) { CSettings * pSettings = CLocalGUI::GetSingleton ().GetMainMenu ()->GetSettingsWindow (); CServerBrowser * pServerBrowser = CLocalGUI::GetSingleton ().GetMainMenu ()->GetServerBrowser (); if ( pSettings && pSettings->IsVisible ( ) && pSettings->IsActive ( ) ) { pSettings->TabSkip ( ( sShiftState & 0x8000 ) ? true : false ); } else if ( pServerBrowser && pServerBrowser->IsVisible ( ) && pServerBrowser->IsActive ( ) ) { pServerBrowser->TabSkip ( ( sShiftState & 0x8000 ) ? true : false ); } } } } if ( ( uMsg == WM_KEYDOWN && ( wParam >= VK_1 && wParam <= VK_9 ) ) ) { eSystemState systemState = g_pCore->GetGame ()->GetSystemState (); if ( systemState == 7 || systemState == 8 || systemState == 9 ) { short sCtrlState = GetKeyState ( VK_CONTROL ); if ( sCtrlState & 0x8000 ) { CSettings * pSettings = CLocalGUI::GetSingleton ().GetMainMenu ()->GetSettingsWindow (); CServerBrowser * pServerBrowser = CLocalGUI::GetSingleton ().GetMainMenu ()->GetServerBrowser (); if ( pSettings && pSettings->IsVisible ( ) && pSettings->IsActive ( ) ) { pSettings->SetSelectedIndex ( ( wParam - VK_1 ) - 1 ); } else if ( pServerBrowser && pServerBrowser->IsVisible ( ) && pServerBrowser->IsActive ( ) ) { pServerBrowser->SetSelectedIndex ( ( wParam - VK_1 ) - 1 ); } } } } // If F8 is pressed, we show/hide the console if ( ( uMsg == WM_KEYDOWN && wParam == VK_F8 ) || ( uMsg == WM_CHAR && wParam == '`' ) ) { eSystemState systemState = g_pCore->GetGame ()->GetSystemState (); if ( CLocalGUI::GetSingleton ().IsConsoleVisible () || systemState == 7 || systemState == 8 || systemState == 9 ) /* GS_FRONTEND, GS_INIT_PLAYING_GAME, GS_PLAYING_GAME */ { CLocalGUI::GetSingleton ().SetConsoleVisible ( !CLocalGUI::GetSingleton ().IsConsoleVisible () ); } return true; } // If the console is accepting input, and we pressed down/up, scroll the console history // or if we pressed tab, step through possible autocomplete matches if ( CLocalGUI::GetSingleton ().GetConsole()->IsInputActive() ) { if ( uMsg == WM_KEYDOWN ) { if ( wParam == VK_DOWN ) { CLocalGUI::GetSingleton ().GetConsole ()->SetPreviousHistoryText (); } if ( wParam == VK_UP ) { CLocalGUI::GetSingleton ().GetConsole ()->SetNextHistoryText (); } if ( wParam == VK_TAB ) { CLocalGUI::GetSingleton ().GetConsole ()->SetNextAutoCompleteMatch (); } else { CLocalGUI::GetSingleton ().GetConsole ()->ResetAutoCompleteMatch (); } } } else if ( uMsg == WM_KEYDOWN && CLocalGUI::GetSingleton().GetMainMenu()->GetServerBrowser()->IsAddressBarAwaitingInput() ) { if ( wParam == VK_DOWN ) { CLocalGUI::GetSingleton().GetMainMenu()->GetServerBrowser()->SetNextHistoryText ( true ); } if ( wParam == VK_UP ) { CLocalGUI::GetSingleton().GetMainMenu()->GetServerBrowser()->SetNextHistoryText ( false ); } } } } } if ( !bWasCaptureKey ) { // Store our keydown for backup unicode translation if ( uMsg == WM_KEYDOWN ) { m_LastVirtualKeyCode = wParam; m_LastScanCode = (BYTE)((lParam >> 16) & 0x000F); GetKeyboardState( m_LastKeyboardState ); } // If it was a question mark character, we may have an unprocessed unicode character if ( uMsg == WM_CHAR && wParam == 0x3F ) { wchar_t* wcsUnicode = new wchar_t[1]; ToUnicodeEx ( m_LastVirtualKeyCode, m_LastScanCode, m_LastKeyboardState, wcsUnicode, 1, 0, GetKeyboardLayout(0) ); wParam = (WPARAM)wcsUnicode[0]; delete wcsUnicode; } // Lead the message through the keybinds message processor g_pCore->GetKeyBinds ()->ProcessMessage ( hwnd, uMsg, wParam, lParam ); bool bProcessed = false, bClientProcessed = false; // Check and see if the GUI should process this message bProcessed = CLocalGUI::GetSingleton ().ProcessMessage ( hwnd, uMsg, wParam, lParam ); // Check and see if the Core/mod should process this message if ( !CCore::GetSingleton ().GetGame ()->IsAtMenu() ) { pfnProcessMessage pfnClientMessageProcessor = CCore::GetSingleton ().GetClientMessageProcessor(); if ( pfnClientMessageProcessor ) { bClientProcessed = pfnClientMessageProcessor ( hwnd, uMsg, wParam, lParam ); } } // If GTA can process this key if ( !bProcessed && !bClientProcessed ) { // ALWAYS return true on escape to stop us getting to GTA's menu if ( uMsg == WM_KEYDOWN && wParam == VK_ESCAPE ) { return true; } // Prevent game window auto-minimizing if full screen and: // 1. More than one monitor present // and 2. Minimizing option disabled // or // 1. Starting up (Main menu has not been displayed yet) if ( uMsg == WM_ACTIVATE || uMsg == WM_ACTIVATEAPP || uMsg == WM_NCACTIVATE || uMsg == WM_SETFOCUS || uMsg == WM_KILLFOCUS ) { if ( !GetVideoModeManager ()->IsWindowed () ) { if ( !CLocalGUI::GetSingleton ().GetMainMenu () || !CLocalGUI::GetSingleton ().GetMainMenu ()->HasStarted () ) return true; // No auto-minimize if ( GetVideoModeManager ()->IsMultiMonitor () && !GetVideoModeManager ()->IsMinimizeEnabled () ) return true; // No auto-minimize } } /* // Should not really ever get here, just in case. else if ( uMsg == WM_SIZE ) { if ( wParam == SIZE_MINIMIZED ) { ShowWindow ( pThis->GetHookedWindowHandle(), SW_RESTORE ); return true; } } */ if ( uMsg == WM_SYSCOMMAND && wParam == 0xF012 ) // SC_DRAGMOVE { CMessageLoopHook::GetSingleton().StartWindowMovement (); return true; } // If we handled mouse steering, don't let GTA. //if ( !CCore::GetSingleton ().GetMouseControl()->ProcessMouseMove ( uMsg, wParam, lParam ) ) // Call GTA's window procedure. return CallWindowProcW ( pThis->m_HookedWindowProc, hwnd, uMsg, wParam, lParam ); } // Don't allow DefWindowProc if processed here. (Important for IME) return true; }
LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LPSUBCLASS_INFO stack; LRESULT ret; TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam); /* retrieve our little stack from the Properties */ stack = GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd); return 0; } /* If we are at the end of stack then we have to call the original * window procedure */ if (!stack->stackpos) { if (IsWindowUnicode (hWnd)) ret = CallWindowProcW (stack->origproc, hWnd, uMsg, wParam, lParam); else ret = CallWindowProcA (stack->origproc, hWnd, uMsg, wParam, lParam); } else { const SUBCLASSPROCS *proc = stack->stackpos; stack->stackpos = stack->stackpos->next; /* call the Subclass procedure from the stack */ ret = proc->subproc (hWnd, uMsg, wParam, lParam, proc->id, proc->ref); } return ret; }