PDA

View Full Version : Disable buttons when not needed



Arucard
03-13-2004, 11:40 PM
What I want to do sounds simple enough but I can't seem to get it to work. What I have is three options. Install, Run, and Quit.

Quit runs fine, but it's the other two I'm having problems with.

I want Install to only be active if the program isn't installed, and I want run to only be activated when the program is installed. So of course I want this to take effect as soon as the screen appears.

Problem is although it may sound really simple I can't seem to get it to work. I've tried using installed = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\company name\\program name")
to store the detect if the program is installed since it'll leave it's reg key in there if it's installed. But no matter what I do from there I have no luck. Any ideas? or an easier way? Thanx

Worm
03-14-2004, 03:01 PM
Its hard to guess what you are doing from one line of code. The line you posted certainly would look to see if it was installed, but what are you doing with the variable's value after you check? Can you share a bit more of your code?

Arucard
03-15-2004, 02:25 AM
Well, I tried to follow it with this (run is disabled by default by the way) but nothing happens.

if installed then
Button.SetEnabled("INSTALL", false);
Button.SetEnabled("RUN", true);
end

Worm
03-15-2004, 07:30 AM
here's a sample I threw together...

Arucard
03-15-2004, 03:48 PM
Thank you for taking the time to create that sample.
From what I can tell my code works, I just can't get it to start up when the project starts up (even though my code is set in On Startup).

I know it works because if I add the code to the button in the On Enter and rest my cursor on that button, my code work out properly. So it looks like my problem is getting my code to run automatically when the program starts up. Any ideas?

Worm
03-15-2004, 03:53 PM
There is nothing to do to get it to run at Startup except for put the code in the On Startup as you've stated.

The only other thing I can think of would be security. Do you have rights to read and write to the HKLM portion of the registry?

Arucard
03-15-2004, 03:54 PM
Fix the problem, I discovered the On Show section which is just what I needed for the code. Thanks for the help though :)