News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Setting/Removing Window Styles

Started by travism, December 09, 2008, 09:14:24 AM

Previous topic - Next topic

travism

I use SetWindowLong to set the button to "WS_VISIBLE|WS_DISABLED", Now if i want to enable the button how to I remove WS_DISABLED? I tried just setting it to "WS_VISIBLE" but that doesn't remove the WS_DISABLED. Sorry for such a easy question but its buggin me, Thanks!

jdoe


To add or remove styles you must get the existing ones before...


invoke GetWindowLong, hWnd, GWL_STYLE
.if (eax != 0)
    xor eax, WS_DISABLED  ; and eax, not WS_DISABLED
    invoke SetWindowLong, hWnd, GWL_STYLE, eax
.endif


Maybe in your case you could just call EnableWindow, hWnd, TRUE


travism

Why would you need to get the style before you change the style? But anyways It works perfectly fine when I disable it using WS_DISABLED but then ofcourse they dont have a WS_ENABLE or whatever so they like to make it more difficult. I tried using EnableWindow but that didn't work either. Im using it on a button to see i don't know if that is the problem? I swear there was an easier way then this :\ Thanks! :)

jdoe

Quote from: travism on December 09, 2008, 11:59:30 AM
Why would you need to get the style before you change the style?


A window/control is most of the time made with many constants style. If you use SetWindowLong/GWL_STYLE with one style, you remove all the others.

It's really strange EnableWindow didn't work. Why you use WS_DISABLED when EnableWindow TRUE/FALSE is there for that. My guess is that EnableWindow do the job but it's what you did before that screw something.

Without seeing some code it's hard to help more.

Tedd

Use EnableWindow(hButton,FALSE) to disable, and EnableWindow(hButton,TRUE) to enable - don't mess with the window styles as well.
I don't think I've ever had any problems with it before, so if it's not working we'll need to see some code :wink
No snowflake in an avalanche feels responsible.

travism


invoke GetDlgItem, hDlg,IDC_BUTTON1
mov tHandle, eax

invoke EnableWindow,tHandle,FALSE


Not sure why its not working, The button just stays enabled...

BlackVortex

Quote from: travism on December 09, 2008, 01:47:47 PM

invoke GetDlgItem, hDlg,IDC_BUTTON1
mov tHandle, eax

invoke EnableWindow,tHandle,FALSE


Not sure why its not working, The button just stays enabled...
Does the API fail ?  What is the return ?

ragdog

Hi

I use this for my codes is from Winasm.net (PhoBos)

invoke EnableDlgItem,hWnd,IDC_BUTTON1,TRUE
invoke EnableDlgItem,hWnd,IDC_BUTTON2,FALSE

EnableDlgItem proc hWnd:dword,dlgItem:dword,bEnabled:dword
invoke GetDlgItem,hWnd,dlgItem
push eax
invoke EnableWindow,eax,bEnabled
pop eax
ret
EnableDlgItem endp

greets,

travism

Its returning without error, so idk whats wrong :(

ragdog

hi

I know not  ,i cannot see your code for find the mistake
have you not use the correct button id?
or the the correct window handle ?

sinsi

Have you checked that GetDlgItem returns a proper handle? If EAX=0 on return then something went wrong.
Functions return an error code for a reason...not a dig at you, but a lot of code I see doesn't check for an error.
Light travels faster than sound, that's why some people seem bright until you hear them.

Shantanu Gadgil

Quote from: ragdog on December 09, 2008, 07:05:39 PM
Hi

I use this for my codes is from Winasm.net (PhoBos)

invoke EnableDlgItem,hWnd,IDC_BUTTON1,TRUE
invoke EnableDlgItem,hWnd,IDC_BUTTON2,FALSE

EnableDlgItem proc hWnd:dword,dlgItem:dword,bEnabled:dword
invoke GetDlgItem,hWnd,dlgItem
push eax
invoke EnableWindow,eax,bEnabled
pop eax
ret
EnableDlgItem endp

greets,

Not to be nitpicky but ...
http://www.masm32.com/board/index.php?topic=5816.0
:bg :bg

Anyway, hope the code is useful!

Regards,
Shantanu
To ret is human, to jmp divine!