本文整理汇总了C++中ClipCursor函数的典型用法代码示例。如果您正苦于以下问题:C++ ClipCursor函数的具体用法?C++ ClipCursor怎么用?C++ ClipCursor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClipCursor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetWindowRect
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;
}
}
示例2: rcTrack
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();
}
示例3: GetWindowRect
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);
}
}
示例4: _ClipCursor
BOOL WINAPI _ClipCursor(const RECT *lpRect)
{
if ( !wmode )
{
if ( _ClipCursorOld )
return _ClipCursorOld(lpRect);
return ClipCursor(lpRect);
}
return TRUE;
}
示例5: ClipCursor
void OverlayControl::MouseUp(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
if (!ActiveOverlay)
return;
// Release mouse.
ClipCursor(0);
ReleaseCapture();
ResetCursor();
}
示例6: MouseSetRect
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
}
示例7: ClipCursor
// ----------------------------------------------------------------------- //
//
// 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);
}
示例8: GetWindowRect
void WindowsMouseController::grab()
{
RECT clipRegion;
GetWindowRect( mWindowHandle, &clipRegion );
clipRegion.left += 10;
clipRegion.right -= 10;
clipRegion.top += 33;
clipRegion.bottom -= 10;
ClipCursor( &clipRegion );
}
示例9: GetClientRect
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);
}
示例10: mouse
/*
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);
}
示例11: IN_DeactivateWin32Mouse
/*
================
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)
;
}
示例12: GetWindowRect
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;
}
}
示例13: Win_DeAcquireMouse
// 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 );
}
示例14: WIN_UpdateClipCursor
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);
}
}
示例15: hideCursor
// Hide the mouse cursor
//
static void hideCursor(_GLFWwindow* window)
{
POINT pos;
ClipCursor(NULL);
if (GetCursorPos(&pos))
{
if (WindowFromPoint(pos) == window->win32.handle)
SetCursor(NULL);
}
}