Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog using TrackMouseEvent
#1
If you want to detect when mouse pointer are leaving client area of dialog, or entering/leaving title bar - then use TrackMouseEvent.


\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

type TRACKMOUSEEVENT cbSize dwFlags hwndTrack dwHoverTime
dll user32 #TrackMouseEvent TRACKMOUSEEVENT*lpEventTrack
def WM_NCMOUSEHOVER 0x2A0
def WM_MOUSEHOVER 0x2A1
def WM_NCMOUSELEAVE 0x2A2
def WM_MOUSELEAVE 0x2A3

if(!ShowDialog("Dialog_TrackMouseEvent" &Dialog_TrackMouseEvent)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 273 246 "TrackMouseEvent"
;1 Button 0x54030001 0x4 160 224 48 14 "OK"
;2 Button 0x54030000 0x4 218 224 48 14 "Cancel"
;3 Edit 0x54030080 0x200 36 60 104 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010808 "" ""

ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam)
,int-- flags
,str s
,TRACKMOUSEEVENT-- tm
,tm.dwFlags=0x2 ;tm.hwndTrack=hDlg ;tm.dwHoverTime=20 ;tm.cbSize=sizeof(tm)
,TRACKMOUSEEVENT-- tc
,tc.dwFlags=0x11 ;tc.hwndTrack=hDlg ;tc.dwHoverTime=5 ;tc.cbSize=sizeof(tc)
,RECT-- r
,GdiObject-- color1 ;color1.handle=CreateSolidBrush(0x788078)
,GdiObject-- color2 ;color2.handle=CreateSolidBrush(0xbb6666)
,GetWindowRect(hDlg &r)
,siz r.right-r.left 80 hDlg
,ret 1
,
,case WM_CTLCOLORDLG ;ret iif(flags&0x8000 color2.handle color1.handle)

,case WM_MOUSEMOVE
,if flags&0x8000=0
,,TrackMouseEvent(&tm) ;flags|0x8000 ;;track for mouse leave
,,act hDlg
,,siz r.right-r.left r.bottom-r.top hDlg
,,s="MOUSE INSIDE WINDOW" ;s.setwintext(id(3 hDlg))
,case WM_MOUSELEAVE
,flags~0x8000
,TrackMouseEvent(&tc) ;;track for mouse on caption
,s="MOUSE OUTSIDE WINDOW" ;s.setwintext(id(3 hDlg))
,
,case WM_NCMOUSEHOVER
,if(wParam<4) siz r.right-r.left 80 hDlg
,
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1


Attached Files
.qml   TrackMouseEvent.qml (Size: 1.9 KB / Downloads: 674)
#2
I find this very interesting.

Can you make it so id 3 can tell you when you are over a picture in the dialog?
#3
You can define a new TRACKMOUSEEVENT and set 'hwndTrack' to handle of child window.
And then you have to call TrackMouseEvent for each new tracking.
I have found information in MSDN library.

Ok,- maybe this is not possible, but there is another way to do it - for most controls you can use WM_SETCURSOR, but i'm not shure about bitmap windows.
#4
New dialog using WM_SETCURSOR to detect when mouse pointer are over a bitmap - or any child window.
Bitmap window must have SS_NOTIFY style.


Attached Files
.qml   TrackMouseEvent2.qml (Size: 2.06 KB / Downloads: 672)
#5
WOW
When I tried that I had to give up, and you did it in a day.


Forum Jump:


Users browsing this thread: 1 Guest(s)