void OverlayControl::MouseDown(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
	if (!ActiveOverlay)
		return;

	//	Left or right button clicked -- select the element under cursor.
	RECT clipRect, clientRect;
	GetWindowRect(hwnd, &clipRect);
	GetClientRect(hwnd, &clientRect);

	//	Save original mouse position.
	GetCursorPosition(hwnd, &clickAnchor);

	//	Element could be activated only if no element active AND user doesn't click 
	//	within the active element.
	if (!ActiveOverlay->ActiveElement || 
		!ActiveOverlay->HitTestElement(ActiveOverlay->ActiveElement, &clientRect, &clickAnchor, &hitTestAnchor))
	{
		//	Find overlay element under cursor.
		OverlayElement *element = ActiveOverlay->FindElementFromPoint(&clientRect, &clickAnchor, &hitTestAnchor);
		ActivateElement(hwnd, element);
	}

	if (!ActiveOverlay->ActiveElement)
	{
		ResetCursor();
	}

	if (0 != (wParam & MK_LBUTTON))
	{
		if (ActiveOverlay->ActiveElement)
		{
			ActiveOverlay->ActiveElement->GetRect(&clientRect, &elementRectAnchor);

			//	Show that we're about to drag the object.
			UpdateCursor(hitTestAnchor);

			//	Capture the mouse.
			SetCapture(hwnd);
			ClipCursor(&clipRect);
		}

		return;
	}

	if (0 != (wParam & MK_RBUTTON))
	{
		//	Show popup menu.
		POINT pt;
		GetCursorPos(&pt);

		__raise RightMouseButtonClicked(ActiveOverlay->ActiveElement, &pt);

		return;
	}
}
Example #2
0
void CRemoteWnd::TrackScaler()
{
	MSG* pMsg = &AfxGetThreadState()->m_msgCur;
	CRect rcTrack( &m_rcsScalerTrack );
	CPoint point;

	ClientToScreen( &rcTrack );
	ClipCursor( &rcTrack );
	ScreenToClient( &rcTrack );
	SetCapture();

	rcTrack.DeflateRect( m_rcScalerTab.Width() / 2, 0 );

	while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
	{
		while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) );

		if ( ! AfxGetThread()->PumpMessage() )
		{
			AfxPostQuitMessage( 0 );
			break;
		}

		GetCursorPos( &point );
		ScreenToClient( &point );

		int nPosition = (int)( 105.0f * (float)( point.x - rcTrack.left ) / (float)rcTrack.Width() );
		if ( nPosition < 0 ) nPosition = 0;
		else if ( nPosition >= 102 ) nPosition = 101;
		else if ( nPosition >= 100 ) nPosition = 100;

		// ToDo: Settings.Live.BandwidthScaleOut
		if ( nPosition != (int)Settings.Live.BandwidthScaleIn )
		{
			Settings.Live.BandwidthScaleIn = (DWORD)nPosition;
			Invalidate();
		}
	}

	ReleaseCapture();
	ClipCursor( NULL );
	Invalidate();
}
Example #3
0
void	Window::LockMouseToWindow(bool lock)	{
	lockMouse = lock;
	if(lock) {
		RECT		windowRect;
		GetWindowRect (window->windowHandle, &windowRect);

		SetCapture(window->windowHandle);
		ClipCursor(&windowRect);

		POINT pt;
		GetCursorPos(&pt);
		ScreenToClient(window->windowHandle, &pt);
		Window::GetMouse()->SetAbsolutePosition(pt.x,pt.y);
	}
	else{
		ReleaseCapture();
		ClipCursor(NULL);
	}
}
Example #4
0
BOOL WINAPI _ClipCursor(const RECT *lpRect)
{
  if ( !wmode )
  {
    if ( _ClipCursorOld )
      return _ClipCursorOld(lpRect);
    return ClipCursor(lpRect);
  }
  return TRUE;
}
void OverlayControl::MouseUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
	if (!ActiveOverlay)
		return;

	//	Release mouse.
	ClipCursor(0);
	ReleaseCapture();
	ResetCursor();
}
Example #6
0
void
WIN_UpdateClipCursor(SDL_Window *window)
{
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    SDL_Mouse *mouse = SDL_GetMouse();
    RECT rect;

    if (data->focus_click_pending) {
        return;
    }

    if ((mouse->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
        (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
        if (mouse->relative_mode && !mouse->relative_mode_warp) {
            LONG cx, cy;
            GetWindowRect(data->hwnd, &rect);

            cx = (rect.left + rect.right) / 2;
            cy = (rect.top + rect.bottom) / 2;

            /* Make an absurdly small clip rect */
            rect.left = cx - 1;
            rect.right = cx + 1;
            rect.top = cy - 1;
            rect.bottom = cy + 1;

            if (ClipCursor(&rect)) {
                data->cursor_clipped_rect = rect;
            }
        } else {
            if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
                ClientToScreen(data->hwnd, (LPPOINT) & rect);
                ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
                if (ClipCursor(&rect)) {
                    data->cursor_clipped_rect = rect;
                }
            }
        }
    } else if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
        ClipCursor(NULL);
        SDL_zero(data->cursor_clipped_rect);
    }
}
Example #7
0
void MouseSetRect(int x1, int y1, int x2, int y2)
{
	#if 0
	TRect r;
	
	r.x1 = x1, r.y1 = y1, r.x2 = x2, r.y2 = y2;
	ClipCursor(&r); /// FIXME -- SDL cannot clip mouse cursor, do it ourselves!
SDL_WM_GrabInput(SDL_GRAB_ON);
	#endif
}
Example #8
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CLTWnd::OnLButtonUp
//
//	PURPOSE:	This is the actual left button up handler
//
// ----------------------------------------------------------------------- //
BOOL CLTWnd::OnLButtonUp(int xPos, int yPos)
{
	// Stop any draggage
	//if(s_pWndDrag)
	g_mouseMgr.SetClipRect(NULL);
	ClipCursor(g_prcClip);
	//s_pWndDrag = NULL;
	s_pWndCapture = NULL;
	return(this != s_pMainWnd);
}
void WindowsMouseController::grab()
{
    RECT clipRegion;
    GetWindowRect( mWindowHandle, &clipRegion );
    clipRegion.left += 10;
    clipRegion.right -= 10;
    clipRegion.top += 33;
    clipRegion.bottom -= 10;
    ClipCursor( &clipRegion );
}
Example #10
0
void Window::lockMouse()
{
	RECT clientRect;
	GetClientRect(m_hWnd,&clientRect);
	POINT p1 = {clientRect.left,clientRect.top};
	POINT p2 = {clientRect.right,clientRect.bottom};
	ClientToScreen(m_hWnd,&p1); ClientToScreen(m_hWnd,&p2);
	RECT bounds={p1.x,p1.y,p2.x,p2.y};
	ClipCursor(&bounds);
}
Example #11
0
/*
   Effect:        Handle any actions relating to the user pressing *down*
                  the left mouse button within the widget.

                  In particular, we need to prepare the widget for moving
                  || sizing. To do this, we remove any drag blobs already
                  present on the widget.

                  We also capture the mouse input, so we can track the
                  movement of the mouse. We will release the capture
                  when the user releases the mouse key.

                  Since the window class style of the widget might not
                  accept double clicks, we will need to compute double
                  clicks ourselves.

                  If someone else has control of the mouse (like the
                  session window || another widget), we won't be getting
                  this mouse message.

   See Also:      WidgetLButtonUp, WidgetLMouseMove.

   Called By:     WidgetWndProc, in response to WM_LBUTTONDOWN messages.
                  LayoutWndProc, in response to WM_LBUTTONDOWN messages
                  when the mouse is over a drag blob.
*/
void WidgetLButtonDown(HWND hWnd, int nDragMode, POINT ptScreen)
{
    RECT rcParentScreen;
    HWND hWndParent, hWndPrev;
    HDC hDC;

    CurrentWidgetInfo.ptPrev = ptScreen;

    hWndParent = GetParent(hWnd);
    CurrentWidgetInfo.nDragMode = nDragMode;
    hDC = GetDC(hWndParent);

    /* Erase the drag blobs from the current widget. The blobs will */
    /* be repainted in WidgetButtonUp after the user finishes dragging */
    /* || sizing. */

    GetWindowRect(hWnd, &CurrentWidgetInfo.rcPrevDots);
    GetWindowRect(hWnd, &CurrentWidgetInfo.rcPrev);

    hWndPrev = CurrentWidgetInfo.hWnd;
    CurrentWidgetInfo.bDotsDrawn = FALSE;

    CurrentWidgetInfo.bDotsDrawn = TRUE;

    if (hWnd != CurrentWidgetInfo.hWnd)
    {
        if (KpsSetCurrentWidget(hWnd))
        {
            if (IsWindow(hWndPrev))
            {
                if (KpsIsAWidget(hWndPrev))
                {
                    InvalidateRect(hWndPrev, NULL, TRUE);
                    UpdateWindow(hWndPrev);
                }
            }
        }
        InvalidateRect(hWnd, NULL, TRUE);
        UpdateWindow(hWnd);
    }

    if (!CurrentWidgetInfo.bCapture)
    {
        SetCapture(hWnd);
        GetClientRect(hWndParent, &rcParentScreen);
        KpsClientRectToScreen(hWndParent, &rcParentScreen);
        ClipCursor(&rcParentScreen);
        CurrentWidgetInfo.bCapture = TRUE;
    }

    ReleaseDC(hWndParent, hDC);

    /* Clear out the rectangle, indicating there is nothing to erase! */
    SetRectEmpty(&rcPrev);
}
Example #12
0
/*
================
IN_DeactivateWin32Mouse
================
*/
void IN_DeactivateWin32Mouse(void)
{
	// NERVE - SMF - dont do this in developer mode
	if(!com_developer->integer)
	{
		ClipCursor(NULL);
	}
	ReleaseCapture();
	while(ShowCursor(TRUE) < 0)
		;
}
Example #13
0
void PixelLightCtrl::SetTrapMouse(bool bTrap)
{
	if (m_hFrontendWnd) {
		// Trap mouse?
		if (bTrap) {
			// Get window rect (in screen coordinates)
			RECT sRect;
			GetWindowRect(&sRect);

			// Trap mouse
			ClipCursor(&sRect); 
		} else {
			// Untrap mouse
			ClipCursor(nullptr);
		}

		// Backup the state
		m_bTrapMouse = bTrap;
	}
}
Example #14
0
// Called when the window loses focus
static void Win_DeAcquireMouse( void ) {
    if( win.mouse.restoreparms )
        SystemParametersInfo( SPI_SETMOUSE, 0, win.mouse.originalparms, 0 );

    SetCursorPos( win.center_x, win.center_y );

    ClipCursor( NULL );
    ReleaseCapture();

    SetWindowText( win.wnd, PRODUCT );
}
Example #15
0
void
WIN_UpdateClipCursor(SDL_Window *window)
{
    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    SDL_Mouse *mouse = SDL_GetMouse();

    /* Don't clip the cursor while we're in the modal resize or move loop */
    if (data->in_title_click || data->in_modal_loop) {
        ClipCursor(NULL);
        return;
    }

    if ((mouse->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
        (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
        if (mouse->relative_mode && !mouse->relative_mode_warp) {
            LONG cx, cy;
            RECT rect;
            GetWindowRect(data->hwnd, &rect);

            cx = (rect.left + rect.right) / 2;
            cy = (rect.top + rect.bottom) / 2;

            /* Make an absurdly small clip rect */
            rect.left = cx - 1;
            rect.right = cx + 1;
            rect.top = cy - 1;
            rect.bottom = cy + 1;

            ClipCursor(&rect);
        } else {
            RECT rect;
            if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
                ClientToScreen(data->hwnd, (LPPOINT) & rect);
                ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
                ClipCursor(&rect);
            }
        }
    } else {
        ClipCursor(NULL);
    }
}
// Hide the mouse cursor
//
static void hideCursor(_GLFWwindow* window)
{
    POINT pos;

    ClipCursor(NULL);

    if (GetCursorPos(&pos))
    {
        if (WindowFromPoint(pos) == window->win32.handle)
            SetCursor(NULL);
    }
}
Example #17
0
void RestrictMouseMovementTo( int left , int top , int right , int bottom ){
	
	RECT r;

	r.left = left;
	r.top = top;
	r.right = right;
	r.bottom = bottom;

	ClipCursor( &r );

}
Example #18
0
void r3dMouse::SetRange(int x1, int y1, int x2, int y2)
{
	RECT	rc;

	// Clip Cursor
	rc.left   = x1;
	rc.top    = y1;
	rc.right  = x2;
	rc.bottom = y2;
	ClipCursor(&rc);
	SetCursorPos(0, 0);
}
Example #19
0
// Called when the window gains focus or changes in some way
static void Win_ClipCursor( void ) {
    RECT rc;

    get_client_rect( win.wnd, &rc );

    win.center_x = ( rc.right + rc.left ) / 2;
    win.center_y = ( rc.top + rc.bottom ) / 2;

    SetCursorPos( win.center_x, win.center_y );

    ClipCursor( &rc );
}
Example #20
0
GameWindow::GameWindow(const string name_t,const string title_t,int width,int height):name(name_t),title(title_t),WIDTH(width),HEIGHT(height)
{
	//1.创建窗口类
	WNDCLASSEX wndClass = {};
	wndClass.cbSize = sizeof(WNDCLASSEX);
	wndClass.style = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc = WndProc;
	wndClass.cbClsExtra = 0;
	wndClass.cbWndExtra = 0;
	wndClass.hInstance = GetModuleHandle(NULL);
	wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wndClass.lpszMenuName = NULL;
	wndClass.lpszClassName = name.c_str();

	//2.注册窗口类
	assert(RegisterClassEx(&wndClass));

	//3.创建窗口
	hwnd = CreateWindow(name.c_str(),title.c_str(),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,WIDTH,HEIGHT,NULL,NULL,wndClass.hInstance,NULL);

	//4.调整大小,移动,显示,更新
	RECT window_rect = {0,0,WIDTH,HEIGHT};
	AdjustWindowRectEx(&window_rect, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd));
	MoveWindow(hwnd,300,150,window_rect.right-window_rect.left, window_rect.bottom-window_rect.top,false);
	ShowWindow(hwnd,SW_NORMAL);
	UpdateWindow(hwnd);

	//5.隐藏鼠标,设为屏幕中心
	ShowCursor(false);
	center.x = WIDTH/2;
	center.y = HEIGHT/2;
	ClientToScreen(hwnd,&center);
	SetCursorPos(center.x,center.y);
	//6.限定鼠标在窗口内
	RECT rect;
	GetClientRect(hwnd,&rect);
	POINT left_top;
	left_top.x = rect.left;
	left_top.y = rect.top;
	POINT right_bottom;
	right_bottom.x = rect.right;
	right_bottom.y = rect.bottom;
	ClientToScreen(hwnd,&left_top);
	ClientToScreen(hwnd,&right_bottom);
	rect.left = left_top.x;
	rect.top = left_top.y;
	rect.right = right_bottom.x;
	rect.bottom = right_bottom.y;
	ClipCursor(&rect);
}
Example #21
0
void unclip()
{
int a;

RECT _screen;

_screen.left = 0;
_screen.top = 0;
_screen.right = GetSystemMetrics(SM_CXSCREEN);
_screen.bottom = GetSystemMetrics(SM_CYSCREEN);

ClipCursor(&_screen);
}
Example #22
0
/**
 * Called from VIDC code when the RISC OS mode has changed.
 * Update windows size to hold it.
 *
 * @param x X size in pixels
 * @param y Y size in pixels
 */
void updatewindowsize(uint32_t x, uint32_t y)
{
	RECT r;

	GetWindowRect(ghwnd, &r);
	MoveWindow(ghwnd, r.left, r.top,
	           x + (GetSystemMetrics(SM_CXFIXEDFRAME) * 2),
	           y + (GetSystemMetrics(SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION),
	           TRUE);
        if (mousecapture)
        {
                RECT arcclip;

                ClipCursor(&oldclip);
                GetWindowRect(ghwnd,&arcclip);
                arcclip.left+=GetSystemMetrics(SM_CXFIXEDFRAME)+10;
                arcclip.right-=GetSystemMetrics(SM_CXFIXEDFRAME)+10;
                arcclip.top+=GetSystemMetrics(SM_CXFIXEDFRAME)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+10;
                arcclip.bottom-=GetSystemMetrics(SM_CXFIXEDFRAME)+10;
                ClipCursor(&arcclip);
        }
}
Example #23
0
	void CorrectCursor() {
		bool autoHide = ((g_Config.bFullScreen && !mouseButtonDown) || (g_Config.bMouseControl && trapMouse)) && GetUIState() == UISTATE_INGAME;
		if (autoHide && (hideCursor || g_Config.bMouseControl)) {
			while (cursorCounter >= 0) {
				cursorCounter = ShowCursor(FALSE);
			}
			if (g_Config.bMouseConfine) {
				RECT rc;
				GetClientRect(hwndDisplay, &rc);
				ClientToScreen(hwndDisplay, reinterpret_cast<POINT*>(&rc.left));
				ClientToScreen(hwndDisplay, reinterpret_cast<POINT*>(&rc.right));
				ClipCursor(&rc);
			}
		} else {
			hideCursor = !autoHide;
			if (cursorCounter < 0) {
				cursorCounter = ShowCursor(TRUE);
				SetCursor(LoadCursor(NULL, IDC_ARROW));
				ClipCursor(NULL);
			}
		}
	}
Example #24
0
void CDriverD3D::setCapture (bool b)
{
	if (b)
	{
		RECT client;
		GetClientRect (_HWnd, &client);
		POINT pt1,pt2;
		pt1.x = client.left;
		pt1.y = client.top;
		ClientToScreen (_HWnd, &pt1);
		pt2.x = client.right;
		pt2.y = client.bottom;
		ClientToScreen (_HWnd, &pt2);
		client.bottom = pt2.y;
		client.top = pt1.y;
		client.left = pt1.x;
		client.right = pt2.x;
		ClipCursor (&client);
	}
	else
		ClipCursor (NULL);
}
Example #25
0
/*
 * Class:     sage_UIManager
 * Method:    setCursorClip
 * Signature: (Ljava/awt/Rectangle;)V
 */
JNIEXPORT void JNICALL Java_sage_UIManager_setCursorClip(
	JNIEnv *env, jclass jc, jobject inRect)
{
	RECT myClip;
	static jclass rectClass = (jclass) env->NewGlobalRef(env->FindClass("java/awt/Rectangle"));
	static jfieldID rectX = env->GetFieldID(rectClass, "x", "I");
	static jfieldID rectY = env->GetFieldID(rectClass, "y", "I");
	static jfieldID rectW = env->GetFieldID(rectClass, "width", "I");
	static jfieldID rectH = env->GetFieldID(rectClass, "height", "I");
	if (inRect)
	{
		LONG width = (LONG) env->GetIntField(inRect, rectW);
		LONG height = (LONG) env->GetIntField(inRect, rectH);
		myClip.left = (LONG) env->GetIntField(inRect, rectX);
		myClip.top = (LONG) env->GetIntField(inRect, rectY);
		myClip.right = myClip.left + width;
		myClip.bottom = myClip.top + height;
		ClipCursor(&myClip);
	}
	else
		ClipCursor(NULL);
}
Example #26
0
void game::Init(void)
{
  if(g_isConsoleUpdater)
  {
    cmdLine_Init();
    return;
  }
  
  //@gHwInfoPoster.Start(); -- DISABLED FOR NOW

  // set small icon
  ::SendMessage(win::hWnd, WM_SETICON, FALSE, (LPARAM)::LoadIcon(win::hInstance, MAKEINTRESOURCE(IDI_WARINC)));
  
  // make borderless window and subclass wndProc
  r3dWinStyleModify(win::hWnd, 0, WS_BORDER);
  r3dWinStyleModify(win::hWnd, 0, WS_CAPTION);
  SetWindowLong(win::hWnd, GWL_WNDPROC, (DWORD)&updApp_WndFunc);

  // ok, now r3drendered started using vars inside itself...
  RegisterAllVars();

  const int Width  = 785;
  const int Height = 650;

  HDC disp_dc  = CreateIC("DISPLAY", NULL, NULL, NULL);
  int curDispWidth  = GetDeviceCaps(disp_dc, HORZRES);
  int curDispHeight = GetDeviceCaps(disp_dc, VERTRES);
  int StartXPos = (curDispWidth - Width) / 2;
  int StartYPos = (curDispHeight - Height) / 2;
  SetWindowPos(win::hWnd, NULL, StartXPos, StartYPos, (int)Width, (int)Height, 0);

  r3dRenderer = new r3dRenderLayer;
  r3dRenderer->Init(win::hWnd, NULL);
  
  fake_SetMode(Width, Height);
  
  char title[512];
  sprintf(title, "Infestation Thailand Updater %s (%s)", UPDATER_VERSION, UPDATER_BUILD);
  if(!UPDATER_UPDATER_ENABLED) strcat(title, "!!!!SELF_UPDATE_DISABLED!!!");
  ::SetWindowText(win::hWnd, title);

  CreateResources();
  
  ShowWindow(win::hWnd, SW_SHOW);
  
  ClipCursor(NULL);
  
  // release dinput classes becase we won't be using them
  Keyboard->ReleaseCapture();
  Mouse->ReleaseCapture();
}
Example #27
0
/*
===========
IN_ActivateMouse

Called when the window gains focus or changes in some way
===========
*/
void IN_ActivateMouse (void)
{
	int		width, height;

	if (!mouseinitialized)
		return;
	if (!in_mouse->value)
	{
		mouseactive = false;
		return;
	}
	if (mouseactive)
		return;

	mouseactive = true;

	if (mouseparmsvalid)
		restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);

	width = GetSystemMetrics (SM_CXSCREEN);
	height = GetSystemMetrics (SM_CYSCREEN);

	GetWindowRect ( cl_hwnd, &window_rect);

	/*
	** The following clamping code doesn't work on multi-monitor setups.
	** Hence it has been commented out.
	*/

	/*if (window_rect.left < 0)
		window_rect.left = 0;
	if (window_rect.top < 0)
		window_rect.top = 0;
	if (window_rect.right >= width)
		window_rect.right = width-1;
	if (window_rect.bottom >= height-1)
		window_rect.bottom = height-1;*/

	window_center_x = (window_rect.right + window_rect.left)/2;
	window_center_y = (window_rect.top + window_rect.bottom)/2;

	SetCursorPos (window_center_x, window_center_y);

	old_x = window_center_x;
	old_y = window_center_y;

	SetCapture ( cl_hwnd );
	ClipCursor (&window_rect);
	while (ShowCursor (FALSE) >= 0)
		;
}
void CShowGrafView::mouseMoveMarkInterval(UINT nFlags, const CPoint &point) {
  if(m_dragging) {
    if(nFlags && MK_LBUTTON) {
      const CRect cr      = getClientRect(this, IDC_SYSTEMPANEL);
      const CRect newRect = CRect(m_mouseDownPoint.x, cr.bottom, point.x, cr.top);
      CClientDC(GetDlgItem(IDC_SYSTEMPANEL)).DrawDragRect(&newRect, CSize(1,1), &m_dragRect, CSize(1,1));
      m_dragRect = newRect;
    } else {
      CClientDC(GetDlgItem(IDC_SYSTEMPANEL)).DrawDragRect(&m_dragRect, CSize(1,1), NULL, CSize(1,1));
      m_dragging = false;
      ClipCursor(NULL);
    }
  }
}
Example #29
0
void WindowsMouse::GetMouseCapture(HWND hWnd)
{
    SetCapture(hWnd);
    ShowCursor(0);

    GetCursorPos(&origCursorPos);

    RECT r;
    GetWindowRect(hWnd, &r);
    ClipCursor(&r);
    center.x = (r.left + r.right) / 2;
    center.y = (r.top + r.bottom) / 2;
    SetCursorPos(center.x, center.y);
}
Example #30
0
static bool win_grab_mouse(ALLEGRO_DISPLAY *display)
{
    ALLEGRO_SYSTEM_WIN *system = (void *)al_get_system_driver();
    ALLEGRO_DISPLAY_WIN *win_disp = (void *)display;
    RECT rect;

    GetWindowRect(win_disp->window, &rect);
    if (ClipCursor(&rect) != 0) {
        system->mouse_grab_display = display;
        return true;
    }

    return false;
}