2 CanvasGadgets with 2 BindGadgets

Windows specific forum
HanPBF
Enthusiast
Enthusiast
Posts: 564
Joined: Fri Feb 19, 2010 3:42 am

Re: 2 CanvasGadgets with 2 BindGadgets

Post by HanPBF »

Thanks for the link!

In the moment I hope, hideGadget(..., #True) and
then hideGadget(..., #False) in the right order does the also job.


Thanks!
mestnyi
Addict
Addict
Posts: 1001
Joined: Mon Nov 25, 2013 6:41 am

Re: 2 CanvasGadgets with 2 BindGadgets

Post by mestnyi »

So I think the easiest way :)

Code: Select all

EnableExplicit

Procedure ClipsGadget()
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Protected WindowID = UseGadgetList(0)
    If (GetWindowLongPtr_(WindowID, #GWL_EXSTYLE) & #WS_EX_COMPOSITED) = #False
      SetWindowLongPtr_(WindowID, #GWL_EXSTYLE, GetWindowLongPtr_(WindowID, #GWL_EXSTYLE) | #WS_EX_COMPOSITED)
    EndIf
  CompilerEndIf
EndProcedure

Procedure onCallback_Canvas1()
  Debug "onCallback_Canvas1"
EndProcedure

Procedure onCallback_Canvas2()
  Debug "onCallback_Canvas2"
EndProcedure

If OpenWindow(0, 0, 0, 512, 512, "Test")
  CanvasGadget(1, 32, 16, 64, 24, #PB_Canvas_Border)   
  BindGadgetEvent(1, @onCallback_Canvas1())
  
  CanvasGadget(2, 8, 8, 128, 64, #PB_Canvas_Border)   
  BindGadgetEvent(2, @onCallback_Canvas2())
  
  ClipsGadget()
EndIf   

Repeat 
  Define E = WaitWindowEvent()
Until E=#PB_Event_CloseWindow
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: 2 CanvasGadgets with 2 BindGadgets

Post by chi »

Or just...

Code: Select all

EnableExplicit

Procedure onCallback_Canvas1()
	Debug "onCallback_Canvas1"
EndProcedure

Procedure onCallback_Canvas2()
	Debug "onCallback_Canvas2"
EndProcedure

If OpenWindow(0, 0, 0, 512, 512, "Test")
	CanvasGadget(1, 32, 16, 64, 24, #PB_Canvas_Border)   
	BindGadgetEvent(1, @onCallback_Canvas1())
	
	CanvasGadget(2, 8, 8, 128, 64, #PB_Canvas_Border)   
	BindGadgetEvent(2, @onCallback_Canvas2())
	
	SetWindowLongPtr_(GadgetID(2), #GWL_STYLE, GetWindowLongPtr_(GadgetID(2), #GWL_STYLE) | #WS_CLIPSIBLINGS)
EndIf   

Repeat
	Define E = WaitWindowEvent()
Until E=#PB_Event_CloseWindow
Et cetera is my worst enemy
Post Reply