after use SetParent_(win2,win1) , how correctly show win2 ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

after use SetParent_(win2,win1) , how correctly show win2 ?

Post by gurj »

after use SetParent_(win2,win1) , how correctly show win2 ?

Code: Select all

;after use SetParent_(win2,win1) , how correctly show win2 ?
win1=OpenWindow(1,0,0,380,350,"",#PB_Window_ScreenCentered)

ButtonGadget(0,11,11,222,22,"Button")
TextGadget(1,11,41,222,22,"Text")
StringGadget(2,11,71,222,22,"String")

ContainerGadget(10, 8, 98, 306, 133, #PB_Container_Raised)
ButtonGadget(11, 10, 15, 80, 24, "Button 11")
ButtonGadget(12, 95, 15, 80, 24, "Button 12")
CloseGadgetList()

win2=OpenWindow(2,0,0,180,150,"2",#PB_Window_SystemMenu);,#PB_Window_WindowCentered,w1)
ButtonGadget(52, 25, 15, 80, 24, "Button 12")

SetParent_(win2,win1)

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
my pb for chinese:
http://ataorj.ys168.com
mestnyi
Addict
Addict
Posts: 1000
Joined: Mon Nov 25, 2013 6:41 am

Re: after use SetParent_(win2,win1) , how correctly show win

Post by mestnyi »

this is the problem of overlapping gadgets.
That's how it works. :)

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Procedure GadgetsClipCallBack( GadgetID, lParam )
      If GadgetID
        Protected Gadget = GetProp_( GadgetID, "PB_ID" )
        
        If GetWindowLongPtr_( GadgetID, #GWL_STYLE ) & #WS_CLIPSIBLINGS = #False 
          If IsGadget( Gadget ) 
            Select GadgetType( Gadget )
              Case #PB_GadgetType_Unknown
                
              Case #PB_GadgetType_ComboBox
                Protected Height = GadgetHeight( Gadget )
            EndSelect
          EndIf
          
          SetWindowLongPtr_( GadgetID, #GWL_STYLE, GetWindowLongPtr_( GadgetID, #GWL_STYLE ) | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN )
          
          If Height
            ResizeGadget( Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, Height )
          EndIf
          
          SetWindowPos_( GadgetID, #GW_HWNDLAST, 0,0,0,0, #SWP_NOMOVE|#SWP_NOSIZE )
        EndIf
        
      EndIf
      
      ProcedureReturn GadgetID
    EndProcedure
  CompilerEndIf
  
  Procedure ClipGadgets( WindowID )
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      WindowID = GetAncestor_( WindowID, #GA_ROOT )
      SetWindowLongPtr_( WindowID, #GWL_STYLE, GetWindowLongPtr_( WindowID, #GWL_STYLE )|#WS_CLIPCHILDREN )
      EnumChildWindows_( WindowID, @GadgetsClipCallBack(), 0 )
    CompilerEndIf
  EndProcedure
  
  ;after use SetParent_(win2,win1) , how correctly show win2 ?
  win1=OpenWindow(1,0,0,380,350,"",#PB_Window_ScreenCentered)

ButtonGadget(0,11,11,222,22,"Button")
TextGadget(1,11,41,222,22,"Text")
StringGadget(2,11,71,222,22,"String")

ContainerGadget(10, 8, 98, 306, 133, #PB_Container_Raised)
ButtonGadget(11, 10, 15, 80, 24, "Button 11")
ButtonGadget(12, 95, 15, 80, 24, "Button 12")
CloseGadgetList()


win2=OpenWindow(2,0,0,180,150,"2",#PB_Window_SystemMenu);,#PB_Window_WindowCentered,w1)
ButtonGadget(52, 25, 15, 80, 24, "Button 12")

SetParent_(win2,win1)

ClipGadgets(win1)

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
I often asked Fred, but he does not hear. :cry:
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: after use SetParent_(win2,win1) , how correctly show win

Post by gurj »

thanks mestnyi !
maybe should use MDIGadget() :

Code: Select all

#Main = 0
#MDIChild = 1
If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
 If CreateMenu(#Main, WindowID(#Main))
  MenuTitle("Menu index 0")
  MenuTitle("MDI windows menu")
  MenuItem(0, "self created item")
  MenuItem(1, "self created item")
  
  ButtonGadget(110,11,11,222,22,"Button")
  MDIGadget(0, 0, 120, 400,210, 1, 2)
  AddGadgetItem(0, #MDIChild, "child window")
  ; add gadgets here...
  ButtonGadget(10,11,11,222,22,"Button")
  TextGadget(1,11,41,222,22,"Text")
  StringGadget(2,11,71,222,22,"String")
  ;UseGadgetList(GadgetID(0))
  UseGadgetList(WindowID(#Main)) ; go back to the main window gadgetlist
  TextGadget(111,11,41,222,22,"Text")
  StringGadget(112,11,71,222,22,"String")
 EndIf
 Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf

my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: after use SetParent_(win2,win1) , how correctly show win

Post by gurj »

add should this:

Code: Select all

;after use SetParent_(win2,win1) , how correctly show win2 ?
;add should this
win1=OpenWindow(1,0,0,380,450,"",#PB_Window_ScreenCentered)

ButtonGadget(0,11,11,222,22,"Button")
TextGadget(1,11,41,222,22,"Text")
StringGadget(2,11,71,222,22,"String")

ContainerGadget(10, 8, 98, 306, 133, #PB_Container_Raised)
ButtonGadget(11, 10, 15, 80, 24, "Button 11")
ButtonGadget(12, 95, 15, 80, 24, "Button 12")
CloseGadgetList()

win2=OpenWindow(2,40,235,180,150,"2",#PB_Window_SystemMenu)
;******win2 can't use #PB_Window_MaximizeGadget and #PB_Window_MinimizeGadget
ButtonGadget(52, 25, 15, 80, 24, "Button 22")

SetParent_(win2,win1)
;-{******here, win1 can't use:
;UseGadgetList(Win1) 
;  TextGadget(111,101,351,22,22,"Text")
;  StringGadget(112,11,381,222,22,"String")
;}
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
my pb for chinese:
http://ataorj.ys168.com
Post Reply