I get this error "Gadget object not initialized" when I resize. I know the problem must be in the callbackprocedure but I do not know enough why or how to fix it.
Here is the Code:
Code: Select all
;Created By Master Games
;Constants
;Call Back Procedure to handle gadget resizing
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_SIZE
ResizeGadget(string1, -1, -1, WindowWidth(), WindowHeight())
EndSelect
ProcedureReturn Result
EndProcedure
;Creates the Window
If OpenWindow(0, 0, 0, 300, 200, #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar, "Math Tool")
If CreateGadgetList(WindowID())
;Creates the Menu
;Creates a Popup Menu
;Creates the Gadgets
string1 = StringGadget(#PB_Any, 0, 5, 150, 15, "", #PB_String_BorderLess)
string2 = StringGadget(#PB_Any, 155, 5, 150, 15, "", #PB_String_BorderLess)
string3 = StringGadget(#PB_Any, WindowWidth()/2-50, WindowHeight()/2-15, 100, 15, "")
button1 = ButtonGadget(#PB_Any, WindowWidth()/2-50, WindowHeight()-50, 100, 50, "Click Me")
;Creates Statusbar
EndIf
EndIf ;EndIf for OpenWindow
SetWindowCallback(@MyWindowCallback())
;Main Loop
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case button1
answer.s = GetGadgetText(string1) + Space(1) + GetGadgetText(string2)
SetGadgetText(string3, answer)
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End