I'm desperately trying to get a button enabled or disabled at runtime, but it won't work. I searched the whole forum and found a dozen of threads with the same subject and I've done exactly what's said there, but the button doesn't get enabled\disabled. I'm working on Windows XP box, SP1 installed, MASM32 8.2 + RadAsm 2.0.4.2 + the last fix for it. In none of my projects I couldn't get it working. Any suggestions?



/siddhartha
Posted on 2004-05-28 19:36:05 by siddhartha
You should be able to use EnableWindow...

invoke EnableWindow, , FALSE ; False disables it,True enables it

Be sure you have the right handle,it is the handle of the button that you need.
Posted on 2004-05-28 20:00:49 by donkey
I am sure that I use the right handle. Can you then attach an example, which I can test on my system so I can realize if it is a problem of my Windows? If so I'm going to reinstall... Thanks for the reply!


/siddhartha
Posted on 2004-05-28 20:05:12 by siddhartha
It cannot be a problem with Windows, at least not one that is solved by a reinstall. This is one of the oldest API functions and if it doesn't work you don't have Microsoft Windows installed, simple as that. There can be no conceivable installation problem that will cause EnableWindow to fail.

invoke GetDlgItem, [hDlg], ID_BUTTON

invoke EnableWindow, eax, FALSE


GetLastError will return an error code telling you why it failed, maybe you should start there.
Posted on 2004-05-28 20:22:56 by donkey
Nah! It's not working... Shame on me! Isn't there another way around this?


/siddhartha
Posted on 2004-05-28 20:28:08 by siddhartha
Try this then, see if pressing toggle will enable/disable the button.
Posted on 2004-05-28 20:33:22 by donkey
It does enable\disable the button. But I have also noticed that you use GetWindowLong for the aim :) Thanks for the great support! God bless you :P


/siddhartha
Posted on 2004-05-28 20:45:36 by siddhartha
GetWindowLong only gets the current enabled status from the button so I know whether to turn it on or off for the toggle, it doesn't have anything to do with the actual EnableWindow function that I use to disable/enable the button.
Posted on 2004-05-28 22:08:49 by donkey
Maybe you're right, but when it's not there the thing doesn't work for me... Weird thing...


/siddhartha
Posted on 2004-05-28 23:58:35 by siddhartha
Well, considering that you did not post any code, I can't help you with why it is reacting that way.
Posted on 2004-05-29 00:09:38 by donkey
Ooops, the mistake is mine. It's a whole mess. It's working without GetWindowLong. Thanks again!


/siddhartha
Posted on 2004-05-29 00:22:30 by siddhartha