Callback thingie

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 tranquil.

Hello again...

just a little question: Are WindowCallBack Messages queued? Why I ask is the following:

I want to process some messages in my WindowCallBack. (Timers and NetWork events) These are reported in the param Message. Everything works fine, but if I resize the window and a message is send to to the window by the system this message gets lost.

I tried some other applications on this issue and there is no such a problem. What can I do not to loose thouse messages. (Networkevents as my priority messages couse all transfers are stoped if they are not processed)

Thanks a lot for a short info.

Fred, can you help?

Cheers
Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
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.

No messages should get lost.
In this example, timers run if windows are resized.

Code: Select all

Global hwnd, hwnd2, Count1, Count2

Procedure MyCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  Select WindowID
    Case WindowID(1)
      Select message
        Case #WM_SIZE
          SetGadgetText(3,"Window 1 sized")
          result=0
        Case #WM_TIMER
          SetGadgetText(4,"Window 1 timer "+Str(count1))
          count1+1
          result=0
          SetGadgetText(3,"")
      EndSelect
    Case WindowID(2)  ; splash window
      Select message
        Case #WM_SIZE
          SetGadgetText(1,"Window 2 sized")
          result=0
        Case #WM_TIMER
          SetGadgetText(2,"Window 2 timer "+Str(count2))
          count2+1
          result=0
          SetGadgetText(1,"")
      EndSelect
  EndSelect
  ProcedureReturn Result
EndProcedure

hwnd2= OpenWindow(2, 200, 300, 673, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget| #PB_Window_SizeGadget,"PB Window 2")
If CreateGadgetList(WindowID())
  TextGadget(1,20,20,300,20,"Timer")
  TextGadget(2,20,40,300,20,"Timer")
EndIf

hwnd= OpenWindow(1, 200, 100, 673, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget| #PB_Window_SizeGadget,"PB Window 1")

;
If CreateGadgetList(WindowID())
  
  TextGadget(3,20,20,300,20,"Timer")
  TextGadget(4,20,40,300,20,"Timer")
  
  SetWindowCallback(@myCallback())
  
  SetTimer_(hwnd, 1, 500, 0)
  SetTimer_(hwnd2, 1, 800, 0)
  Repeat
    EventID=WaitWindowEvent()
  Until EventID = #PB_EventCloseWindow
EndIf
End
Regards,

Berikco

http://www.benny.zeb.be/purebasic.htm
Post Reply