WindowCallback problem

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Saboteur.

I get an error in the next code, in SetGadgetText command. Is possible use normal commands in callback procedures? or is my problem only?

I have Win98.

Code: Select all

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  Result=#PB_ProcessPureBasicEvents
  
  UseWindow(0)
  SetGadgetText(1,"Bye")
  
  ProcedureReturn Result
EndProcedure

If OpenWindow(0,200,200,300,300,#PB_Window_SystemMenu,"Demo")
  CreateGadgetList(WindowID())
  StringGadget(1,10,10,100,20,"Hello")
  SetWindowCallback(@WindowCallback())
EndIf

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
End
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

you need to process the messages in the Callback, now Setgadgettext() is called for every window event.

Code: Select all

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  Result=#PB_ProcessPureBasicEvents
  
 ; UseWindow(0)
  If Message = #WM_LBUTTONDOWN
    SetGadgetText(1,"Bye")
  ElseIf Message = #WM_RBUTTONDOWN
    SetGadgetText(1,"ByeBye")
  EndIf
  
  ProcedureReturn Result
EndProcedure

If OpenWindow(0,200,200,300,300,#PB_Window_SystemMenu,"Demo")
  CreateGadgetList(WindowID())
  StringGadget(1,10,10,100,20,"Hello")
  SetWindowCallback(@WindowCallback())
EndIf

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
End
Regards,

Berikco

http://users.pandora.be/berikco/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Saboteur.

Ok thanks
Post Reply