coda
Junior Member
Posts: 74
|
Post by coda on Oct 1, 2021 10:55:16 GMT -5
I feel I have asked this question before years ago when I was more of a regular on the old forum but I have forgotten the answer and could find nothing on it searching the new forum. Maybe doing the searching wrong. Disabling and enabling groupboxes using: #main.mygroupbox, "!disable" & #main.mygroupbox, "!enable" appears not to work... Is this a known issue? If so, is there a workaround? Thanks in advance for your assistance.
|
|
|
Post by Brandon Parker on Oct 1, 2021 13:04:00 GMT -5
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Oct 1, 2021 13:37:01 GMT -5
Thanks, Brandon. That's definitely the issue I'm talking about. It's not my post though. I've always been Coda even on the old forum. Maybe I'm wrong that I've enquired previously but I feel there was another solution not mentioned in this thread. I might be wrong... Is there a stylebits or API call solution?
|
|
|
Post by metro on Oct 1, 2021 21:13:51 GMT -5
Brandon's code from the old site , not sure if is what you are after... I could not see any reference to coda in any of the posts, just Anatoly, Brandon , Rod and Chris.
Re: GROUPBOX enable/disable « Reply #1 on: Nov 14th, 2017, 7:06pm »
' Form created with the help of Freeform-J v.261006 ' Generated on Nov 13, 2017 at 16:45:09
nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #main.groupbox1, "GroupBox Caption", 26, 16, 208, 176 groupbox #main.groupbox3, "GroupBox Caption", 26, 195, 203, 161 radiobutton #main.radiobutton4, "RadioButton Caption", [radiobutton4Set], [radiobutton4Reset], 37, 43, 168, 20 radiobutton #main.radiobutton5, "RadioButton Caption", [radiobutton5Set], [radiobutton5Reset], 38, 67, 168, 20 radiobutton #main.radiobutton6, "RadioButton Caption", [radiobutton6Set], [radiobutton6Reset], 40, 226, 168, 20 radiobutton #main.radiobutton7, "RadioButton Caption", [radiobutton7Set], [radiobutton7Reset], 39, 247, 168, 20 button #main.button8, "enable", [button8Click], UL, 317, 27, 122, 25 button #main.button9, "disable", [button9Click], UL, 317, 74, 122, 25 open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
[radiobutton4Set] 'Perform action for the radiobutton named 'radiobutton4' 'Insert your own code here wait
[radiobutton4Reset] 'Perform reset for the radiobutton named 'radiobutton4' 'Insert your own code here wait
[radiobutton5Set] 'Perform action for the radiobutton named 'radiobutton5' 'Insert your own code here wait
[radiobutton5Reset] 'Perform reset for the radiobutton named 'radiobutton5' 'Insert your own code here wait
[radiobutton6Set] 'Perform action for the radiobutton named 'radiobutton6' 'Insert your own code here wait
[radiobutton6Reset] 'Perform reset for the radiobutton named 'radiobutton6' 'Insert your own code here wait
[radiobutton7Set] 'Perform action for the radiobutton named 'radiobutton7' 'Insert your own code here wait
[radiobutton7Reset] 'Perform reset for the radiobutton named 'radiobutton7' 'Insert your own code here wait
[button8Click] 'Perform action for the button named 'button8' #main.groupbox1 "enabled" #main.groupbox1 "!enable" wait
[button9Click] 'Perform action for the button named 'button9' #main.groupbox1 "disabled" '#main.groupbox1 "!disable" Notice EnableWindow(Hwnd(#main.groupbox1), 0) #main.groupbox1 "Didn't Update Text" wait
Function EnableWindow(hWnd, bEnable) CallDLL #user32, "EnableWindow", hWnd As long, _ bEnable As long, _ EnableWindow As long End Function
|
|
|
Post by Brandon Parker on Oct 1, 2021 21:20:36 GMT -5
Here is a super-easy example that simply displays the GroupBox with no text, adds a StaticText where the GroupBox's child StaticText would normally be displayed and changes its parent to the GroupBox (not really required..., but if you move the GroupBox... ), and ties the Enabling/Disabling of the new StaticText to the Enabling/Disabling of the two RadioButton controls inside the GroupBox. That last one is something I just figured most people "want" to do when Enabling/Disabling a GroupBox. I was going to work on an API solution, but it required WMLiberty.dll. It is also cumbersome and painful because Microsoft messed their stuff up... This is WAY easier!! NoMainWin
Global False : False = 0 Global True : True = 1 Global enabled : enabled = True
Button #Main.btnToggle, "Enabled", toggle, UL, 10, 15, 75, 25 RadioButton #Main.rdBtn1, "Radio 1", radioButtonDoNothing, radioButtonDoNothing, 10, 60, 75, 25 RadioButton #Main.rdBtn2, "Radio 2", radioButtonDoNothing, radioButtonDoNothing, 10, 80, 75, 25 GroupBox #Main.gpBox, "", 5, 45, 100, 65 StaticText #Main.gpBoxStatic, "GroupBox", 10, 0, 50, 15 Open "Testing GroupBox" For Window As #Main #Main "TrapClose Quit"
result = SetParent(Hwnd(#Main.gpBoxStatic), Hwnd(#Main.gpBox))
Wait
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub Quit handle$ Close #handle$ End End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub toggle handle$ If enabled Then #Main.btnToggle "Disabled" #Main.gpBoxStatic "!Disable" #Main.rdBtn1 "Disable" #Main.rdBtn2 "Disable" Else #Main.btnToggle "Enabled" #Main.gpBoxStatic "!Enable" #Main.rdBtn1 "Enable" #Main.rdBtn2 "Enable" End If enabled = Abs(Not(enabled)) End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub radioButtonDoNothing handle$
End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function SetParent(hChild, hNewParent) CallDLL #user32, "SetParent", hChild As ulong, _ hNewParent As ulong, _ SetParent As ulong End Function Here is a second example that shows how the RadioButtons and the StaticText move with the GroupBox when it is set to be their parent control. NoMainWin
Global False : False = 0 Global True : True = 1 Global enabled : enabled = True
Button #Main.btnToggle, "Enabled", toggle, UL, 10, 15, 75, 25 RadioButton #Main.rdBtn1, "Radio 1", radioButtonDoNothing, radioButtonDoNothing, 10, 15, 75, 25 RadioButton #Main.rdBtn2, "Radio 2", radioButtonDoNothing, radioButtonDoNothing, 10, 35, 75, 25 GroupBox #Main.gpBox, "", 5, 45, 100, 65 StaticText #Main.gpBoxStatic, "GroupBox", 10, 0, 50, 15 Open "Testing GroupBox" For Window As #Main #Main "TrapClose Quit"
result = SetParent(Hwnd(#Main.gpBoxStatic), Hwnd(#Main.gpBox)) result = SetParent(Hwnd(#Main.rdBtn1), Hwnd(#Main.gpBox)) result = SetParent(Hwnd(#Main.rdBtn2), Hwnd(#Main.gpBox))
result = MoveWindow(Hwnd(#Main.gpBox), 50, 50, 100, 65, True) Wait
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub Quit handle$ Close #handle$ End End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub toggle handle$ If enabled Then #Main.btnToggle "Disabled" #Main.gpBoxStatic "!Disable" #Main.rdBtn1 "Disable" #Main.rdBtn2 "Disable" Else #Main.btnToggle "Enabled" #Main.gpBoxStatic "!Enable" #Main.rdBtn1 "Enable" #Main.rdBtn2 "Enable" End If enabled = Abs(Not(enabled)) End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub radioButtonDoNothing handle$
End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function SetParent(hChild, hNewParent) CallDLL #user32, "SetParent", hChild As ulong, _ hNewParent As ulong, _ SetParent As ulong End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function Have fun with this!! {:0) Brandon Parker
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Oct 3, 2021 4:02:32 GMT -5
Oh wow! Thankyou metro guru! Thankyou very much, Brandon. That is exactly what I'm wanting to do! As I say, I feel I have done this before (after consultation with forum members) but I can't find any examples of it in my old code which is weird. ...and I'm sure this is probably how I would have done it before if I did. Maybe I'm having some kind of weird personal Mandela effect and I'm not in the same universe I used to be in lolololololol. Anyway, thanks so much again for your knowledgeable assistance. I can procced with confidence now.
|
|