I wonder why Buttons always have to display that black border around them when they get pushed the first time. After the second push they become normal again. (view attachment)

Is there any way to get around this behavior?

TIA,
Jimmy
Posted on 2002-07-25 19:29:00 by JimmyClif
I always specify WS_EX_STATICEDGE on the extended styles for my buttons.
Posted on 2002-07-25 19:41:59 by stryker
I tried that last night including (WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE) but all those also gave it a black border after the first push. :(

edit: It looks like an ON/OFF feature thing. First push turns it ON (black border) and the second turns it OFF (restore to normal).
Posted on 2002-07-25 19:46:26 by JimmyClif
If your using a resource file try removing all the attributes.

If using CreateWindow?? try specifying WS_CHILD + WS_VISIBLE on the styles and WS_EX_STATICEDGE on the extended styles.
Posted on 2002-07-25 19:53:23 by stryker
I use those styles but still the same on a Window :grin:

Actually I narrowed it down to WM_COMMAND !
If I don't intercept it at all, the Buttons act just like I want them to. If I intercept it they do this on/off thing.

I realized this when I pasted my code for the buttons into an empty template and they worked exactly as I wanted. (At first this left me clueless but as soon as I intercepted WM_COMMAND those ^%##%^$ did it again.
Posted on 2002-07-25 21:19:42 by JimmyClif
Here I post some code, for you to see for yourself ;)

Just dump this code into a 250,250 Window.

Compile it and try out the Button (which does nothing as the WM_COMMAND is all commented out) then manually select the Edit window.. You see that the Button looses the pushed state.

Then uncomment the WM_COMMAND area which (all it does is set the focus to the edit window) compile it and you?ll see that the Button keeps the pushed state (black border)




a$ TEXTEQU <ADDR>
o$ TEXTEQU <OFFSET>

.data
MButtonClass db "BUTTON",0
MEditClass db "EDIT",0
.data?
hSave dd ?
hEdit dd ?
.const
IDC_SAVE equ 137

.code

WndProc proc hwnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.IF uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_STATICEDGE,o$ MButtonClass,sadd("Push Me"),\
BS_PUSHBUTTON or WS_CHILD or WS_VISIBLE,15,20,89,20,\
hwnd,IDC_SAVE,hInstance,0
mov hSave,eax

invoke CreateWindowEx,WS_EX_CLIENTEDGE,o$ MEditClass,0,\
ES_MULTILINE or ES_LEFT or ES_WANTRETURN or WS_CHILD or \
WS_VISIBLE or ES_AUTOVSCROLL or WS_VSCROLL,\
15,90,200,100,hwnd,0,hInstance,0
mov hEdit,eax

; .ELSEIF uMsg==WM_COMMAND
; mov eax,wParam
; invoke SetFocus,hEdit

.ELSEIF uMsg==WM_CLOSE
invoke ExitProcess,NULL

.ELSE
invoke DefWindowProc,hwnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret

WndProc endp


Thanks for all the help
Posted on 2002-07-25 21:59:32 by JimmyClif
Well, I kinda gave it up trying to figure out which styles it changes on a push. So I decided to toy around with ownerdrawn buttons instead.

Anyway.. if someone ever figured out what I meant by this thread and even knows an answer it'd surely be appreciated.

:grin:
J
Posted on 2002-07-27 21:40:05 by JimmyClif
I'm not following the code you've posted but how come mine doesn't behave like that even If I handle the WM_COMMAND message. I just quickly modified ICZ tut #9.
Posted on 2002-07-27 21:55:59 by stryker