
I have been a [few month] reader of the forums here and found quite a few snippets of code that have helped out in small programs I've written. I am a new 'user' to programming altogether, so please do not expect me to understand the latest lingo

Now, down to the problem...
I have a #PB_String_ReadOnly tag set on a String Gadget when a button is clicked, and it works without a problem, including removing the tag. The issue arises when I open a new window [and subsequently close it], and I am unable to either enable or disable the tag on the field. I have posted some quick code I assembled for the purpose of troubleshooting the cause.
Code: Select all
;{- Enumerations / DataSections
;{ Windows
Enumeration
#Window_0
#Window_1
EndEnumeration
;}
;{ Gadgets
Enumeration
#Button_0
#Button_1
#Button_2
#Button_3
#String_TestField
#String_TestField2
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure test()
If OpenWindow(#Window_1, 550, 300, 200, 200, "Window_1", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Window_1))
ButtonGadget(#Button_3, 35, 50, 110, 30, "Close")
EndIf
EndIf
SetActiveWindow(#Window_1)
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #Button_3
CloseWindow(#Window_1)
SetActiveWindow(#Window_0)
Break
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_1
CloseWindow(#Window_1)
Break
EndIf
EndSelect
ForEver
EndProcedure
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 450, 200, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Window_0))
ButtonGadget(#Button_0, 35, 50, 110, 30, "Open other window")
ButtonGadget(#Button_1, 35, 110, 110, 30, "Unlock text field")
ButtonGadget(#Button_2, 35, 170, 110, 30, "Kill")
StringGadget(#String_TestField, 125, 250, 110, 25, "",#PB_String_ReadOnly)
StringGadget(#String_TestField2, 125, 280, 110, 25, "")
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #Button_0
CreateThread(@test(),0)
ElseIf EventGadget = #Button_1
SetActiveGadget(#String_TestField)
StringGadget(#String_TestField, 125, 250, 110, 25, "TEST")
ElseIf EventGadget = #Button_2
End
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
EndProcedure
OpenWindow_Window_0()