Hi

What message do I get when I user push a button that is created using Bmpbutton.
I tryed BN_PUSHED & BN_HILITE but it doesn't work, I simply want to run a code as long as the user keeps the button pushed, and stop when he releses the button.

Peace
Posted on 2004-02-15 19:34:33 by mistronr1
Hi,

AFAIK the bitmap button that comes with MASM32 is not a button at all, it is a custom control, so you will not get any of those messages or state flags. It only sends WM_COMMAND, nothing else, there are no flags set. You can check to see which image index is currently being displayed but that is the only way you can actually know the state of the "button". Also the mouse is captured during the press so your window will probably not get any mouse messages making it tough to do anything except rewrite the BmpButton routine to your needs.
Posted on 2004-02-16 06:45:09 by donkey
Hi mistronr1,

Depending on the application, it is usually alot easier and certainly more efficient to just use an ownerdrawn button. It requires processing the WM_DRAWITEM message and painting the button. That way you get all the normal messages and notifications but can have the button appear any way you like. Just check the button ID and draw according to the state flag. In the case below I have just drawn the normal button edges to demonstrate but you can put anything you like in the DC, text, image anything that can be drawn into a DC. Also WM_CTLCOLORBTN will work with it. If you need multiple bitmaps pass them in a structure in the GWL_USERDATA of the button.

WMDRAWITEM:

cmp W[wParam],1001
jne >>DEFPROC
mov edi,[lParam] ;DRAWITEMSTRUCT
mov eax,[edi+DRAWITEMSTRUCT.itemState]
test eax,ODS_SELECTED
jnz >.BTNDOWN
.BTNUP
mov eax,edi
add eax,DRAWITEMSTRUCT.rcItem
invoke DrawEdge,[edi+DRAWITEMSTRUCT.hdc],eax,\
EDGE_RAISED,BF_TOPLEFT+BF_BOTTOMRIGHT
invoke SetWindowLong,[hwnd],DWL_MSGRESULT,TRUE
xor eax,eax
inc eax
ret
.BTNDOWN
mov eax,edi
add eax,DRAWITEMSTRUCT.rcItem
invoke DrawEdge,[edi+DRAWITEMSTRUCT.hdc],eax,\
EDGE_SUNKEN,BF_TOPLEFT+BF_BOTTOMRIGHT
invoke SetWindowLong,[hwnd],DWL_MSGRESULT,TRUE
xor eax,eax
inc eax
ret
Posted on 2004-02-16 07:13:46 by donkey
HI D
You are so great and you allways take the time to help others.
I'll try your solution, I will be back with more questions.

Thanks alot
Peace
Posted on 2004-02-16 08:31:23 by mistronr1
Hi mistronr1,

If you need to look at an example of a multi-button owner draw with an imagelist go to my website there is one in the goasm projects section. It uses a back buffer to draw the buttons to cut out the flashing and draws 7 buttons in almost no code, it is very efficient and no messy handles or bitmaps to delete. Just one imagelist with all of the button images together (assembled with TBpaint).
Posted on 2004-02-16 09:01:31 by donkey