Exemple #1
0
static LRESULT CALLBACK scrnProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch (Msg) {
        HANDLE_MSG(hWnd, WM_CREATE,			onCreate);
        HANDLE_MSG(hWnd, WM_ACTIVATEAPP,	onActivateApp);
        HANDLE_MSGB(hWnd,WM_PAINT,			onPaint);
        HANDLE_MSG(hWnd, WM_CLOSE,			onClose);
        HANDLE_MSG(hWnd, WM_DESTROY,		onDestroy);
        HANDLE_MSG(hWnd, WM_COMMAND,		onCommand);

    // We can't use the macro from windowsx.h macro for this one
    case WM_SYSCOMMAND: {
        if (onSysCommand(hWnd,(UINT)wParam,(int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam))) {
            return 0;
        }
        break;
    }

    HANDLE_MSG(hWnd, WM_SIZE,			onSize);
    HANDLE_MSG(hWnd, WM_ENTERSIZEMOVE,	onEnterSizeMove);
    HANDLE_MSG(hWnd, WM_EXITSIZEMOVE,	onExitSizeMove);

    HANDLE_MSGB(hWnd, WM_SIZING,		onSizing);		// set screen visible size, added by regret
    HANDLE_MSGB(hWnd, WM_DROPFILES,		onDropFiles);	// drag & drop support, added by regret

    HANDLE_MSG(hWnd, WM_ENTERIDLE,		onEnterIdle);
    HANDLE_MSG(hWnd, WM_MOUSEMOVE,		onMouseMove);
    HANDLE_MSG(hWnd, WM_LBUTTONUP,		onLButtonUp);
    HANDLE_MSG(hWnd, WM_LBUTTONDOWN,	onLButtonDown);
    HANDLE_MSG(hWnd, WM_LBUTTONDBLCLK,	onLButtonDblClk);
//		HANDLE_MSG(hWnd, WM_RBUTTONUP,		onRButtonUp);
    HANDLE_MSG(hWnd, WM_RBUTTONDBLCLK,	onRButtonDown);
    HANDLE_MSG(hWnd, WM_RBUTTONDOWN,	onRButtonDown);

    HANDLE_MSG(hWnd, WM_ENTERMENULOOP,	onEnterMenuLoop);
    HANDLE_MSGB(hWnd,WM_EXITMENULOOP,	onExitMenuLoop);

    HANDLE_MSG(hWnd, WM_DISPLAYCHANGE,	onDisplayChange);
    }

    return DefWindowProc(hWnd, Msg, wParam, lParam);
}
Exemple #2
0
bool BaseWindow::wndProc(UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message) {
    case WM_COMMAND:
      return onCommand(wParam, lParam);
    case WM_NOTIFY:
      return onNotify((int)wParam, (LPNMHDR)lParam);
    case WM_SYSCOMMAND:
      return onSysCommand(wParam, lParam);
    case WM_LBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_MBUTTONDOWN:
    case WM_MBUTTONUP:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
    case WM_MOUSEWHEEL:
    case WM_MOUSEMOVE:
    {
      unsigned char mouseButtons = 0;

      mouseButtons |= LOWORD(wParam) & MK_RBUTTON ? MOUSE_RDOWN : 0;
      mouseButtons |= LOWORD(wParam) & MK_MBUTTON ? MOUSE_MDOWN : 0;
      mouseButtons |= LOWORD(wParam) & MK_LBUTTON ? MOUSE_LDOWN : 0;

      // Translate position from LPARAM to POINT.
      POINTS points = MAKEPOINTS(lParam);
      POINT point;
      point.x = points.x;
      point.y = points.y;

      unsigned short wheelSpeed = 0; 
      if (message == WM_MOUSEWHEEL) {
        // Get speed wheel and set mouse button.
        signed short wheelSignedSpeed = static_cast<signed short>(HIWORD(wParam));
        if (wheelSignedSpeed < 0) {
          mouseButtons |= MOUSE_WDOWN;
          wheelSpeed = - wheelSignedSpeed / WHEEL_DELTA;
        } else {
          mouseButtons |= MOUSE_WUP;
          wheelSpeed = wheelSignedSpeed / WHEEL_DELTA;
        }

        // In some cases wheelSignedSpeed can be smaller than the WHEEL_DELTA,
        // then wheelSpeed set to 1, but not 0.
        if (wheelSpeed == 0) {
          wheelSpeed = 1;
        }

        // If windows-message is WHEEL, then need to translate screen coordinate to client.
        if (!ScreenToClient(getHWnd(), &point)) {
          point.x = -1;
          point.y = -1;
        }
      }

      // Notify window about mouse-event.
      return onMouse(mouseButtons, static_cast<unsigned short>(wheelSpeed), point);
    }
  }
  return onMessage(message, wParam, lParam);
}
Exemple #3
0
static LRESULT CALLBACK traceproc(HWND hWnd, UINT uMsg,
												WPARAM wParam, LPARAM lParam)
{
	RECT	rc;

	switch(uMsg)
	{
		case WM_CREATE:
			return onCreate(hWnd);

		case WM_SYSCOMMAND:
			return onSysCommand(hWnd, wParam, lParam);

		case WM_MOVE:
			if (!(GetWindowLong(hWnd, GWL_STYLE) &
											(WS_MAXIMIZE | WS_MINIMIZE)))
			{
				GetWindowRect(hWnd, &rc);
				tracecfg.posx = rc.left;
				tracecfg.posy = rc.top;
			}
			break;

		case WM_SIZE:							// window resize
			if (!(GetWindowLong(hWnd, GWL_STYLE) &
										(WS_MAXIMIZE | WS_MINIMIZE)))
			{
				GetWindowRect(hWnd, &rc);
				tracecfg.width = rc.right - rc.left;
				tracecfg.height = rc.bottom - rc.top;
			}
			MoveWindow(s_hView, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
			View_ScrollToBottom(s_hView);
			break;

		case WM_SETFOCUS:
			SetFocus(s_hView);
			return(0L);

		case WM_CTLCOLORSTATIC:
		case WM_CTLCOLOREDIT:
			SetTextColor((HDC)wParam, VIEW_FGCOLOR);
			SetBkColor((HDC)wParam, VIEW_BGCOLOR);
			return((LRESULT)s_hBrush);

		case WM_CLOSE:
			break;

		case WM_DESTROY:
			if (s_hBrush)
			{
				DeleteObject(s_hBrush);
			}
			if (s_hfView)
			{
				DeleteObject(s_hfView);
			}
			break;
#if 0
		case WM_ENTERSIZEMOVE:
			winloc_movingstart();
			break;

		case WM_MOVING:
			winloc_movingproc((RECT *)lParam);
			break;

		case WM_ERASEBKGND:
			return FALSE;
#endif
		default:
			return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
	return FALSE;
}