how do I tell when a mouse is over a control on a dialog window?

BTW I coded all the below all by myself, I feel like a programmer lol.. tomorrow I will attempt to condense drawpal into a single loop. Note.. I used the backDC to point to another bitmap so I don't overuse the DC's per Donkey's suggestions, help, and advice..




.elseif eax==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke drawpal,backDC,palBM
invoke BitBlt,hdc,3,315,60,85,backDC,0,0,SRCCOPY
invoke SelectObject,backDC,backBM
invoke BitBlt,hdc,72,4,639,557,backDC,0,0,SRCCOPY
invoke EndPaint,hWnd, ADDR ps
invoke ReleaseDC,hWnd,hdc
.elseif eax==WM_CLOSE

***and***

drawpal PROC BDC:DWORD,BBM:DWORD
LOCAL x:DWORD
LOCAL y:DWORD
LOCAL clr:BYTE
LOCAL vclr:DWORD
LOCAL SDC:DWORD

mov x,0
mov y,0
mov clr,255
invoke SelectObject,BDC,BBM
mov eax,SDC
bloop:

RGB clr,0,0
push eax
pop vclr

invoke drawrect,BDC,x,y,15,y,vclr
inc y
sub clr,3
cmp y,85
jne bloop


mov x,16
mov y,0
mov clr,255
bloop2:

RGB 0,clr,0
push eax
pop vclr

invoke drawrect,BDC,x,y,15,y,vclr
inc y
sub clr,3
cmp y,85
jne bloop2


mov x,32
mov y,0
mov clr,255
bloop3:

RGB 0,0,clr
push eax
pop vclr

invoke drawrect,BDC,x,y,15,y,vclr
inc y
sub clr,3
cmp y,85
jne bloop3

mov x,48
mov y,0
mov clr,255
bloop4:

RGB clr,clr,clr
push eax
pop vclr

invoke drawrect,BDC,x,y,15,y,vclr
inc y
sub clr,3
cmp y,85
jne bloop4

invoke SelectObject,BDC,SDC
ret
drawpal endp
Posted on 2003-09-11 04:45:38 by drarem
The control will receive WM_MOUSEMOVE messages throught its' wndproc. You could also consider setting up and trapping the WM_MOUSEHOVER message.
Posted on 2003-09-11 06:25:36 by sluggy
Thanks, I'll research that.. isn't that the new .NET stuff with mousehover?

Slightly optimized..



drawpall PROC BDC:DWORD,BBM:DWORD

;Usage: invoke drawpall,someDC,someBMP - use temporary dc to select into it
LOCAL y:DWORD
LOCAL clr:BYTE
LOCAL SDC:DWORD

mov y,0
mov clr,255
invoke SelectObject,BDC,BBM
mov eax,SDC
bloop:

RGB clr,0,0
invoke drawrect,BDC,0,y,15,y,eax
shl eax,8
invoke drawrect,BDC,16,y,15,y,eax
shl eax,8
invoke drawrect,BDC,32,y,15,y,eax
RGB clr,clr,clr
invoke drawrect,BDC,48,y,15,y,eax

inc y
sub clr,3 ; for clr=255 to 0 step 3 (total equiv. = 85 colors)
cmp y,85 ; ok for my purposes
jne bloop

invoke SelectObject,BDC,SDC
ret
drawpall endp
Posted on 2003-09-11 12:23:52 by drarem

Thanks, I'll research that.. isn't that the new .NET stuff with mousehover?

Nope, I posted an example here, it will not work in Win95 but all others are supported.
Posted on 2003-09-11 13:10:31 by donkey
thanks but I took the bruteforce method.. some controls will be owner-drawn (virtual) and won't have their own dialogID, such as the palette.

try out my own personal scribble WIP: please test for memory leaks. It is 6k
http://www.web.ms11.net/drarem/ron2.exe

select the pen colors and paint away. pen size intial is 1, changed to 5 when color picked. Also, it draws on mousemove.. gotta fix that.

and is there an alternative to this or is it good nuff to do?
getmouseover PROC twin:HWND,nP:POINT,mvrc:RECT

LOCAL retv:DWORD
mov retv,0
mov eax,mvrc.right
.IF nP.x<=eax
mov eax,mvrc.left
.IF nP.x>=eax
mov eax,mvrc.top
.IF nP.y>=eax
mov eax,mvrc.bottom
.IF nP.y<=eax
mov retv,1
.elseif
.endif
.endif
.endif
.endif
mov eax,retv
getmouseover endp
Posted on 2003-09-11 14:58:52 by drarem
Hi, drarem
Perhaps the PtInRect api could help you on the code you just posted.


invoke PtInRect,addr nP,addr mvrc

That should replace your entire routine... since twin is not used for anything, and PtInRect returns FALSE when the point is not in the rect, and TRUE when it is.
Posted on 2003-09-11 17:30:27 by QvasiModo