Prolly already asked several times..
but i tried it myself with some code i had and i dont want to just copy now some code from another prog.

Im Loading several Image Files on my Window....
Now when im Over the Button with my Mousepointer i want to change the Image....
When im off it should change back again. prolly pretty simple :).

So...

I started the following way:

( for better understanding i only past the code for one button ):

[...]
.IF uMsg == WM_CREATE
[...]
invoke CrWindowEx,hWnd,10,130,0,0,CMD_RUN
mov hButton1, eax
invoke BitmapFromResource, hInstance, 303
invoke SendMessage, hButton1, STM_SETIMAGE, IMAGE_BITMAP, eax
[...]

CrWindowEx loads a Procedure with the invoke CreateWindowEx API.
So this part loads and shows the image.

[...]
Invoke SetTimer, hWnd, TIMER_ID2, TIME_INT2, NULL
[...]

The Timer...

[...]
.ELSEIF uMsg == WM_TIMER
[...]
invoke GetCursorPos, addr pt
invoke GetWindowRect, hButton1, addr rButton1
cmp eax,0
je @F

invoke PtInRect, addr rButton1, pt.x, pt.y

.if (eax)
invoke MouseOver, hButton1
.endif
@@:

invoke GetWindowRect, hButton2, addr rButton2
cmp eax,0
je @F

invoke PtInRect, addr rButton2, pt.x, pt.y

.if (eax)

.else
invoke MouseOut, hButton2
.endif
@@:
[...]

The Mouse gets over the first Button -> Start Mousover,...
The Mouse gets over the new (second) Button -> Start Mouseout,...

[...]
MouseOver proc uses edi hCtl :DWORD

mov eax, hCtl

.IF eax == hButtonRun

.IF iiii == 0
Invoke DestroyWindow, hCtl
invoke CrWindowEx,hWndtr,10,130,0,0,CMD_RUN
mov hButton2, eax
invoke BitmapFromResource, hInstance, 306
invoke SendMessage, hButton2, STM_SETIMAGE, IMAGE_BITMAP, eax
inc iiii
.ENDIF

.ENDIF

ret

MouseOver endp
[...]

The First Button gets destroyed (DestroyWindow). Then the new one gets created.
I dont know if MouseOver gets executed all the time when my mouse is over the area so i set a if check that it only gets executed once. When the Mousepointer is going out of the area 'iiii' gets decreased back again.

[...]
MouseOut proc hCtl :DWORD

mov eax, hCtl

.IF eax == hButton2

.IF iiii == 1
Invoke DestroyWindow, hCtl
invoke CrWindowEx,hWndtr,10,130,0,0,CMD_RUN
mov hButton, eax
invoke BitmapFromResource, hInstance, 303
invoke SendMessage, hButton, STM_SETIMAGE, IMAGE_BITMAP, eax
dec iiii
.ENDIF

.ENDIF

ret

MouseOut endp
[...]
Ok here the new Window gets destroyed and the Old one created again.

I also tried once in MouseOver just to create the new one over the same area and in MouseOut just to delete the new one.

But however i do it i never get a fine result. Its workin very ..mh..slow..'un'nice ;).. for some secs and then both windows seem to get deleted....

Can somebody give me a better solution or a tipp what i should change that it is workin properly.?
Posted on 2003-05-13 12:46:06 by Cenox
Cenox,

the way I've done it, is to not use a timer, but to use SetCapture() to capture msg's to stay with target rect and then ck PtInRect() to see if mouse has left rect, to redraw original and then call ReleaseCapture to resume, else if mouse move to fast, the target rect may never get repainted...

Brad
Posted on 2003-05-18 11:01:58 by Brad
mh..
can u give some pice of code as an example..
still dont have it fully workin.
Posted on 2003-05-20 07:23:26 by Cenox
Cenox,

I use PowerBASIC, so code is slightly different,
but, I'm guessing

.IF uMsg == WM_MOUSEMOVE
invoke SetCapture hwnd

invoke GetCursorPos, addr pt
invoke GetWindowRect, hButton1, addr rButton1
cmp eax,0
je @F

invoke PtInRect, addr rButton1, pt.x, pt.y

.if (eax)

;Do your stuff_________________
; ie. invoke MouseOver, hButton1
;___________________________

.else

;undo your stuff_________________

invoke ReleaseCapture

.endif
@@:
Posted on 2003-05-20 10:52:30 by Brad
thanks for the code..

i can run my exe file but when ive edited it the way u told me to i cant see my main window anymore :/
Posted on 2003-05-21 10:34:41 by Cenox
Cenox,

It seems that no one is helping out much... :)
likely because it's hard to know whats going wrong w/o seeing your code...
also, you may want to ask at Hutch's new Masm32 forum: at:
http://masmforum.com ...

Brad
Posted on 2003-05-21 20:47:19 by Brad
Hi all,

What about TrackMouseEvent API ???
Posted on 2003-05-22 02:13:17 by PhoBos