internal LRESULT CALLBACK Win32MainWindowCallback(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam) { LRESULT Result = 0; switch (Message) { case WM_DESTROY: { // TODO: handle this as an error - recreate window? GlobalRunning = false; } break; case WM_CLOSE: { // TODO: handle this with a message to the user? GlobalRunning = false; } break; case WM_SETCURSOR: { if (DEBUGGlobalShowCursor) { Result = DefWindowProcA(Window, Message, WParam, LParam); } else { SetCursor(0); } } break; case WM_ACTIVATEAPP: { #if 0 if (WParam) { SetLayeredWindowAttributes(Window, RGB(0, 0, 0), 255, LWA_ALPHA); } else { SetLayeredWindowAttributes(Window, RGB(0, 0, 0), 64, LWA_ALPHA); } #endif } break; case WM_PAINT: { PAINTSTRUCT Paint; HDC DeviceContext = BeginPaint(Window, &Paint); win32_window_dimension Dimension = Win32GetWindowDimension(Window); Win32DisplayBufferInWindow(&GlobalBackbuffer, DeviceContext, Dimension.Width, Dimension.Height); EndPaint(Window, &Paint); } break; case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYDOWN: case WM_KEYUP: { Assert(!"Keyboard input came in through a non-dispatch message!"); } break; default: { // OutputDebugStringA("default\n"); Result = DefWindowProcA(Window, Message, WParam, LParam); } break; } return(Result); }
LRESULT WINAPI ImeWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode ) // ReactOS { PWND pWnd; PIMEUI pimeui; pWnd = ValidateHwnd(hwnd); if (pWnd) { if (!pWnd->fnid) { if (msg != WM_NCCREATE) { if (unicode) return DefWindowProcW(hwnd, msg, wParam, lParam); return DefWindowProcA(hwnd, msg, wParam, lParam); } NtUserSetWindowFNID(hwnd, FNID_IME); pimeui = HeapAlloc( GetProcessHeap(), 0, sizeof(IMEUI) ); SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pimeui); } else { if (pWnd->fnid != FNID_IME) { ERR("Wrong window class for Ime! fnId 0x%x\n",pWnd->fnid); return 0; } pimeui = ((PIMEWND)pWnd)->pimeui; if (pimeui == NULL) { ERR("Window is not set to IME!\n"); return 0; } } } if (msg==WM_CREATE || msg==WM_NCCREATE) return TRUE; if (msg==WM_NCDESTROY) { HeapFree( GetProcessHeap(), 0, pimeui ); SetWindowLongPtrW(hwnd, 0, 0); NtUserSetWindowFNID(hwnd, FNID_DESTROY); } if (unicode) return DefWindowProcW(hwnd, msg, wParam, lParam); return DefWindowProcA(hwnd, msg, wParam, lParam); }
//////////////////////////////////////////////////////////// /// Function called whenever one of our windows receives a message //////////////////////////////////////////////////////////// static LRESULT CALLBACK GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam) { // Associate handle and Window instance when the creation message is received if (Message == WM_CREATE) { // Get instance (it was passed as the last argument of CreateWindow) LONG Instance = (LONG)((CREATESTRUCT *)LParam)->lpCreateParams; // Set as the "user data" parameter of the window SetWindowLongPtr(Handle, GWLP_USERDATA, Instance); } // Forward the event to the appropriate function if (WindowhWnd) { ProcessEvent(Message, WParam, LParam); if (WindowCallback) return CallWindowProc((WNDPROC)(WindowCallback), Handle, Message, WParam, LParam); } // We don't forward the WM_CLOSE message to prevent the OS from automatically destroying the window if (Message == WM_CLOSE) return 0; return HasUnicodeSupport() ? DefWindowProcW(Handle, Message, WParam, LParam) : DefWindowProcA(Handle, Message, WParam, LParam); }
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; /* log system messages, except for painting */ if (message < WM_USER && message != WM_PAINT && message != WM_ERASEBKGND && message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && message != WM_GETICON && message != WM_DEVICECHANGE) { trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); 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, PARENT_SEQ_INDEX, &msg); } defwndproc_counter++; ret = DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
static LRESULT WINAPI child_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter; struct message msg = { 0 }; LRESULT ret; msg.message = message; msg.flags = sent | wparam | lparam; if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; if (hwnd == child1_wnd) msg.id = CHILD1_ID; else if (hwnd == child2_wnd) msg.id = CHILD2_ID; else msg.id = 0; add_message(sequences, PAGER_SEQ_INDEX, &msg); defwndproc_counter++; ret = DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_CLOSE) { mAppRunning = false; } return DefWindowProcA(hWnd, message, wParam, lParam); }
//////////////////////////////////////////////////////////// /// Function called whenever one of our windows receives a message //////////////////////////////////////////////////////////// LRESULT CALLBACK WindowImplWin32::GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam) { // Associate handle and Window instance when the creation message is received if (Message == WM_CREATE) { // Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow) long This = reinterpret_cast<long>(reinterpret_cast<CREATESTRUCT*>(LParam)->lpCreateParams); // Set as the "user data" parameter of the window SetWindowLongPtr(Handle, GWLP_USERDATA, This); } // Get the WindowImpl instance corresponding to the window handle WindowImplWin32* Window = reinterpret_cast<WindowImplWin32*>(GetWindowLongPtr(Handle, GWLP_USERDATA)); // Forward the event to the appropriate function if (Window) { Window->ProcessEvent(Message, WParam, LParam); if (Window->myCallback) return CallWindowProc(reinterpret_cast<WNDPROC>(Window->myCallback), Handle, Message, WParam, LParam); } // We don't forward the WM_CLOSE message to prevent the OS from automatically destroying the window if (Message == WM_CLOSE) return 0; static const bool HasUnicode = HasUnicodeSupport(); return HasUnicode ? DefWindowProcW(Handle, Message, WParam, LParam) : DefWindowProcA(Handle, Message, WParam, LParam); }
static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM lParam1, LPARAM lParam2) { MCIWndInfo* mwi = (MCIWndInfo*)GetWindowLongA(hWnd, 0); if (mwi || wMsg == WM_CREATE) { switch (wMsg) { case WM_CREATE: MCIWND_Create(hWnd, (CREATESTRUCTA*)lParam2); return 0; case WM_DESTROY: MCIWND_Close(mwi); HeapFree(GetProcessHeap(), 0, mwi->lpName); HeapFree(GetProcessHeap(), 0, mwi); break; case WM_PAINT: MCIWND_Paint(mwi, lParam1); break; case WM_COMMAND: return MCIWND_Command(mwi, lParam1, lParam2); case WM_TIMER: MCIWND_Timer(mwi, lParam1, lParam2); return TRUE; } } return DefWindowProcA(hWnd, wMsg, lParam1, lParam2); }
static LRESULT WINAPI parentWindowProcess(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; /* do not log painting messages */ if (message != WM_PAINT && message != WM_ERASEBKGND && message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && message != WM_GETICON && message != WM_DEVICECHANGE) { trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam); msg.message = message; msg.flags = sent|wparam|lparam; if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; add_message(sequences, PARENT_SEQ_INDEX, &msg); } /* dump sent structure data */ if (message == WM_DRAWITEM) g_drawitem = *(DRAWITEMSTRUCT*)lParam; defwndproc_counter++; ret = DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
internal LRESULT CALLBACK MainWindowCallback(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam) { LRESULT Result = 0; switch(Message) { case WM_CLOSE: case WM_DESTROY: { GlobalRunning = false; } break; default: { Result = DefWindowProcA(Window, Message, wParam, lParam); } break; } return Result; }
static LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { if(msg == WM_MOUSEMOVE) results[test_no].mouse_move_called++; return DefWindowProcA( hWnd, msg, wParam, lParam ); }
static LRESULT CALLBACK win32_window_callback(HWND window, UINT message, WPARAM wp, LPARAM lp) { switch (message) { case WM_KEYDOWN: { CORE->key_modifiers = win32_app_key_mods(); if (wp < KEYS_MAX) { CORE->key_states[wp] = 1; CORE->key_deltas[wp] = 1; // printf("key pressed: %d\n", wp); } return 0; } break; case WM_KEYUP: { CORE->key_modifiers = win32_app_key_mods(); if (wp < KEYS_MAX) { CORE->key_states[wp] = 0; CORE->key_deltas[wp] = 1; // printf("key released: %d\n", wp); } return 0; } break; case WM_CLOSE: { PostQuitMessage(0); CORE->running = 0; } break; } return DefWindowProcA(window, message, wp, lp); }
static LRESULT WINAPI test_notify_parent_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_NOTIFY: { NMHDR *hdr = ((LPNMHDR)lParam); switch(hdr->code) { case NM_DBLCLK: g_got_dblclk = TRUE; break; case NM_CLICK: g_got_click = TRUE; break; case NM_RDBLCLK: g_got_rdblclk = TRUE; break; case NM_RCLICK: g_got_rclick = TRUE; break; } /* Return zero to indicate default processing */ return 0; } case WM_CONTEXTMENU: g_got_contextmenu = TRUE; return 0; default: return( DefWindowProcA(hwnd, msg, wParam, lParam)); } return 0; }
static LRESULT CALLBACK OwnerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if(msg == ID_FINDMSGSTRING) { return handle_findmsg((FINDREPLACEA*)lParam); } return DefWindowProcA(hwnd, msg, wParam, lParam); }
static LRESULT CALLBACK main_window_procA (HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { /* Add blank case statements for these to ensure we don't use them * by mistake. */ case DM_GETDEFID: break; case DM_SETDEFID: break; case WM_CREATE: return (OnMainWindowCreate (hwnd, (LPCREATESTRUCTA) lParam) ? 0 : (LRESULT) -1); case WM_COMMAND: if (wParam == IDCANCEL) { g_terminated = TRUE; return 0; } break; } return DefWindowProcA (hwnd, uiMsg, wParam, lParam); }
static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) { static uint8_t data[1024]; UINT r; unsigned i; RAWINPUT *ri = (RAWINPUT*)data; UINT size = sizeof(data); if (msg != WM_INPUT) return DefWindowProcA(wnd, msg, wpar, lpar); /* app is in the background */ if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) goto end; r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, data, &size, sizeof(RAWINPUTHEADER)); if (r == (UINT)-1) { RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", GetLastError()); goto end; } if (ri->header.dwType == RIM_TYPEKEYBOARD) { if (ri->data.keyboard.Message == WM_KEYDOWN) g_keyboard->keys[ri->data.keyboard.VKey] = 1; else if (ri->data.keyboard.Message == WM_KEYUP) g_keyboard->keys[ri->data.keyboard.VKey] = 0; } else if (ri->header.dwType == RIM_TYPEMOUSE) { for (i = 0; i < g_mouse_cnt; ++i) { if (g_mice[i].hnd == ri->header.hDevice) { winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); break; } } } end: DefWindowProcA(wnd, msg, wpar, lpar); return 0; }
LRESULT CALLBACK Win32MainWindowCallback( HWND Window, UINT Message, WPARAM WParam, LPARAM LParam) { LRESULT Result = 0; switch(Message) { case WM_SIZE: { RECT ClientRect; GetClientRect(Window, &ClientRect); int Width = ClientRect.right - ClientRect.left; int Height = ClientRect.bottom - ClientRect.top; Win32ResizeDIBSection(Width, Height); } break; case WM_DESTROY: { Running = false; }break; case WM_CLOSE: { PostQuitMessage(0); Running = false; }break; case WM_ACTIVATEAPP: { OutputDebugStringA(""); }break; case WM_PAINT: { PAINTSTRUCT Paint; HDC DeviceContext = BeginPaint(Window, &Paint); int X = Paint.rcPaint.left; int Y = Paint.rcPaint.top; int Width = Paint.rcPaint.right - Paint.rcPaint.left; int Height = Paint.rcPaint.bottom - Paint.rcPaint.top; RECT ClientRect; GetClientRect(Window, &ClientRect); Win32UpdateWindow(DeviceContext, &ClientRect, X, Y, Width, Height); EndPaint(Window, &Paint); }break; default: { OutputDebugStringA(""); Result = DefWindowProcA(Window, Message, WParam, LParam); }break; } return (Result); }
static LRESULT WINAPI VCP_UI_FileCopyWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg != WM_CREATE) return DefWindowProcA (hwnd, uMsg, wParam, lParam); return 0; }
static LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { if(msg == WM_SYSKEYDOWN) { ok(wParam == VK_MENU, "Got wrong wParam in WM_SYSKEYDOWN (%d instead of %d)\n", wParam, VK_MENU ); } return DefWindowProcA( hWnd, msg, wParam, lParam ); }
static LRESULT CALLBACK MyWindowWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_ACTIVATE: if ( wParam == WA_INACTIVE && bEmbedBrowserObject ) { ShowWindow(hwndHTMLParent, SW_HIDE); UnEmbedBrowserObject(hwndHTMLParent); bEmbedBrowserObject = FALSE; bTooltipShow = FALSE; } break; default: return DefWindowProcA(hwnd, message, wParam, lParam); } return DefWindowProcA(hwnd, message, wParam, lParam); }
void CStaticMemDC::OnPaint() { CPaintDC dc(this); CRect clip; GetWindowRect(&clip); // get rect of the control ScreenToClient(&clip); CMemDC2 memDC(&dc,&clip); DefWindowProcA(WM_PAINT, (WPARAM)memDC->m_hDC, (LPARAM)0); }
LRESULT Window::wndproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { Window* window = reinterpret_cast<Window*>( GetWindowLongPtrA( hWnd, GWLP_USERDATA ) ); if( window ) { return window->msgproc( hWnd, msg, wParam, lParam ); } return DefWindowProcA( hWnd, msg, wParam, lParam ); }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_DESTROY) { trace("destroying hwnd %p\n", hWnd); PostQuitMessage(0); return 0; } return DefWindowProcA( hWnd, msg, wParam, lParam ); }
LRESULT CALLBACK StaticHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_NCHITTEST: return HTCLIENT; } WNDPROC pOldProc=(WNDPROC)GetPropA(hwnd,"OriginalStaticProc"); if (pOldProc) CallWindowProcA(pOldProc,hwnd,uMsg,wParam,lParam); return DefWindowProcA(hwnd,uMsg,wParam,lParam); }
LRESULT CTargetWnd::WindowProc(UINT msg,WPARAM wParam,LPARAM lParam) { #ifdef _DEBUG void DebugCommandsProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam); DebugCommandsProc(*this,msg,wParam,lParam); #endif if (IsUnicodeSystem()) return DefWindowProcW(m_hWnd,msg,wParam,lParam); else return DefWindowProcA(m_hWnd,msg,wParam,lParam); }
LRESULT CALLBACK ContainerWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: return 0; } ContainerNode *pNode=(ContainerNode *)GetPropA(hwnd,"ContainerNode"); LRESULT retval=0; if (pNode && pNode->OnMessage(hwnd,uMsg,wParam,lParam,&retval)) return retval; return DefWindowProcA(hwnd,uMsg,wParam,lParam); }
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; /* log system messages, except for painting */ if (message < WM_USER && message != WM_PAINT && message != WM_ERASEBKGND && message != WM_NCPAINT && message != WM_NCHITTEST && message != WM_GETTEXT && message != WM_GETICON && message != WM_DEVICECHANGE) { msg.message = message; msg.flags = sent|wparam|lparam|parent; if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code; add_message(sequences, PAGER_SEQ_INDEX, &msg); } if (message == WM_NOTIFY) { NMHDR *nmhdr = (NMHDR *)lParam; switch (nmhdr->code) { case PGN_CALCSIZE: { NMPGCALCSIZE *nmpgcs = (NMPGCALCSIZE *)lParam; DWORD style = GetWindowLongA(nmpgcs->hdr.hwndFrom, GWL_STYLE); if (style & PGS_HORZ) ok(nmpgcs->dwFlag == PGF_CALCWIDTH, "Unexpected flags %#x.\n", nmpgcs->dwFlag); else ok(nmpgcs->dwFlag == PGF_CALCHEIGHT, "Unexpected flags %#x.\n", nmpgcs->dwFlag); break; } default: ; } } defwndproc_counter++; ret = DefWindowProcA(hwnd, message, wParam, lParam); defwndproc_counter--; return ret; }
static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_NOTIFY && lParam) { NMTTDISPINFOA *ttnmdi = (NMTTDISPINFOA*)lParam; if (ttnmdi->hdr.code == TTN_GETDISPINFOA) lstrcpyA(ttnmdi->lpszText, testcallbackA); } return DefWindowProcA(hwnd, message, wParam, lParam); }
static LRESULT WINAPI wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_IME_SETCONTEXT: case WM_NCCREATE: case WM_CREATE: return TRUE; } return DefWindowProcA(hwnd,msg,wParam,lParam); }
static LRESULT CALLBACK info_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProcA(hWnd, msg, wParam, lParam); } return 0; }