Sorry if this is already answered but i spent time with search and didnt find any satifying answer :rolleyes:

in my program i have a bitmap button and when mouse is above the button it should look like its pressed down(only look) and play a little wav, i try to use the BmpButton from masm32 lib but that isnt working, it seems it works only on up/down. any ideas how to 'fix' this ? im a newbie so please explain in detail

thanks
/yours Noobe
Posted on 2002-06-18 20:05:32 by Noobe
you can try processing WM_MOUSEMOVE
When the mouse is within the confines of your button then repaint the button with another bitmap when it leaves replace the original bitmap..
Posted on 2002-06-19 02:49:33 by MArtial_Code
I have seen an intesting example of a bitmap button...
IIRC, it was from a guy of the P.Crew team...
It seems that it is what you want...
I'm currently at work, but if you are patient enough, I will probably find the sample when I will go back to home (it also supports disabled state, by the way) but perhaps you can find it by "googling".
Posted on 2002-06-19 02:57:31 by JCP
I wrote a Outlook bar control, wich does exactly what you want:



[...]
.data
[...]
szStaticClass db "STATIC", 0
[...]
.data?
[...]
rOutbox RECT <?>
[...]
.code
[...]
.if uMsg == WM_CREATE

invoke SetTimer, hWin, 11, 10, 0 ; set timer
[...]
invoke CreateWindowEx, 0, addr szStaticClass, addr szOutbox,
WS_CHILD or WS_VISIBLE or SS_CENTERIMAGE or SS_NOTIFY or SS_BITMAP, 0, 100, 96, 75, hCtl, OB_OUTBOX, 400000h, 0
mov hOutbox, eax

invoke LoadBitmap, 400000h, 103
invoke SendMessage, hOutbox, STM_SETIMAGE, IMAGE_BITMAP, eax
[...]
.elseif uMsg == WM_TIMER
invoke GetWindowRect, hOutbox, addr rOutbox
[...]
invoke GetCursorPos, addr pt ; get cursor position
[...]
invoke PtInRect, addr rOutbox, pt.x, pt.y

.if (eax)
invoke MouseOver, hOutbox
.else
invoke MouseOut, hOutbox
.endif
[...]
MouseOver proc hCtl :DWORD
invoke GetWindowLong, hCtl, GWL_EXSTYLE ; get extended style
.if (!(eax & WS_EX_CLIENTEDGE)) ; if WS_EX_CLIENTEDGE is not set (this check prevents flickering) ----+
push edi
mov edi, eax ; |
mov eax, WS_EX_CLIENTEDGE ; |
or eax, edi ; |
invoke SetWindowLong, hCtl, GWL_EXSTYLE, eax ; set it <-------------------------------------------|
invoke SetWindowPos, hCtl, 0, 0, 0, 0, 0, ; redraw window
SWP_NOSIZE or SWP_NOMOVE or \
SWP_NOZORDER or SWP_NOACTIVATE or \
SWP_FRAMECHANGED
pop edi
.endif
ret
MouseOver endp
[...]
MouseOut proc hCtl :DWORD
invoke GetWindowLong, hCtl, GWL_EXSTYLE ; get extended style
.if (eax & WS_EX_CLIENTEDGE) ; check if style is set (prevents flickering, too)
and eax, not WS_EX_CLIENTEDGE ; if yes, then remove it
invoke SetWindowLong, hCtl, GWL_EXSTYLE, eax ; store it
invoke SetWindowPos, hCtl, 0, 0, 0, 0, 0, ; redraw window
SWP_NOSIZE or SWP_NOMOVE or \
SWP_NOZORDER or SWP_NOACTIVATE or \
SWP_FRAMECHANGED
.endif
ret
MouseOut endp
[...]


Hope this helps!
If you have any questions, feel free to ask :)
Posted on 2002-06-19 03:04:58 by bazik
Ooops, forgot the code wich handles the click events:



[...]
.elseif uMsg == WM_COMMAND
mov eax, wParam
shr eax, 16 ; get loword of wParam

.if eax == STN_CLICKED ; if loword is STN_CLICKED
[...]
.elseif wParam == OB_OUTBOX
invoke MessageBox, 0, addr szOutbox, addr szAppName, 0
[...]
Posted on 2002-06-19 03:07:29 by bazik
Readiosys - thanks would be great if you found it, might be just what i need


bAZiK - thanks i will look at this code and try to understand it ;)

this board is great i post in the night and when i wake up there are some answers to my questions. thanks alot guys
Posted on 2002-06-19 08:18:12 by Noobe
Sorry for the delay, I had some work to finish before...
Here is the example...
Posted on 2002-06-22 16:01:30 by JCP
What's the difference between returning TRUE and returning FALSE when processing the WM_ERASEBKGND message?

I don't see any visible difference even if I also add an empty WM_PAINT case (containing just BeginPaint/EndPaint).
Posted on 2002-06-24 04:23:33 by grv575
The win32 hlp file states

An application should return nonzero in response to WM_ERASEBKGND if it processes the message and erases the background; this indicates that no further erasing is required. If the application returns zero, the window will remain marked for erasing. (Typically, this indicates that the fErase member of the PAINTSTRUCT structure will be TRUE.)

So there is the reason

:alright:
Posted on 2002-06-24 21:21:37 by IwasTitan
Oh so it only sets the erase flag of the ps to true but doesn't really erase the background. So I guess there is no difference unless you use this flag to determine when to manually erase the background in wm_paint.
Posted on 2002-06-24 22:44:09 by grv575
I think that returning FALSE or TRUE gives the application more control depending on what you are doing with client are. If you erased the background and returned zero you still have the ability to affect the client area without calling another api function for the client area.
:alright:
Posted on 2002-06-24 23:13:12 by IwasTitan