1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
LRESULT CALLBACK uw::WindowBase::s_SubProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
EventStruct evt = {(WindowBase*)GetWindowLongPtr(hwnd, GWLP_USERDATA)};
switch (msg)
{
case WM_DESTROY:
if (evt.WinObj->DoEvent(EVENT_ONDESTROY, &evt))
return 0;
break;
case WM_MOVE:
case WM_MOVING:
GetWindowRect(evt.WinObj->m_Window, &evt.WinObj->m_WindowRect);
GetClientRect(evt.WinObj->m_Window, &evt.WinObj->m_ClientRect);
if (evt.WinObj->DoEvent(EVENT_ONMOVE, &evt))
return 0;
break;
case WM_SIZE:
case WM_SIZING:
GetWindowRect(evt.WinObj->m_Window, &evt.WinObj->m_WindowRect);
GetClientRect(evt.WinObj->m_Window, &evt.WinObj->m_ClientRect);
if (evt.WinObj->DoEvent(EVENT_ONSIZE, &evt))
return 0;
break;
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
evt.MouseEvent.CursorPos.x = GET_X_LPARAM(lparam);
evt.MouseEvent.CursorPos.y = GET_Y_LPARAM(lparam);
if (msg == WM_LBUTTONDOWN)
evt.MouseEvent.Button = VK_LBUTTON;
else if (msg == WM_MBUTTONDOWN)
evt.MouseEvent.Button = VK_MBUTTON;
else if (msg == WM_RBUTTONDOWN)
evt.MouseEvent.Button = VK_RBUTTON;
if (evt.WinObj->DoEvent(EVENT_ONMOUSEPRESS, &evt))
return 0;
break;
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
evt.MouseEvent.CursorPos.x = GET_X_LPARAM(lparam);
evt.MouseEvent.CursorPos.y = GET_Y_LPARAM(lparam);
if (msg == WM_LBUTTONUP)
evt.MouseEvent.Button = VK_LBUTTON;
else if (msg == WM_MBUTTONUP)
evt.MouseEvent.Button = VK_MBUTTON;
else if (msg == WM_RBUTTONUP)
evt.MouseEvent.Button = VK_RBUTTON;
if (evt.WinObj->DoEvent(EVENT_ONMOUSERELEASE, &evt))
return 0;
break;
case WM_MOUSEMOVE:
evt.MouseEvent.CursorPos.x = GET_X_LPARAM(lparam);
evt.MouseEvent.CursorPos.y = GET_Y_LPARAM(lparam);
if (evt.WinObj->DoEvent(EVENT_ONMOUSEMOVE, &evt))
return 0;
break;
case WM_MOUSEWHEEL:
evt.MouseEvent.WheelDelta = GET_WHEEL_DELTA_WPARAM(wparam);
evt.MouseEvent.CursorPos.x = GET_X_LPARAM(lparam);
evt.MouseEvent.CursorPos.y = GET_Y_LPARAM(lparam);
if (evt.WinObj->DoEvent(EVENT_ONMOUSEWHEEL, &evt))
return 0;
break;
case WM_KEYDOWN:
evt.KeyEvent.Key = wparam;
if (evt.WinObj->DoEvent(EVENT_ONKEYPRESS, &evt))
return 0;
break;
case WM_KEYUP:
evt.KeyEvent.Key = wparam;
if (evt.WinObj->DoEvent(EVENT_ONKEYRELEASE, &evt))
return 0;
break;
case WM_CHAR:
evt.KeyEvent.Char = (WCHAR)wparam;
if (evt.WinObj->DoEvent(EVENT_ONKEYCHAR, &evt))
return 0;
break;
case WM_ERASEBKGND:
if (evt.WinObj->DoEvent(EVENT_ONERASE, &evt))
return TRUE;
break;
case WM_PAINT:
if (evt.WinObj->DoEvent(EVENT_ONPAINT, &evt))
return 0;
break;
case WM_SETTEXT:
// (LPWSTR)lparam
break;
}
return evt.WinObj->m_DefProc(hwnd, msg, wparam, lparam);
}
|