Skip to content
DarkKaiser의 블로그
DarkKaiser의 블로그
  • 개발 관련 자료(노션)
  • Raspberry Pi(노션)
  • WD My Cloud(노션)
  • GitHub
DarkKaiser의 블로그

_TrackMouseEvent

DarkKaiser, 2010년 3월 30일2023년 9월 5일

– SetCapture() 함수처럼 마우스 이벤트를 추적할 수 있도록 해줍니다. 그러나 동작 원리를 놓고 보면 두 함수는 너무나 다른 함수입니다. 마우스가 자신의 윈도우 영역을 벗어났음을 감지하는 방법에서, SetCapture() 함수는 응용 프로그램 자신이 직접 마우스를 점유하고 계속 마우스 메시지를 수신하여 경계를 벗어났는지 검사하지만, _TrackMouseEvent() 함수는 운영체제에 자신의 윈도우를 등록하여 마우스가 자신의 영역을 벗어나면 메시지(WM_MOUSELEAVE)를 수신하여 경계가 벗어났음을 판단합니다.

 
– VS2008에서 WM_MOUSELEAVE 메시지에 대한 핸들러를 자동으로 추가하실 수 있습니다.
 
Return code Description
Message

Meaning

WM_NCMOUSEHOVER

Windows 98/Me, Windows 2000/XP: The same meaning as WM_MOUSEHOVER except this is for the nonclient area of the window.

WM_NCMOUSELEAVE

Windows 98/Me, Windows 2000/XP: The same meaning as WM_MOUSELEAVE except this is for the nonclient area of the window.

WM_MOUSEHOVER

The mouse hovered over the client area of the window for the period of time specified in a prior call to TrackMouseEvent. Hover tracking stops when this message is generated. The application must call TrackMouseEvent again if it requires further tracking of mouse hover behavior.

WM_MOUSELEAVE

The mouse left the client area of the window specified in a prior call to TrackMouseEvent. All tracking requested byTrackMouseEvent is canceled when this message is generated. The application must call TrackMouseEvent when the mouse reenters its window if it requires further tracking of mouse hover behavior.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

TrackMouseEventW (Unicode)
===================
// 샘플코드
void CSkinButton::CheckHover()
{
  if (!IsWindowEnabled())
    return;

  TRACKMOUSEEVENT EventTrack1, EventTrack2;
  EventTrack1.cbSize = sizeof(TRACKMOUSEEVENT);
  EventTrack1.dwFlags = TME_HOVER;
  EventTrack1.hwndTrack = m_hWnd;
  EventTrack1.dwHoverTime = 10;

  _TrackMouseEvent(&EventTrack1);

  EventTrack2.cbSize = sizeof(TRACKMOUSEEVENT);
  EventTrack2.dwFlags = TME_LEAVE;
  EventTrack2.hwndTrack = m_hWnd;
  EventTrack2.dwHoverTime = 0;

  _TrackMouseEvent(&EventTrack2);
}

void CSkinButton::OnMouseMove(UINT nFlags, CPoint point)
{
  CheckHover();

  CButton::OnMouseMove(nFlags, point);
}
C/C++/VC++

글 내비게이션

Previous post
Next post

답글 남기기 응답 취소

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

최신 글

  • AssertJ 소개testCompile ‘org.assertj:assertj-core:3.6.2’ 2017년 9월 14일
  • 자주 사용되는 Lombok 어노테이션 2017년 9월 14일
  • 유니코드 #3 2017년 9월 14일
  • 유니코드 #2 2017년 9월 14일
  • 유니코드 #1 2017년 9월 14일

최신 댓글

    카테고리

    • 개인 자료 (1)
      • 일기 (1)
    • 주절주절 (7)
    • 프로그래밍 갤러리 (16)
    • 프로그래밍 언어 (186)
      • Java (29)
      • C/C++/VC++ (114)
      • C# (11)
      • Visual Basic (6)
      • 안드로이드 (9)
      • Objective-C (5)
      • JavaScript (4)
      • JSP/Servlet (2)
      • Python (4)
      • 어셈블러 (1)
    • 개발++ (44)
      • Book (11)
        • Joel On Software (10)
      • 프로젝트 관리 (6)
      • Maven (1)
      • 디버깅 (1)
      • DirectX (1)
      • Silverlight (1)
      • RESTful (1)
      • Hacking (1)
      • WDM (4)
      • VoIP (5)
      • 기타 (1)
    • 개발 도구 (15)
      • eclipse (14)
      • Sublime Text (1)
    • 네트워크 (7)
    • 설치 및 배포 (7)
      • InstallShield (2)
      • NSIS (4)
    • 버전 관리 (9)
      • Git (2)
      • CVS (2)
      • Subversion (5)
    • 데이터베이스 (7)
      • Oracle (3)
      • Sybase (2)
      • MS-SQL (2)
    • 단위테스트 (3)
      • JUnit (1)
      • NUnit (2)
    • 버그추적시스템 (2)
      • mantis (2)
    • 운영체제 (7)
      • Windows (5)
      • 리눅스 (2)
    • WAS (3)
      • WebLogic (3)
    • 디자인패턴 (1)
    • 디지털 이미지 프로세싱 (16)

    태그

    Abstract ActiveX AfxParseURL Automation boost devenv.exe event EventLogTraceListener Hover interface IO iTextSharp JAD jar JavaScript Joel Leave MFC Monitor msdev.com MSDN mutable PDF Properties RAW Saturation SHGetFolderPath SHGetKnownFolderPath SQLite STLTask String TextWriterTraceListener URL VI 권한 데이터소스 디컴파일러 문자열 스레드 동기화 스레드 생성 실용주의 프로그래머 자동화 테스팅 파일포맷 프리컴파일

    메타

    • 로그인
    • 엔트리 피드
    • 댓글 피드
    • WordPress.org
    ©2025 DarkKaiser의 블로그 | WordPress Theme by SuperbThemes