本文整理汇总了C++中TrackMouseEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ TrackMouseEvent函数的具体用法?C++ TrackMouseEvent怎么用?C++ TrackMouseEvent使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TrackMouseEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WindowProc
/***********************************************************************************
WindowProc - Main message handler
***********************************************************************************/
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TRACKMOUSEEVENT tme;
switch(message)
{
case WM_CREATE:
g_pStateIntro->Initialize();
g_pStateMain->Initialize();
g_pStateControl->Initialize();
g_pStateCredits->Initialize();
g_pStatePlay1->Initialize();
//#define _WIN32_WINNT 0x0500 added before <windows.h> in order to get this to work
tme.cbSize = sizeof(tme);
tme.dwFlags = 0x00000002;//TME_LEAVE;
tme.hwndTrack = hWnd;
TrackMouseEvent(&tme);
return 0;
case WM_MOUSEMOVE:
TrackMouseEvent(&tme);
return 0;
case WM_LBUTTONDBLCLK:
return 0;
case WM_LBUTTONDOWN:
mouse.SetLeftButtonDown(true);
return 0;
case WM_LBUTTONUP:
mouse.SetLeftButtonDown(false);
return 0;
case WM_RBUTTONDOWN:
mouse.SetRightButtonDown(true);
return 0;
case WM_RBUTTONUP:
mouse.SetRightButtonDown(false);
return 0;
case WM_MOUSELEAVE:
mouse.SetLeftButtonDown(false);
mouse.SetRightButtonDown(false);
return 0;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
示例2: switch
LRESULT TabCloseButton::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) {
RECT tmpRect;
switch(msg) {
case WM_MOUSEMOVE:
if(state_)
break;
state_ = 1;
TrackMouseEvent(TME_LEAVE);
ImmediatelyUpdateWindow();
return 0;
case WM_MOUSELEAVE:
state_ = 0;
mousePressed_ = false;
tmpRect = getClientRect();
::MapWindowPoints(getWindowHandle(), getParent(), (POINT *) &tmpRect, 2);
SafeWindowFromHandle(getParent())->UpdateWindow(&tmpRect);
::UpdateWindow(getParent());
ImmediatelyUpdateWindow();
return 0;
case WM_LBUTTONDOWN:
state_ = 2;
mousePressed_ = true;
ImmediatelyUpdateWindow();
return 0;
case WM_LBUTTONUP:
state_ = 1;
ImmediatelyUpdateWindow();
if(mousePressed_)
onClick_(*this);
return 0;
}
return Window::WndProc(msg, wParam, lParam);
}
示例3: GetCursorPos
void CDrawCheckbox::OnMouseMove(WPARAM wParam, LPARAM lParam)
{
// 按钮可用
if(m_nCtrlState != STATE_DISABLE)
{
POINT pt = {};
GetCursorPos(&pt);
ScreenToClient(m_hWnd, &pt);
if(PtInRegion(m_hCtrlRgn, pt.x, pt.y)) // 鼠标在控件区域内
{
// 鼠标没有跟踪
if(!m_fTrackMouse)
{
// 跟踪鼠标离开,触发MouseLeave消息
TRACKMOUSEEVENT MouseEvent = {sizeof(TRACKMOUSEEVENT)};
MouseEvent.dwFlags = TME_LEAVE;
MouseEvent.hwndTrack = m_hWnd;
MouseEvent.dwHoverTime = 1000;
TrackMouseEvent(&MouseEvent);
// 设置鼠标被跟踪
m_fTrackMouse = TRUE;
}
// 按钮没有按下,则设置按钮状态为焦点
if(m_nCtrlState != STATE_DOWN)
m_nCtrlState = STATE_FOCUS;
}
else // 移动到区域外,均直接处理为鼠标弹起
{
m_nCtrlState = STATE_UP;
}
InvalidataCtrl();
}
}
示例4: sizeof
void NativeTextfieldWin::SetContainsMouse(bool contains_mouse)
{
if(contains_mouse == contains_mouse_)
{
return;
}
contains_mouse_ = contains_mouse;
if(!textfield_->draw_border())
{
return;
}
if(contains_mouse_)
{
// Register for notification when the mouse leaves. Need to do this so
// that we can reset contains mouse properly.
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = m_hWnd;
tme.dwHoverTime = 0;
TrackMouseEvent(&tme);
}
RedrawWindow(NULL, NULL, RDW_INVALIDATE|RDW_FRAME);
}
示例5: pt
LRESULT CHtmlColorCtrl::OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
RECT rcClient;
if( GetClientRect(&rcClient) ) {
if(!m_bTrackingMouse) {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = /*TME_HOVER|*/TME_LEAVE;
m_bTrackingMouse = TrackMouseEvent(&tme);
}
m_ptMouse.x=min(pt.x/BOX_SIZE, COL_COUNT-1);
m_ptMouse.y=min(pt.y/BOX_SIZE, LINE_COUNT-1);
CRect rcBtn(0, LINE_COUNT*BOX_SIZE+20, COL_COUNT*BOX_SIZE, rcClient.bottom);
m_bOnButton=rcBtn.PtInRect(pt);
if( m_bOnButton )
m_ptMouse.x=m_ptMouse.y=-1;
InvalidateRect(&rcClient);
}
return 0;
}
示例6: KillTimer
void CSCWListCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_nHoverNDTimerID) {
if (HitTest(m_HoverNDPoint) == HitTest(point))
return;
KillTimer(m_nHoverNDTimerID);
m_nHoverNDTimerID = 0;
}
if (m_nShowNDTimerID) {
if (HitTest(m_HoverNDPoint) == HitTest(point))
return;
KillTimer(m_nShowNDTimerID);
m_nShowNDTimerID = 0;
m_pParent->SetNotesWindow(CPoint(0, 0), false);
}
if (!m_bMouseInWindow) {
m_bMouseInWindow = true;
TRACKMOUSEEVENT tme = {sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd, 0};
VERIFY(TrackMouseEvent(&tme));
}
m_nHoverNDTimerID = SetTimer(TIMER_ND_HOVER, HOVER_TIME_ND, NULL);
m_HoverNDPoint = point;
CListCtrl::OnMouseMove(nFlags, point);
}
示例7: ShowCursor
void CHyperLink::OnMouseMove(UINT nFlags, CPoint point)
{
if (!m_bDisabled)
{
ShowCursor(FALSE);
m_hReg = ::SetCursor(m_hHand);
ShowCursor(TRUE);
}
if (m_bMouseIn)
return;
TRACKMOUSEEVENT EventTrack;
EventTrack.cbSize = sizeof(TRACKMOUSEEVENT);
EventTrack.dwFlags = TME_LEAVE;
EventTrack.dwHoverTime = 0;
EventTrack.hwndTrack = m_hWnd;
TrackMouseEvent(&EventTrack);
m_bMouseIn = TRUE;
if (nFlags & MK_LBUTTON)
m_bMouseDown = TRUE;
else
m_bMouseDown = FALSE;
Invalidate();
}
示例8: sizeof
void CDComView::OnMouseMove(UINT nFlags, CPoint point)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
TrackMouseEvent(&tme);
if (m_bMouseIn == false)
{
m_bMouseIn = true;
if ((m_bLeftButtonDown == true) && ((MK_LBUTTON & nFlags) != MK_LBUTTON))
{
m_bDoubleClickDown = false;
m_bLeftButtonDown = false;
PostMessage(WM_COMMAND, MAKEWPARAM(ID_EDIT_COPY, 0));
}
}
if (m_bLeftButtonDown == true)
{
UpdateSelectionRange(point, false, m_bDoubleClickDown);
Invalidate();
}
CScrollView::OnMouseMove(nFlags, point);
}
示例9: sizeof
// マウスイベント時のボタン描画処理の前処理
void Controls::DrawImageButtonOnMouseEvent(HWND hWnd_button, int flag)
{
HDC hdc_button;
int id;
CONTROLINFO *lpControlInfo;
id = (int)GetWindowLongPtr(hWnd_button, GWLP_USERDATA);
lpControlInfo = &controlinfo[id];
if (lpControlInfo->hWnd_control != hWnd_button)
return;
if (flag) {
if (lpControlInfo->option & 0x1)
return;
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd_button;
TrackMouseEvent(&tme);
lpControlInfo->option |= 0x1;
} else {
if (!(lpControlInfo->option & 0x1))
return;
lpControlInfo->option &= ~0x1;
}
lpControlInfo->drawmode = flag;
hdc_button = GetDC(hWnd_button);
DrawImageButton(lpControlInfo, hdc_button);
ReleaseDC(hWnd_button, hdc_button);
return;
}
示例10: sizeof
void HoverControl::onMouseMove(long x, long y)
{
if (!_isTracking)
{
// TrackMouseEvents disable after one message is received, so we need to
// re-enable them.
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.dwHoverTime = HOVER_DEFAULT;
tme.hwndTrack = _hwnd;
TrackMouseEvent(&tme);
_isTracking = true;
}
if (_mouseLeft)
{
// MOUSE OVER ACTION
if (!_isDisabled && _hoverStateBitmap)
SendMessage(_hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) _hoverStateBitmap);
_mouseLeft = false;
}
if (!_isDisabled)
SetCursor(LoadCursor(NULL, IDC_HAND));
}
示例11: sizeof
LRESULT CDreamSkinSpinCtrl::OnMouseMove(UINT nFlags, POINTS point)
{
TRACKMOUSEEVENT EventTrack;
EventTrack.cbSize = sizeof(TRACKMOUSEEVENT);
EventTrack.dwFlags = TME_LEAVE;
EventTrack.hwndTrack = m_hWnd;
EventTrack.dwHoverTime = 0;
TrackMouseEvent(&EventTrack);
POINT pt;
pt.x = point.x;
pt.y = point.y;
DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
RECT rcClient;
::GetClientRect(m_hWnd, &rcClient);
int nHover = SpinCtrlHitTest(rcClient, pt, dwStyle);
if (m_nHover != nHover)
{
m_nHover = nHover;
::InvalidateRect(m_hWnd, &rcClient, FALSE);
}
return 0;
}
示例12: switch
LRESULT CALLBACK ImagedButton::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
ImagedButton *_this = (ImagedButton *)GetWindowLong(hWnd, GWL_USERDATA);
switch (message) {
case WM_LBUTTONDBLCLK:
PostMessage(hWnd, WM_LBUTTONDOWN, wParam, lParam);
break;
case WM_MOUSEMOVE:
if (!_this->m_mouseOver) {
_this->m_mouseOver = true;
TRACKMOUSEEVENT evt;
evt.cbSize = sizeof(evt);
evt.dwFlags = TME_LEAVE;
evt.dwHoverTime = HOVER_DEFAULT;
evt.hwndTrack = hWnd;
_this->invalidate();
TrackMouseEvent(&evt);
}
break;
case WM_MOUSELEAVE:
_this->m_mouseOver = false;
_this->invalidate();
break;
}
return CallWindowProc((WNDPROC)_this->m_defWindowProc, hWnd, message, wParam, lParam);
}
示例13: switch
LRESULT Window::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch(message) {
case(WM_CREATE):{
Window* w = reinterpret_cast<Window*>(((LPCREATESTRUCT)lParam)->lpCreateParams);
SetWindowLongPtr(hWnd,GWL_USERDATA,reinterpret_cast<long>(w));
}break;
case(WM_DESTROY): {
PostQuitMessage(0);
forceQuit = true;
}break;
case (WM_ACTIVATE): {
if(LOWORD(wParam) == WA_INACTIVE) {
ReleaseCapture();
ClipCursor(NULL);
if (hasInit) {
Mouse::instance->Sleep();
Mouse::instance->Sleep();
}
}
else{
if(hasInit) {
Mouse::instance->Wake();
Mouse::instance->Wake();
}
}
return 0;
}break;
case (WM_LBUTTONDOWN): {
}break;
case (WM_MOUSEMOVE): {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = windowHandle;
TrackMouseEvent(&tme);
}break;
case(WM_SIZE): {
screenWidth = LOWORD(lParam);
screenHeight = HIWORD(lParam);
Resize();
}break;
case(WM_SETFOCUS) : {
if (hasInit) {
Mouse::instance->Wake();
Mouse::instance->Wake();
}
}break;
case(WM_KILLFOCUS) : {
if (hasInit) {
Mouse::instance->Sleep();
Mouse::instance->Sleep();
}
}break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
示例14: sizeof
void TabBarPlus::trackMouseEvent(DWORD event2check)
{
TRACKMOUSEEVENT tme = {};
tme.cbSize = sizeof(tme);
tme.dwFlags = event2check;
tme.hwndTrack = _hSelf;
TrackMouseEvent(&tme);
}
示例15: trackMouse
static void trackMouse()
{
TRACKMOUSEEVENT track_event;
track_event.cbSize = sizeof(TRACKMOUSEEVENT);
track_event.dwFlags = TME_LEAVE;
track_event.hwndTrack = g_platform_data.m_hwnd;
g_platform_data.m_is_mouse_tracked = TrackMouseEvent(&track_event) == TRUE;
}