예제 #1
0
void dGLWDocker::OnSize(int width, int height)
{
	dGLWWidget::OnSize(width, height);

	dGLWMenuBar* menu = NULL;
	for (dList<dGLWWidget*>::dListNode* node = m_children.GetFirst(); node; node = node->GetNext()) {
		dGLWWidget* const widget = node->GetInfo();
		if (widget->IsType(dGLWMenuBar::GetRttiType())) {
			menu = (dGLWMenuBar*) widget;
		}
	}

	OnPosition(m_rect.m_x, m_rect.m_y);
	if (menu) {
		dGLWRect rect (menu->GetRect());
		m_client.m_y += rect.m_height;
		m_client.m_height -= rect.m_height;
	}
}
LRESULT D3D11App::ProcessMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;

	switch (message)
	{
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
            EndPaint(hwnd, &ps);
            break;
		case WM_MOUSEMOVE:
			OnMouseMove(hwnd, GETX(lParam), GETY(lParam), (wParam & MK_LBUTTON) != 0, (wParam & MK_MBUTTON) != 0, (wParam & MK_RBUTTON) != 0);
			break;
		case WM_KEYDOWN:
			if (wParam == VK_ESCAPE)
			{
				if (m_mouseCapture)
				{
					// Release mouse capture on escape if there is one ...
					CaptureMouse(false);
				}
				else
				{
					// ... otherwise exit the application
					PostMessage(hwnd, WM_CLOSE, 0, 0);
				}
			}
			else
			{
				OnKeyPress(hwnd, (unsigned int) wParam, true);
			}
			break;
		case WM_KEYUP:
			OnKeyPress(hwnd, (unsigned int) wParam, false);
			break;
		case WM_SYSKEYDOWN:
			// Toggle fullscreen on Alt-Enter
			if ((lParam & (1 << 29)) && wParam == VK_RETURN)
			{
				m_context->ToggleFullscreen();
			}
			break;
		case WM_LBUTTONDOWN:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_LEFT, true);
			break;
		case WM_LBUTTONUP:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_LEFT, false);
			break;
		case WM_RBUTTONDOWN:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_RIGHT, true);
			break;
		case WM_RBUTTONUP:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_RIGHT, false);
			break;
		case WM_MBUTTONDOWN:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_MIDDLE, true);
			break;
		case WM_MBUTTONUP:
			OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_MIDDLE, false);
			break;
		case WM_WINDOWPOSCHANGED:
			WINDOWPOS *p;
			p = (WINDOWPOS *) lParam;

			// Ignore events with SWP_NOSENDCHANGING flag
			if (p->flags & SWP_NOSENDCHANGING) break;

			if ((p->flags & SWP_NOMOVE) == 0)
			{
				OnPosition(hwnd, p->x, p->y);
			}
			if ((p->flags & SWP_NOSIZE) == 0)
			{
				RECT rect;
				GetClientRect(hwnd, &rect);
				OnSize(hwnd, rect.right - rect.left, rect.bottom - rect.top);
			}
			break;
		case WM_CREATE:
			ShowWindow(hwnd, SW_SHOW);
			break;
		case WM_CLOSE:
			DestroyWindow(hwnd);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}