本文整理汇总了C++中SetCapture函数的典型用法代码示例。如果您正苦于以下问题:C++ SetCapture函数的具体用法?C++ SetCapture怎么用?C++ SetCapture使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetCapture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAnchorPoint
//.........这里部分代码省略.........
// strURL | If not empty, when the balloon is clicked ShellExecute() will
// | be called, with strURL passed in.
// unTimeout | If not 0, balloon will automatically close after unTimeout milliseconds.
// hIcon | If not NULL, the icon indicated by hIcon will be displayed at top-left of the balloon.
//
// Returns:
// TRUE if successful, else FALSE
//
BOOL CBalloonHelp::Create(const CString& strTitle, const CString& strContent,
const CPoint& ptAnchor, unsigned int unOptions,
CWnd* pParentWnd /*=NULL*/,
const CString strURL /*= ""*/,
unsigned int unTimeout /*= 0*/,
HICON hIcon /*= NULL*/)
{
m_strContent = strContent;
SetAnchorPoint(ptAnchor, pParentWnd);
m_unOptions = unOptions;
m_strURL = strURL;
m_unTimeout = unTimeout;
if ( NULL != hIcon )
SetIcon(hIcon);
pParentWnd = GetSafeOwner(pParentWnd);
if (NULL == pParentWnd)
return FALSE;
// if no fonts set, use defaults
if ( NULL == m_pContentFont )
{
m_pContentFont = new CFont;
if ( !m_pContentFont->CreateStockObject(DEFAULT_GUI_FONT) )
return FALSE;
}
// title font defaults to bold version of content font
if ( NULL == m_pTitleFont )
{
m_pTitleFont = new CFont;
LOGFONT LogFont;
m_pContentFont->GetLogFont(&LogFont);
LogFont.lfWeight = FW_BOLD;
if ( !m_pTitleFont->CreateFontIndirect(&LogFont) )
return FALSE;
}
if ( !GetClassAtom() ) // couldn't register class
return FALSE;
// check system settings: if fade effects are disabled or unavailable, disable here too
BOOL bFade = FALSE;
::SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, &bFade, 0);
if (bFade)
::SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, &bFade, 0);
if (!bFade || NULL == m_fnAnimateWindow)
m_unOptions |= unDISABLE_FADE;
// create invisible at arbitrary position; then position, set region, and finally show
// the idea with WS_EX_TOOLWINDOW is, you can't switch to this using alt+tab
DWORD dwExStyle = WS_EX_TOOLWINDOW;
if ( m_unOptions&unSHOW_TOPMOST ) // make topmost, if requested
dwExStyle |= WS_EX_TOPMOST;
if ( !CreateEx(dwExStyle, _T("BalloonHelpClass"), strTitle, WS_POPUP, CRect(0,0,10,10), pParentWnd, 0, NULL) )
return FALSE;
PositionWindow();
if ( (m_unOptions&unCLOSE_ON_MOUSE_MOVE)
||(m_unOptions&unCLOSE_ON_LBUTTON_UP)
||(m_unOptions&unCLOSE_ON_LBUTTON_DOWN)
||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
||(m_unOptions&unCLOSE_ON_MBUTTON_DOWN)
||(m_unOptions&unCLOSE_ON_RBUTTON_UP)
||(m_unOptions&unCLOSE_ON_RBUTTON_DOWN) )
{
::GetCursorPos(&m_ptMouseOrig);
SetMouseHook();
}
// these need to take effect even if the window receiving them
// is not owned by this process. So, if this process does not
// already have the mouse captured, capture it!
if ( (m_unOptions&unCLOSE_ON_LBUTTON_UP)
||(m_unOptions&unCLOSE_ON_MBUTTON_UP)
||(m_unOptions&unCLOSE_ON_RBUTTON_UP) )
{
// no, i don't particularly need or want to deal with a situation
// where a balloon is being created and another program has captured
// the mouse. If you need it, it shouldn't be too hard, just do it here.
if ( NULL == GetCapture() )
SetCapture();
}
if ( m_unOptions&unCLOSE_ON_KEYPRESS )
SetKeyboardHook();
ShowBalloon();
return TRUE;
}
示例2: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
#ifndef WHEEL_DELTA
#define WHEEL_DELTA 120
#endif
irr::CIrrDeviceWin32* dev = 0;
irr::SEvent event;
static irr::s32 ClickCount=0;
if (GetCapture() != hWnd && ClickCount > 0)
ClickCount = 0;
struct messageMap
{
irr::s32 group;
UINT winMessage;
irr::s32 irrMessage;
};
static messageMap mouseMap[] =
{
{0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN},
{1, WM_LBUTTONUP, irr::EMIE_LMOUSE_LEFT_UP},
{0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN},
{1, WM_RBUTTONUP, irr::EMIE_RMOUSE_LEFT_UP},
{0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN},
{1, WM_MBUTTONUP, irr::EMIE_MMOUSE_LEFT_UP},
{2, WM_MOUSEMOVE, irr::EMIE_MOUSE_MOVED},
{3, WM_MOUSEWHEEL, irr::EMIE_MOUSE_WHEEL},
{-1, 0, 0}
};
// handle grouped events
messageMap * m = mouseMap;
while ( m->group >=0 && m->winMessage != message )
m += 1;
if ( m->group >= 0 )
{
if ( m->group == 0 ) // down
{
ClickCount++;
SetCapture(hWnd);
}
else
if ( m->group == 1 ) // up
{
ClickCount--;
if (ClickCount<1)
{
ClickCount=0;
ReleaseCapture();
}
}
event.EventType = irr::EET_MOUSE_INPUT_EVENT;
event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT) m->irrMessage;
event.MouseInput.X = (short)LOWORD(lParam);
event.MouseInput.Y = (short)HIWORD(lParam);
event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0);
// left and right mouse buttons
event.MouseInput.ButtonStates = wParam & ( MK_LBUTTON | MK_RBUTTON);
// middle and extra buttons
if (wParam & MK_MBUTTON)
event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
#if(_WIN32_WINNT >= 0x0500)
if (wParam & MK_XBUTTON1)
event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA1;
if (wParam & MK_XBUTTON2)
event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA2;
#endif
event.MouseInput.Wheel = 0.f;
// wheel
if ( m->group == 3 )
{
POINT p; // fixed by jox
p.x = 0; p.y = 0;
ClientToScreen(hWnd, &p);
event.MouseInput.X -= p.x;
event.MouseInput.Y -= p.y;
event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA;
}
dev = getDeviceFromHWnd(hWnd);
if (dev)
{
dev->postEventFromUser(event);
if ( event.MouseInput.Event >= irr::EMIE_LMOUSE_PRESSED_DOWN && event.MouseInput.Event <= irr::EMIE_MMOUSE_PRESSED_DOWN )
{
irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Event);
if ( clicks == 2 )
{
//.........这里部分代码省略.........
示例3: viewproc
//.........这里部分代码省略.........
case WM_RBUTTONDOWN:
{
SetFocus(hwndview);
return 0;
}
case WM_MOUSEWHEEL:
{
if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
gli_input_handle_key(keycode_MouseWheelUp);
else
gli_input_handle_key(keycode_MouseWheelDown);
}
case WM_CAPTURECHANGED:
{
gli_copyselect = FALSE;
return 0;
}
case WM_MOUSEMOVE:
{
/* catch and release */
RECT rect;
POINT pt = { x, y };
GetClientRect(hwnd, &rect);
int hover = PtInRect(&rect, pt);
if (!hover) {
if (GetCapture() == hwnd)
ReleaseCapture();
} else {
if (GetCapture() != hwnd ) {
SetCapture(hwnd);
}
if (gli_copyselect) {
SetCursor(idc_ibeam);
gli_move_selection(x, y);
} else {
if (gli_get_hyperlink(x, y)) {
SetCursor(idc_hand);
} else {
SetCursor(idc_arrow);
}
}
}
return 0;
}
case WM_COPY:
{
gli_copyselect = FALSE;
SetCursor(idc_arrow);
winclipsend();
return 0;
}
case WM_PASTE:
{
SetFocus(hwndview);
winclipreceive();
return 0;
}
case WM_SYSKEYDOWN:
示例4: windowProc
//.........这里部分代码省略.........
{
const int mods = getKeyMods();
const int scancode = (lParam >> 16) & 0x1ff;
const int key = translateKey(wParam, lParam);
if (key == _GLFW_KEY_INVALID)
break;
if (wParam == VK_SHIFT)
{
// Release both Shift keys on Shift up event, as only one event
// is sent even if both keys are released
_glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);
}
else if (wParam == VK_SNAPSHOT)
{
// Key down is not reported for the print screen key
_glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
_glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
}
else
_glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
break;
}
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
{
const int mods = getKeyMods();
SetCapture(hWnd);
if (uMsg == WM_LBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
else if (uMsg == WM_RBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
else if (uMsg == WM_MBUTTONDOWN)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
else
{
if (HIWORD(wParam) == XBUTTON1)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS, mods);
else if (HIWORD(wParam) == XBUTTON2)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS, mods);
return TRUE;
}
return 0;
}
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
{
const int mods = getKeyMods();
ReleaseCapture();
if (uMsg == WM_LBUTTONUP)
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods);
else if (uMsg == WM_RBUTTONUP)
示例5: SetCapture
void D3DLightingBasic::OnMouseDown(WPARAM btnState, int x, int y)
{
mLastMousePos.x = x;
mLastMousePos.y = y;
SetCapture(m_hMainWnd);
}
示例6: PhpSearchWndSubclassProc
LRESULT CALLBACK PhpSearchWndSubclassProc(
_In_ HWND hWnd,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam,
_In_ UINT_PTR uIdSubclass,
_In_ ULONG_PTR dwRefData
)
{
PEDIT_CONTEXT context = (PEDIT_CONTEXT)dwRefData;
switch (uMsg)
{
case WM_NCDESTROY:
{
PhpSearchFreeTheme(context);
if (context->WindowFont)
DeleteObject(context->WindowFont);
RemoveWindowSubclass(hWnd, PhpSearchWndSubclassProc, uIdSubclass);
PhFree(context);
}
break;
case WM_ERASEBKGND:
return 1;
case WM_NCCALCSIZE:
{
LPNCCALCSIZE_PARAMS ncCalcSize = (NCCALCSIZE_PARAMS*)lParam;
// Let Windows handle the non-client defaults.
DefSubclassProc(hWnd, uMsg, wParam, lParam);
// Deflate the client area to accommodate the custom button.
ncCalcSize->rgrc[0].right -= context->CXWidth;
}
return 0;
case WM_NCPAINT:
{
RECT windowRect;
// Let Windows handle the non-client defaults.
DefSubclassProc(hWnd, uMsg, wParam, lParam);
// Get the screen coordinates of the window.
GetWindowRect(hWnd, &windowRect);
// Adjust the coordinates (start from 0,0).
OffsetRect(&windowRect, -windowRect.left, -windowRect.top);
// Get the position of the inserted button.
PhpSearchGetButtonRect(context, &windowRect);
// Draw the button.
PhpSearchDrawButton(context, windowRect);
}
return 0;
case WM_NCHITTEST:
{
POINT windowPoint;
RECT windowRect;
// Get the screen coordinates of the mouse.
if (!GetCursorPos(&windowPoint))
break;
// Get the screen coordinates of the window.
GetWindowRect(hWnd, &windowRect);
// Get the position of the inserted button.
PhpSearchGetButtonRect(context, &windowRect);
// Check that the mouse is within the inserted button.
if (PtInRect(&windowRect, windowPoint))
{
return HTBORDER;
}
}
break;
case WM_NCLBUTTONDOWN:
{
POINT windowPoint;
RECT windowRect;
// Get the screen coordinates of the mouse.
if (!GetCursorPos(&windowPoint))
break;
// Get the screen coordinates of the window.
GetWindowRect(hWnd, &windowRect);
// Get the position of the inserted button.
PhpSearchGetButtonRect(context, &windowRect);
// Check that the mouse is within the inserted button.
if (PtInRect(&windowRect, windowPoint))
{
context->Pushed = TRUE;
SetCapture(hWnd);
//.........这里部分代码省略.........
示例7: Docking_ProcessWindowMessage
//.........这里部分代码省略.........
if(msg->lParam) return 0;
BOOL toBeDocked = (BOOL) ModernGetSettingByte(NULL,"CLUI","DockToSides",SETTING_DOCKTOSIDES_DEFAULT);
if((msg->wParam && g_CluiData.fDocked<0) || (!msg->wParam && g_CluiData.fDocked>0)) g_CluiData.fDocked=-g_CluiData.fDocked;
ZeroMemory(&abd,sizeof(abd));
abd.cbSize=sizeof(abd);
abd.hWnd=msg->hwnd;
if(msg->wParam) {
RECT rc, rcMonitor;
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
abd.lParam=0;
abd.uCallbackMessage=WM_DOCKCALLBACK;
SHAppBarMessage(ABM_NEW,&abd);
GetWindowRect(msg->hwnd,&rc);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
MoveWindow(msg->hwnd,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,FALSE);
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc);
ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW,NULL);//-=-=-=
}
else {
SHAppBarMessage(ABM_REMOVE,&abd);
}
}
return 0;
case WM_NCHITTEST:
{ LONG result;
result=DefWindowProc(msg->hwnd,WM_NCHITTEST,msg->wParam,msg->lParam);
if(result==HTSIZE || result==HTTOP || result==HTTOPLEFT || result==HTTOPRIGHT ||
result==HTBOTTOM || result==HTBOTTOMRIGHT || result==HTBOTTOMLEFT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
if(g_CluiData.fDocked==DOCKED_LEFT && result==HTLEFT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
if(g_CluiData.fDocked==DOCKED_RIGHT && result==HTRIGHT) {*((LRESULT*)lParam)=HTCLIENT; return TRUE;}
return 0;
}
case WM_SYSCOMMAND:
if((msg->wParam&0xFFF0)!=SC_MOVE) return 0;
SetActiveWindow(msg->hwnd);
SetCapture(msg->hwnd);
draggingTitle=1;
*((LRESULT*)lParam)=0;
return TRUE;
case WM_MOUSEMOVE:
if(!draggingTitle) return 0;
{ RECT rc;
POINT pt;
GetClientRect(msg->hwnd,&rc);
if(((g_CluiData.fDocked==DOCKED_LEFT || g_CluiData.fDocked==-DOCKED_LEFT) && (short)LOWORD(msg->lParam)>rc.right) ||
((g_CluiData.fDocked==DOCKED_RIGHT || g_CluiData.fDocked==-DOCKED_RIGHT) && (short)LOWORD(msg->lParam)<0)) {
ReleaseCapture();
draggingTitle=0;
ZeroMemory(&abd,sizeof(abd));
abd.cbSize=sizeof(abd);
abd.hWnd=msg->hwnd;
SHAppBarMessage(ABM_REMOVE,&abd);
g_CluiData.fDocked=0;
GetCursorPos(&pt);
PostMessage(msg->hwnd,WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(pt.x,pt.y));
SetWindowPos(msg->hwnd,0,pt.x-rc.right/2,pt.y-GetSystemMetrics(SM_CYFRAME)-GetSystemMetrics(SM_CYSMCAPTION)/2,ModernGetSettingDword(NULL,"CList","Width",0),ModernGetSettingDword(NULL,"CList","Height",0),SWP_NOZORDER);
ModernWriteSettingByte(NULL,"CList","Docked",(BYTE)g_CluiData.fDocked);
// ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);
}
return 1;
}
case WM_LBUTTONUP:
if(draggingTitle) {
ReleaseCapture();
draggingTitle=0;
}
return 0;
case WM_DOCKCALLBACK:
switch(msg->wParam) {
case ABN_WINDOWARRANGE:
CLUI_ShowWindowMod(msg->hwnd,msg->lParam?SW_HIDE:SW_SHOW);
{
RECT rc, rcMonitor;
Docking_GetMonitorRectFromWindow(msg->hwnd,&rcMonitor);
GetWindowRect(msg->hwnd,&rc);
Docking_AdjustPosition(msg->hwnd,&rcMonitor,&rc);
Sync(CLUIFrames_OnMoving,msg->hwnd,&rc); //-=-=-=
ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);
g_CluiData.mutexPreventDockMoving=1;
}
break;
}
return TRUE;
case WM_DESTROY:
if(g_CluiData.fDocked>0) {
ZeroMemory(&abd,sizeof(abd));
abd.cbSize=sizeof(abd);
abd.hWnd=msg->hwnd;
SHAppBarMessage(ABM_REMOVE,&abd);
ModernSkinButton_ReposButtons(msg->hwnd, SBRF_DO_NOT_DRAW, NULL);
}
return 0;
}
return 0;
}
示例8: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static POINT point;
static POINT pointOld;
static BOOL bCapture;
static HFONT hFont;
static TCHAR szText[1024];
switch (msg)
{
case WM_CREATE:
hFont = CreateFont(64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("メイリオ"));
break;
case WM_LBUTTONDOWN:
if (!bCapture)
{
point.x = LOWORD(lParam);
point.y = HIWORD(lParam);
SetCapture(hWnd);
bCapture = 1;
}
break;
case WM_RBUTTONUP:
if (bCapture)
{
ReleaseCapture();
bCapture = 0;
}
SendMessage(hWnd, WM_CLOSE, 0, 0);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
const HDC hdc = BeginPaint(hWnd, &ps);
const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
RECT rect;
GetClientRect(hWnd, &rect);
DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
SelectObject(hdc, hFontOld);
EndPaint(hWnd, &ps);
}
break;
case WM_MOUSEMOVE:
if (bCapture)
{
const HDC hdc = GetDC(hWnd);
const HPEN hPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
const HPEN hPenOld = (HPEN)SelectObject(hdc, hPen);
MoveToEx(hdc, point.x, point.y, 0);
LineTo(hdc, pointOld.x, pointOld.y);
SelectObject(hdc, hPenOld);
DeleteObject(hPen);
MoveToEx(hdc, point.x, point.y, 0);
LineTo(hdc, LOWORD(lParam), HIWORD(lParam));
const HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
const double dAngle = atan2((double)(point.x - LOWORD(lParam)), (double)(point.y - HIWORD(lParam)));
const double dDistance = sqrt((double)((point.x - LOWORD(lParam))*(point.x - LOWORD(lParam)) + (point.y - HIWORD(lParam))*(point.y - HIWORD(lParam))));
swprintf_s(szText, 1024,
TEXT("角度 %f 度\r\n")
TEXT("角度 %f ラジアン\r\n")
TEXT("距離 %f ピクセル\r\n"),
(dAngle + PI / 2.0)*180.0 / PI,
dAngle + PI / 2.0,
dDistance + 1.0
);
RECT rect;
GetClientRect(hWnd, &rect);
DrawText(hdc, szText, -1, &rect, DT_WORDBREAK);
SelectObject(hdc, hFontOld);
ReleaseDC(hWnd, hdc);
pointOld.x = LOWORD(lParam);
pointOld.y = HIWORD(lParam);
}
break;
case WM_LBUTTONUP:
if (bCapture)
{
ReleaseCapture();
bCapture = 0;
InvalidateRect(hWnd, 0, 1);
}
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
{
SendMessage(hWnd, WM_CLOSE, 0, 0);
}
else if (wParam == 'C')
{
if (GetKeyState(VK_CONTROL)<0)
{
const int nLen = lstrlen(szText);
const HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, sizeof(TCHAR)*(nLen + 1));
const LPTSTR lpszBuf = (LPTSTR)GlobalLock(hMem);
lstrcpy(lpszBuf, szText);
GlobalUnlock(hMem);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, hMem);
CloseClipboard();
}
//.........这里部分代码省略.........
示例9: DragUI
void DragUI( HWND hWnd, HWND hWnd1,UINT message, WPARAM wParam, LPARAM lParam,BOOL fIsCompWnd)
{
POINT pt;
static POINT ptdif,ptdif1;
static RECT drc,drc1;
static SIZE sz,sz1;
DWORD dwT;
switch (message)
{
case WM_SETCURSOR:
if ( HIWORD(lParam) == WM_LBUTTONDOWN
|| HIWORD(lParam) == WM_RBUTTONDOWN )
{
GetCursorPos( &pt );
SetCapture(hWnd);
GetWindowRect(hWnd,&drc);
ptdif.x = pt.x - drc.left;
ptdif.y = pt.y - drc.top;
sz.cx = drc.right - drc.left;
sz.cy = drc.bottom - drc.top;
if (IsWindow(hWnd1)) {
GetWindowRect(hWnd1,&drc1);
ptdif1.x = pt.x - drc1.left;
ptdif1.y = pt.y - drc1.top;
sz1.cx = drc1.right - drc1.left;
sz1.cy = drc1.bottom - drc1.top;
}
SetWindowLong(hWnd,FIGWL_MOUSE,FIM_CAPUTURED);
}
break;
case WM_MOUSEMOVE:
dwT = GetWindowLong(hWnd,FIGWL_MOUSE);
if (dwT & FIM_MOVED)
{
DrawUIBorder(&drc);
if (IsWindow(hWnd1)) DrawUIBorder(&drc1);
GetCursorPos( &pt );
drc.left = pt.x - ptdif.x;
drc.top = pt.y - ptdif.y;
drc.right = drc.left + sz.cx;
drc.bottom = drc.top + sz.cy;
if (IsWindow(hWnd1)) {
drc1.left = pt.x - ptdif1.x;
drc1.top = pt.y - ptdif1.y;
drc1.right = drc1.left + sz1.cx;
drc1.bottom = drc1.top + sz1.cy;
}
DrawUIBorder(&drc);
if (IsWindow(hWnd1)) DrawUIBorder(&drc1);
}
else if (dwT & FIM_CAPUTURED)
{
DrawUIBorder(&drc);
if (IsWindow(hWnd1)) DrawUIBorder(&drc1);
SetWindowLong(hWnd,FIGWL_MOUSE,dwT | FIM_MOVED);
}
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
dwT = GetWindowLong(hWnd,FIGWL_MOUSE);
if (dwT & FIM_CAPUTURED)
{
ReleaseCapture();
if (dwT & FIM_MOVED)
{
DrawUIBorder(&drc);
if (IsWindow(hWnd1)) DrawUIBorder(&drc1);
GetCursorPos( &pt );
MoveWindow(hWnd,pt.x - ptdif.x,
pt.y - ptdif.y,
sz.cx,
sz.cy,TRUE);
if(fIsCompWnd) {
HWND hUIWnd;
LPARAM mylParam;
*((LPWORD)(&mylParam)) = (WORD)(pt.x - ptdif.x);
*((LPWORD)(&mylParam)+1) = (WORD)(pt.y - ptdif.y);
hUIWnd = (HWND)GetWindowLong(hWnd,FIGWL_SVRWND);
if (IsWindow(hUIWnd))
SendMessage(hUIWnd,WM_UI_COMPMOVE,0,mylParam);
}
if (IsWindow(hWnd1)) {
MoveWindow(hWnd1,pt.x - ptdif1.x,
pt.y - ptdif1.y,
sz1.cx,
sz1.cy,TRUE);
}
}
}
break;
//.........这里部分代码省略.........
示例10: PAGER_MouseMove
static LRESULT
PAGER_MouseMove (PAGER_INFO* infoPtr, INT keys, INT x, INT y)
{
POINT clpt, pt;
RECT wnrect;
BOOL topLeft = FALSE;
INT btnstate = 0;
INT hit;
HDC hdc;
pt.x = x;
pt.y = y;
TRACE("[%p] to (%d,%d)\n", infoPtr->hwndSelf, x, y);
ClientToScreen(infoPtr->hwndSelf, &pt);
GetWindowRect(infoPtr->hwndSelf, &wnrect);
if (PtInRect(&wnrect, pt)) {
RECT topleft, bottomright, *rect = NULL;
PAGER_GetButtonRects(infoPtr, &topleft, &bottomright, FALSE);
clpt = pt;
MapWindowPoints(0, infoPtr->hwndSelf, &clpt, 1);
hit = PAGER_HitTest(infoPtr, &clpt);
if ((hit == PGB_TOPORLEFT) && (infoPtr->TLbtnState == PGF_NORMAL))
{
topLeft = TRUE;
rect = &topleft;
infoPtr->TLbtnState = PGF_HOT;
btnstate = infoPtr->TLbtnState;
}
else if ((hit == PGB_BOTTOMORRIGHT) && (infoPtr->BRbtnState == PGF_NORMAL))
{
topLeft = FALSE;
rect = &bottomright;
infoPtr->BRbtnState = PGF_HOT;
btnstate = infoPtr->BRbtnState;
}
/* If in one of the buttons the capture and draw buttons */
if (rect)
{
TRACE("[%p] draw btn (%s), Capture %s, style %08x\n",
infoPtr->hwndSelf, wine_dbgstr_rect(rect),
(infoPtr->bCapture) ? "TRUE" : "FALSE",
infoPtr->dwStyle);
if (!infoPtr->bCapture)
{
TRACE("[%p] SetCapture\n", infoPtr->hwndSelf);
SetCapture(infoPtr->hwndSelf);
infoPtr->bCapture = TRUE;
}
if (infoPtr->dwStyle & PGS_AUTOSCROLL)
SetTimer(infoPtr->hwndSelf, TIMERID1, 0x3e, 0);
hdc = GetWindowDC(infoPtr->hwndSelf);
/* OffsetRect(wnrect, 0 | 1, 0 | 1) */
PAGER_DrawButton(hdc, infoPtr->clrBk, *rect,
infoPtr->dwStyle & PGS_HORZ, topLeft, btnstate);
ReleaseDC(infoPtr->hwndSelf, hdc);
return 0;
}
}
/* If we think we are captured, then do release */
if (infoPtr->bCapture && (WindowFromPoint(pt) != infoPtr->hwndSelf))
{
NMHDR nmhdr;
infoPtr->bCapture = FALSE;
if (GetCapture() == infoPtr->hwndSelf)
{
ReleaseCapture();
if (infoPtr->TLbtnState == PGF_GRAYED)
{
infoPtr->TLbtnState = PGF_INVISIBLE;
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
SWP_NOZORDER | SWP_NOACTIVATE);
}
else if (infoPtr->TLbtnState == PGF_HOT)
{
infoPtr->TLbtnState = PGF_NORMAL;
/* FIXME: just invalidate button rect */
RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
}
if (infoPtr->BRbtnState == PGF_GRAYED)
{
infoPtr->BRbtnState = PGF_INVISIBLE;
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
SWP_NOZORDER | SWP_NOACTIVATE);
}
else if (infoPtr->BRbtnState == PGF_HOT)
{
infoPtr->BRbtnState = PGF_NORMAL;
/* FIXME: just invalidate button rect */
RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
//.........这里部分代码省略.........
示例11: FaderWndProc
LONG WINAPI FaderWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
/////////////////////////////////////////////////////////////////////////////
{
PAINTSTRUCT ps;
PFADERINFO pFI = (PFADERINFO)GetWindowLong( hWnd, GWL_USERDATA );
HWND hParentWnd = GetParent( hWnd );
switch( iMessage )
{
case WM_GETDLGCODE:
return( DLGC_WANTARROWS );
case WM_SETFOCUS:
if( pFI )
{
CreateCaret( hWnd, (HBITMAP)1, pFI->bmFader.bmWidth - 5, pFI->bmFader.bmHeight - CARET_OFFSET );
SetCaretPos( pFI->nBitmapX + 2, pFI->nBitmapPos + (CARET_OFFSET/2) );
ShowCaret( hWnd );
pFI->bHasFocus = TRUE;
}
break;
case WM_KILLFOCUS:
if( pFI )
pFI->bHasFocus = FALSE;
HideCaret( hWnd );
DestroyCaret();
break;
case WM_APPCOMMAND:
switch( GET_APPCOMMAND_LPARAM(lParam) )
{
case APPCOMMAND_VOLUME_MUTE:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_BOTTOM, (LPARAM)hWnd );
return( TRUE );
case APPCOMMAND_VOLUME_UP:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEUP, (LPARAM)hWnd );
return( TRUE );
case APPCOMMAND_VOLUME_DOWN:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEDOWN, (LPARAM)hWnd );
return( TRUE );
default:
return( DefWindowProc( hWnd, iMessage, wParam, lParam ) );
}
break;
case WM_KEYDOWN: /* Keyboard Interface for Fader */
switch( wParam )
{
case VK_TAB:
// pass this on to the parent
//PostMessage( hParentWnd, iMessage, wParam, lParam );
break;
case VK_RIGHT:
case VK_DOWN:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEDOWN, (LPARAM)hWnd );
break;
case VK_LEFT:
case VK_UP:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_LINEUP, (LPARAM)hWnd );
break;
case VK_PRIOR:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_PAGEUP, (LPARAM)hWnd );
break;
case VK_NEXT:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_PAGEDOWN, (LPARAM)hWnd );
break;
case VK_HOME:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_TOP, (LPARAM)hWnd );
break;
case VK_END:
PostMessage( hParentWnd, WM_VSCROLL, (WPARAM)SB_BOTTOM, (LPARAM)hWnd );
break;
}
break;
case WM_LBUTTONUP:
ReleaseCapture();
if( pFI )
{
// we know this control has the focus
SetCaretPos( pFI->nBitmapX + 2, pFI->nBitmapPos + (CARET_OFFSET/2) );
ShowCaret( hWnd );
pFI->bMouseDown = FALSE;
}
break;
case WM_LBUTTONDOWN:
SetFocus( hWnd );
SetCapture( hWnd );
HideCaret( hWnd );
if( pFI )
{
//.........这里部分代码省略.........
示例12: switch
// callback function for the splitter window.
LRESULT CALLBACK
FrameWindowSplitter::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
// Get a pointer to the window class object.
FrameWindowSplitter *pFrameWindowSplitter = (FrameWindowSplitter *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch(message)
{
case WM_NCCREATE:
// Get the initial creation pointer to the window object
pFrameWindowSplitter = (FrameWindowSplitter *)((CREATESTRUCT *)lparam)->lpCreateParams;
pFrameWindowSplitter->m_hwnd = hwnd;
SetWindowLongPtr(hwnd, GWLP_USERDATA,(LONG_PTR)pFrameWindowSplitter);
break;
case WM_PAINT:
return pFrameWindowSplitter->OnPaint();
case WM_MOUSEMOVE:
pFrameWindowSplitter->MouseMove();
return 0;
case WM_LBUTTONDOWN:
{
MDIWindow * pcquerywnd = (MDIWindow*)GetWindowLongPtr(pFrameWindowSplitter->m_hwndparent, GWLP_USERDATA);
if(pcquerywnd->m_isobjbrowvis == wyFalse)
break;
else
{
pFrameWindowSplitter->m_prevstyle = GetWindowLongPtr(pFrameWindowSplitter->m_hwndparent, GWL_STYLE);
SetWindowLongPtr(pFrameWindowSplitter->m_hwndparent, GWL_STYLE, pFrameWindowSplitter->m_prevstyle & ~WS_CLIPCHILDREN);
pFrameWindowSplitter->m_hwndprevfocus = GetFocus();
SetFocus(hwnd);
SetCapture(hwnd);
/* starting from v4.2 BETA we stop the repaining of the two custom tab controls
so that flicker does not happen */
pFrameWindowSplitter->m_isdragged = wyTrue;
pFrameWindowSplitter->MouseMove(wyTrue);
}
}
break;
case WM_LBUTTONUP:
ReleaseCapture();
break;
case WM_CAPTURECHANGED:
if(pFrameWindowSplitter->m_isdragged)
{
SetWindowLongPtr(pFrameWindowSplitter->m_hwndparent, GWL_STYLE, pFrameWindowSplitter->m_prevstyle);
pFrameWindowSplitter->EndDrag(wyTrue);
pFrameWindowSplitter->Resizeall();
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
pFrameWindowSplitter->m_isdragged = wyFalse;
if(pFrameWindowSplitter->m_hwndprevfocus)
{
SetFocus(pFrameWindowSplitter->m_hwndprevfocus);
pFrameWindowSplitter->m_hwndprevfocus = NULL;
}
}
break;
}
return(DefWindowProc(hwnd, message, wparam, lparam));
}
示例13: drag_end
bool
ListControl::OnMouseDown(PixelScalar x, PixelScalar y)
{
// End any previous drag
scroll_bar.DragEnd(this);
drag_end();
kinetic_timer.Cancel();
RasterPoint Pos;
Pos.x = x;
Pos.y = y;
// If possible -> Give focus to the Control
const bool had_focus = !HasCursorKeys() || HasFocus();
if (!had_focus)
SetFocus();
if (scroll_bar.IsInsideSlider(Pos)) {
// if click is on scrollbar handle
// -> start mouse drag
scroll_bar.DragBegin(this, Pos.y);
} else if (scroll_bar.IsInside(Pos)) {
// if click in scroll bar up/down/pgup/pgdn
if (scroll_bar.IsInsideUpArrow(Pos.y))
// up
MoveOrigin(-1);
else if (scroll_bar.IsInsideDownArrow(Pos.y))
// down
MoveOrigin(1);
else if (scroll_bar.IsAboveSlider(Pos.y))
// page up
MoveOrigin(-(int)items_visible);
else if (scroll_bar.IsBelowSlider(Pos.y))
// page down
MoveOrigin(items_visible);
} else {
// if click in ListBox area
// -> select appropriate item
int index = ItemIndexAt(y);
// If mouse was clicked outside the list items -> cancel
if (index < 0)
return false;
drag_y = GetPixelOrigin() + y;
drag_y_window = y;
if (had_focus && (unsigned)index == GetCursorIndex() &&
CanActivateItem()) {
drag_mode = DragMode::CURSOR;
Invalidate_item(cursor);
} else {
// If item was not selected before
// -> select it
SetCursorIndex(index);
drag_mode = DragMode::SCROLL;
}
if (UsePixelPan())
kinetic.MouseDown(GetPixelOrigin());
SetCapture();
}
return true;
}
示例14: WindowProc
//.........这里部分代码省略.........
KEY_NONE , KEY_NONE , KEY_NONE , KEY_NONE ,
KEY_NONE , KEY_NONE , KEY_NONE , KEY_NONE ,
KEY_NONE , KEY_NONE , KEY_NONE , KEY_NONE ,
KEY_NONE , KEY_NONE , KEY_NONE , KEY_LBRACKET ,
KEY_PIPE , KEY_RBRACKET , KEY_QUOTE , KEY_NONE ,
/** only KEY_NONE`s here... **/
};
INPUT vkey;
POINT movp;
switch (uMsg) {
case WM_CREATE:
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
return 0;
case WM_HOTKEY:
/** Emulate a PrtScr, since we`ve captured it, and now
the system redirects all PrtScr keystrokes to us.
This is indeed ugly, but it`s how Windows works... **/
UnregisterHotKey(hWnd, IDHOT_SNAPWINDOW);
UnregisterHotKey(hWnd, IDHOT_SNAPDESKTOP);
vkey = (INPUT){INPUT_KEYBOARD};
vkey.ki.wVk = VK_SNAPSHOT;
SendInput(1, &vkey, sizeof(INPUT));
RegisterHotKey(hWnd, IDHOT_SNAPDESKTOP, 0, VK_SNAPSHOT);
RegisterHotKey(hWnd, IDHOT_SNAPWINDOW, 0, VK_SNAPSHOT);
if (GetActiveWindow() != hWnd)
break;
wPrm = VK_SNAPSHOT;
case WM_SYSKEYDOWN:
uMsg = WM_KEYDOWN;
case WM_SYSKEYUP:
case WM_KEYDOWN:
case WM_KEYUP:
switch (wPrm) {
case VK_SHIFT: /** [ MAPVK_VSC_TO_VK_EX ]-----v **/
wPrm = MapVirtualKey((lPrm >> 16) & 0xFF, 3); break;
#define WIN_MKEY(a, b) wPrm = (lPrm & 0x01000000)? a : b
case VK_MENU: WIN_MKEY(VK_RMENU, VK_LMENU); break;
case VK_CONTROL: WIN_MKEY(VK_RCONTROL, VK_LCONTROL); break;
case VK_RETURN: WIN_MKEY(VK_SEPARATOR, VK_RETURN); break;
case VK_DELETE: WIN_MKEY(VK_DELETE, VK_DECIMAL); break;
case VK_INSERT: WIN_MKEY(VK_INSERT, VK_NUMPAD0); break;
case VK_END: WIN_MKEY(VK_END, VK_NUMPAD1); break;
case VK_DOWN: WIN_MKEY(VK_DOWN, VK_NUMPAD2); break;
case VK_NEXT: WIN_MKEY(VK_NEXT, VK_NUMPAD3); break;
case VK_LEFT: WIN_MKEY(VK_LEFT, VK_NUMPAD4); break;
case VK_CLEAR: WIN_MKEY(VK_NUMPAD5, VK_NUMPAD5); break;
case VK_RIGHT: WIN_MKEY(VK_RIGHT, VK_NUMPAD6); break;
case VK_HOME: WIN_MKEY(VK_HOME, VK_NUMPAD7); break;
case VK_UP: WIN_MKEY(VK_UP, VK_NUMPAD8); break;
case VK_PRIOR: WIN_MKEY(VK_PRIOR, VK_NUMPAD9); break;
#undef WIN_MKEY
}
cKbdInput((ENGC*)GetWindowLongPtr(hWnd, GWLP_USERDATA),
keys[wPrm & 0xFF], (uMsg == WM_KEYDOWN)? TRUE : FALSE);
return 0;
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
if ((uMsg == WM_LBUTTONDOWN)
|| (uMsg == WM_MBUTTONDOWN)
|| (uMsg == WM_RBUTTONDOWN))
SetCapture(hWnd);
else
ReleaseCapture();
GetCursorPos(&movp);
ScreenToClient(hWnd, &movp);
cMouseInput((ENGC*)GetWindowLongPtr(hWnd, GWLP_USERDATA), movp.x,
movp.y, ((uMsg == WM_LBUTTONDOWN)? 1 << 1 : 0) |
((uMsg == WM_MBUTTONDOWN)? 1 << 2 : 0) |
((uMsg == WM_RBUTTONDOWN)? 1 << 3 : 0));
return 0;
case WM_MOUSEMOVE:
GetCursorPos(&movp);
ScreenToClient(hWnd, &movp);
cMouseInput((ENGC*)GetWindowLongPtr(hWnd, GWLP_USERDATA), movp.x,
movp.y, ((wPrm & MK_LBUTTON)? 2 : 0) |
((wPrm & MK_MBUTTON)? 4 : 0) |
((wPrm & MK_RBUTTON)? 8 : 0) | 1);
return 0;
case WM_SIZE: {
ENGC *engc = (ENGC*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if (engc && (wPrm != SIZE_MINIMIZED))
cResizeWindow(engc, LOWORD(lPrm), HIWORD(lPrm));
return 0;
}
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wPrm, lPrm);
}
示例15: WndProc
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static BOOL fBlocking, fValidBox ;
static POINT ptBeg, ptEnd, ptBoxBeg, ptBoxEnd ;
HDC hdc ;
PAINTSTRUCT ps ;
switch (message)
{
case WM_LBUTTONDOWN :
ptBeg.x = ptEnd.x = LOWORD (lParam) ;
ptBeg.y = ptEnd.y = HIWORD (lParam) ;
DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
SetCapture (hwnd) ;
SetCursor (LoadCursor (NULL, IDC_CROSS)) ;
fBlocking = TRUE ;
return 0 ;
case WM_MOUSEMOVE :
if (fBlocking)
{
SetCursor (LoadCursor (NULL, IDC_CROSS)) ;
DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
ptEnd.x = LOWORD (lParam) ;
ptEnd.y = HIWORD (lParam) ;
DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
}
return 0 ;
case WM_LBUTTONUP :
if (fBlocking)
{
DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
ptBoxBeg = ptBeg ;
ptBoxEnd.x = LOWORD (lParam) ;
ptBoxEnd.y = HIWORD (lParam) ;
ReleaseCapture () ;
SetCursor (LoadCursor (NULL, IDC_ARROW)) ;
fBlocking = FALSE ;
fValidBox = TRUE ;
InvalidateRect (hwnd, NULL, TRUE) ;
}
return 0 ;
case WM_CHAR :
if (fBlocking & (wParam == '\x1B')) // i.e., Escape
{
DrawBoxOutline (hwnd, ptBeg, ptEnd) ;
ReleaseCapture () ;
SetCursor (LoadCursor (NULL, IDC_ARROW)) ;
fBlocking = FALSE ;
}
return 0 ;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ;
if (fValidBox)
{
SelectObject (hdc, GetStockObject (BLACK_BRUSH)) ;
Rectangle (hdc, ptBoxBeg.x, ptBoxBeg.y,
ptBoxEnd.x, ptBoxEnd.y) ;
}
if (fBlocking)
{
SetROP2 (hdc, R2_NOT) ;
SelectObject (hdc, GetStockObject (NULL_BRUSH)) ;
Rectangle (hdc, ptBeg.x, ptBeg.y, ptEnd.x, ptEnd.y) ;
}
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}