It is currently Mon Jul 16, 2018 7:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How do I know what a gadget is displayed?
PostPosted: Sun Apr 15, 2018 6:23 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 661
That is, I need an event after the gadget is displayed.
Here is an example of what I need but only more correct.
Can anyone help me? Thank you in advance.
And it is very desirable cross-platform.

Code:
; Module
#PB_EventType_Show = #PB_EventType_FirstCustomValue

Procedure CallBack()
 
  Select EventType()
    Case #PB_EventType_Show
      Debug "show"
  EndSelect
 
EndProcedure

Procedure TimerCallBack()
 
  If IsWindowVisible_(GadgetID(0))
    RemoveWindowTimer(0, EventTimer())
    PostEvent(#PB_Event_Gadget, 0,0, #PB_EventType_Show)
  EndIf
 
EndProcedure

Procedure Gadget(Window, Gadget, X.l, Y.l, Width.l, Height.l)
  AddWindowTimer(Window, 1, 10)
  CanvasGadget(Gadget, X, Y, Width, Height)
 
  BindGadgetEvent(Gadget, @CallBack())
  BindEvent(#PB_Event_Timer, @TimerCallBack(), Window)
EndProcedure

; EndModule



If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  Gadget(0, 0, 10, 10, 200, 200)
 
  ;   HideGadget(0,1)
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I know what a gadget is displayed?
PostPosted: Mon Apr 16, 2018 12:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 661
Do not pass by write do not hesitate. :D Here's another version without using the window id (which is important).
This option would suit me more only there is no cross-platform.
Code:
; Module
Enumeration  #PB_EventType_FirstCustomValue
  #PB_EventType_Show
  #PB_EventType_Timer
EndEnumeration

Procedure TimerStart(hWnd, TimerId, Delay, ProcedureAdress)
  SetTimer_(hWnd,TimerId,Delay,ProcedureAdress)
EndProcedure

Procedure TimerKill(hWnd, TimerId)
  KillTimer_(hWnd, TimerId)
EndProcedure

Procedure CallBack()
 
  Select EventType()
    Case #PB_EventType_Show
      Debug "show"
    Case #PB_EventType_Timer
      Debug "Timer"
  EndSelect
 
EndProcedure

Procedure TimerCallBack(hwnd.l, uMsg.l, *idEvent, dwTime.w);
 
  If *idEvent = 0 And IsWindowVisible_(hwnd)
    PostEvent(#PB_Event_Gadget, GetProp_(GetParent_(hwnd), "PB_WindowID")-1, GetDlgCtrlID_(hwnd), #PB_EventType_Show)
    TimerKill(hWnd,*idEvent)
  Else
    PostEvent(#PB_Event_Gadget, GetProp_(GetParent_(hwnd), "PB_WindowID")-1, GetDlgCtrlID_(hwnd), #PB_EventType_Timer)
  EndIf
 
EndProcedure

Procedure Gadget(Gadget, X.l, Y.l, Width.l, Height.l, time=0)
  CanvasGadget(Gadget, X, Y, Width, Height)
 
  TimerStart(GadgetID(Gadget), 0, 1, @TimerCallBack())
 
  If time
    TimerStart(GadgetID(Gadget), 1, time, @TimerCallBack())
  EndIf
 
  BindGadgetEvent(Gadget, @CallBack())
EndProcedure

; EndModule



If OpenWindow(10, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  Gadget(10, 10, 10, 200, 200, 500)
 
  ;   HideGadget(0,1)
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I know what a gadget is displayed?
PostPosted: Thu Apr 19, 2018 12:50 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 661
Code:
EnableExplicit

Global GadgetCB

Procedure ButtonCB(hWnd, Message, wParam, lParam)
  Select Message
    Case 133
      If IsWindowVisible_(hwnd)
        Debug "Show"
      EndIf
  EndSelect
 
  ProcedureReturn CallWindowProc_(GadgetCB, hWnd, Message, wParam, lParam)
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(1, 10, 10, 100, 20)
 
  ;HideGadget(1,1)
  GadgetCB = SetWindowLongPtr_(GadgetID(1), #GWL_WNDPROC, @ButtonCB())
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 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