It is currently Tue Dec 01, 2020 3:40 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Can I use #PB_Ignore for 'empty' PostEvent Parameters?
PostPosted: Sat Oct 03, 2020 1:59 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 585
Location: Near Hamburg
I want to fire an event with PostEvent.
Code:
PostEvent(Event [, Window, Object [, Type [, Data]])

A data value is to be passed (last parameter), but no window, no object and no EventType.

Can I use #PB_Ignore for this?
Code:
PostEvent(#MyCustomEvent, #PB_Ignore, #PB_Ignore, #PB_Ignore, 300)

Or does it make no difference at all, because PureBasic doesn't care about these values at all? The event should be sent to all windows and I don't want that it is not sent to all windows by specifying a wrong constant at the parameter Window, Object and Type.

Markus

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: Can I use #PB_Ignore for 'empty' PostEvent Parameters?
PostPosted: Sat Oct 03, 2020 2:13 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2730
Location: Germany
Yes ;)
You can use all parameters as long as you structure your evaluation of the WaitWindowEvent correctly.
That means, always first evaluate the event (e.g. #PB_Event_CloseWindow) and then the meant window (EventWindow).
Code:
;-TOP

Enumeration #PB_Event_FirstCustomValue
  #MyEvent_Data
EndEnumeration

Enumeration Windows
  #Main
EndEnumeration

Enumeration Gadgets
 
EndEnumeration

Enumeration Status
  #MainStatusBar
EndEnumeration

Procedure Main()
 
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
 
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
   
    Debug "Constant #PB_Ignore = " + #PB_Ignore
   
    PostEvent(#MyEvent_Data, #PB_Ignore, #PB_Ignore, #PB_Ignore, 300)
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
         
        Case #MyEvent_Data
          Debug "Window = " + EventWindow()
          Debug "Gadget = " + EventGadget()
          Debug "Type   = " + EventType()
          Debug "Data   = " + EventData()
         
      EndSelect
    ForEver
   
  EndIf
 
EndProcedure : Main()

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Last edited by mk-soft on Sat Oct 03, 2020 2:20 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Can I use #PB_Ignore for 'empty' PostEvent Parameters?
PostPosted: Sat Oct 03, 2020 2:17 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 585
Location: Near Hamburg
Great, many thanks, mk-soft.
You put a lot of effort and wrote an example. Image

_________________
PB 5.72 x64, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 52y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: Can I use #PB_Ignore for 'empty' PostEvent Parameters?
PostPosted: Sat Oct 03, 2020 2:24 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2730
Location: Germany
The PostEvent function does not trigger any internal actions. It only adds the message in the event buffer, which you then evaluate after WaitWindowEvent.

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Can I use #PB_Ignore for 'empty' PostEvent Parameters?
PostPosted: Sat Oct 03, 2020 3:06 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2730
Location: Germany
Here is the proof how PostEvent works and the truth about the function EventTimer :wink:
Code:
;-TOP

Enumeration #PB_Event_FirstCustomValue
  #MyEvent_Data
EndEnumeration

Enumeration Windows
  #Main
EndEnumeration

Enumeration Gadgets
 
EndEnumeration

Enumeration Status
  #MainStatusBar
EndEnumeration

Procedure Main()
 
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
 
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
   
    Debug "Constant #PB_Ignore = " + #PB_Ignore
    Debug "----------------------------------"
   
    PostEvent(#MyEvent_Data, #PB_Ignore, #PB_Ignore, #PB_Ignore, 300)
   
    PostEvent(#PB_Event_Gadget, 1, 10, 100, 1000)
   
    AddWindowTimer(#Main, 999, 1000)
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
         
        Case #PB_Event_Gadget
          Debug "#PB_Event_Gadget"
          Debug "Window          = " + EventWindow()
          Debug "Gadget (Object) = " + EventGadget()
          Debug "Type            = " + EventType()
          Debug "Data            = " + EventData()
          Debug "Timer  (Object) = " + EventTimer()
          Debug "----------------------------------"
         
        Case #PB_Event_Timer
          Debug "#PB_Event_Timer"
          Debug "Window          = " + EventWindow()
          Debug "Gadget (Object) = " + EventGadget()
          Debug "Type            = " + EventType()
          Debug "Data            = " + EventData()
          Debug "Timer  (Object) = " + EventTimer()
          Debug "----------------------------------"
          RemoveWindowTimer(#Main, 999)
         
        Case #MyEvent_Data
          Debug "#MyEvent_Data"
          Debug "Window          = " + EventWindow()
          Debug "Gadget (Object) = " + EventGadget()
          Debug "Type            = " + EventType()
          Debug "Data            = " + EventData()
          Debug "Timer  (Object) = " + EventTimer()
          Debug "----------------------------------"
         
      EndSelect
    ForEver
   
  EndIf
 
EndProcedure : Main()

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 32 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye