LB Booster
Programming >> Compatibility with LB4 >> Error setting a disabled RadioButton
http://lbb.conforums.com/index.cgi?board=compatibility&action=display&num=1390074146

Error setting a disabled RadioButton
Post by CirothUngol on Jan 18th, 2014, 6:42pm

LB Booster will hang if the program attempts to "set" a disabled RadioButton. This issue popped-up on code that I had successfully executed using a previous version of LBB, so it would seem to be a recent issue. You may test the problem using the following Code:
 NOMAINWIN
 WindowWidth = 175
 WindowHeight = 185
 GROUPBOX    #main.gb1, "    RadioButton Test    ",                10,   5, 150, 80
 RADIOBUTTON #main.rb1,    "RadioButton 1", [rb1Set], [rb1Reset],  25,  20, 100, 20
 RADIOBUTTON #main.rb2,    "RadioButton 2", [rb2Set], [rb2Reset],  25,  40, 100, 20
 RADIOBUTTON #main.rb3,    "RadioButton 3", [rb3Set], [rb3Reset],  25,  60, 100, 20
 BUTTON       #main.b1,           "Enable", [b1Click],        UL,  10,  90,  75, 25
 BUTTON       #main.b2,          "Disable", [b2Click],        UL,  90,  90,  75, 25
 BUTTON       #main.b3,           "SetRB1", [b3Click],        UL,   5, 120,  50, 25
 BUTTON       #main.b4,           "SetRB2", [b4Click],        UL,  60, 120,  50, 25
 BUTTON       #main.b5,           "SetRB3", [b5Click],        UL, 115, 120,  50, 25
 OPEN "RadioButton Test" FOR window_nf AS #main
 #main, "font ms_sans_serif 10"
 #main, "trapclose [main.quit]"

[rb1Set]
[rb1Reset]
[rb2Set]
[rb2Reset]
[rb3Set]
[rb3Reset]
 WAIT

[b1Click]
 #main.rb1, "enable"
 #main.rb2, "enable"
 #main.rb3, "enable"
 WAIT
[b2Click]
 #main.rb1, "disable"
 #main.rb2, "disable"
 #main.rb3, "disable"
 WAIT

[b3Click]
 #main.rb1, "set"
 WAIT
[b4Click]
 #main.rb2, "set"
 WAIT
[b5Click]
 #main.rb3, "set"
 WAIT

[main.quit]
 CLOSE #main
 END 

Use the buttons to enable\disable\set\reset the RadioButtons. Works in both JustBASIC v1.01 and Liberty BASIC v4.04.
Re: Error setting a disabled RadioButton
Post by Richard Russell on Jan 18th, 2014, 8:50pm

on Jan 18th, 2014, 6:42pm, CirothUngol wrote:
LB Booster will hang if the program attempts to "set" a disabled RadioButton.

It doesn't 'hang' here (LBB 2.43). What I do notice is that when you set a disabled radiobutton the others don't automatically reset (as they would when the buttons are enabled), so you end up with more than one indicated at the same time!

Quote:
it would seem to be a recent issue.

There was a problem with an early version of LBB that if you 'programmatically' set a radiobutton (using "set") the other buttons in the same group wouldn't reset. Maybe fixing that has affected your usage.

But I still can't reproduce any serious issue such as LBB 'hanging'.

Richard.

Re: Error setting a disabled RadioButton
Post by CirothUngol on Jan 18th, 2014, 11:51pm

Just upgraded LBB from 2.41 to 2.43 (thanx for the new release), but the test program still stops responding for me.
Windows XP sp3 with all updates and minimal software installed; if the RadioButtons are enabled then clicking a "SetRB#" button sets it appropriately, but does nothing when I click a "SetRB#" button if they are disabled, then goes to hourglass and "Not Responding". I'll check again on Win7 when I get that system back up.

No problem, really. I simply enable the RadioButtons before setting them and now my program works fine. Excellent utility you have here, I'm more than happy to bend with a language's odd little quirks... it's what Liberty BASIC programmers do. ^_^
Re: Error setting a disabled RadioButton
Post by Richard Russell on Jan 19th, 2014, 09:16am

on Jan 18th, 2014, 11:51pm, CirothUngol wrote:
clicking a "SetRB#" button sets it appropriately, but does nothing when I click a "SetRB#" button if they are disabled, then goes to hourglass and "Not Responding".

Strange. LBB doesn't do anything different if the button is disabled - the "set" command simply sends a BM_CLICK message, which according to MSDN "Simulates the user clicking a button":

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775985.aspx

So it almost sounds as though the 'crash' is a Windows issue. Nevertheless I'll make a note to investigate further at some point.

Meanwhile, as you say, the workaround is to send a "enable; set; disable" command sequence to change the state of a disabled radiobutton.

Edit: Confirmed crash on Windows XP, no crash on Windows 7, no crash on Windows 8.1. This is looking to be a Windows issue (Windows XP becomes unsupported by Microsoft from April).

Richard.