Docking toolwindows with an MDI gadget

Share your advanced PureBasic knowledge/code with the community.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Docking toolwindows with an MDI gadget

Post by localmotion34 »

here is a little attemp at an excel like toolwindow that can be docked or free using an MDI gadget. MDI source code originally by freak, which i modiefied to suit this purpose

Code: Select all

; *******************************************************************************
; MDIGadget() Description: Modified By LOCALMOTION34
; *******************************************************************************


; Example Code: a MDI ImageViewer:
; *******************************************************************************

Structure MDIWindow
  ; info about the loaded image
  Image.l
  ImageWidth.l
  ImageHeight.l
  
  ; gadget numbers
  ScrollAreaGadget.l
  ImageGadget.l  
EndStructure

NewList MDIWindow.MDIWindow()
#SS_NOTIFY=256 
#WINDOW = 0
#TOOLBAR = 0
#MENU = 0

Enumeration
  #MENU_Open
  #MENU_Close
  #MENU_CloseAll
  #MENU_Quit
  
  #MENU_TileV
  #MENU_TileH
  #MENU_Cascade
  #MENU_Arrange
  #MENU_Previous
  #MENU_Next
  
  #MENU_FirstMDI
EndEnumeration
Structure gadgetlist
  button.l
  button2.l
  button3.l
  button4.l
EndStructure
Dim windowlist.gadgetlist(100)
windowlist(0)\button=1
windowlist(0)\button2=2
windowlist(0)\button3=3
windowlist(0)\button4=4
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

#GADGET_MDI = 0
#Window_0=1
#WindowFlags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget

If OpenWindow(#WINDOW, 0, 0, 800, 600, #WindowFlags, "MDI ImageViewer/Docked ToolWindow")
  If CreateMenu(#MENU, WindowID())
    MenuTitle("File")
    MenuItem(#MENU_Open, "Open")
    MenuItem(#MENU_Close, "Close")
    MenuItem(#MENU_CloseAll, "Close All")
    MenuBar()
    MenuItem(#MENU_Quit, "Quit")      
    MenuTitle("Windows")
    MenuItem(#MENU_TileV, "Tile vertically")
    MenuItem(#MENU_TileH, "Tile horizontally")
    MenuItem(#MENU_Cascade, "Cascade")
    MenuItem(#MENU_Previous, "Previous")
    MenuItem(#MENU_Next, "Next")
    
    ; MDI subwindows will get added here
  EndIf
  
  If CreateToolBar(#TOOLBAR, WindowID())
    ToolBarStandardButton(#MENU_Open, #PB_ToolBarIcon_Open)
    ToolBarStandardButton(#MENU_Close, #PB_ToolBarIcon_Delete)
    ToolBarSeparator()
    ToolBarStandardButton(#MENU_Previous, #PB_ToolBarIcon_Undo)
    ToolBarStandardButton(#MENU_Next, #PB_ToolBarIcon_Redo)
  EndIf
  
  If CreateGadgetList(WindowID())
    MDIGadget(#GADGET_MDI, 110, 30, 700, 500, 1, #MENU_FirstMDI)
    x = WindowX() 
    y = WindowY()
    slam=OpenWindow(1,x+3,y+80,110,500,#PB_Window_BorderLess| #WS_BORDER,"",WindowID(#WINDOW))
    SetWindowLong_(WindowID(1),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW|#ws_child)
    SendMessage_(slam, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
    CreateGadgetList(WindowID(1))
    ButtonGadget(100, 10, 15, 80, 24,"Docked") 
    ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
    CloseGadgetList()
   
    
  EndIf
  
  
  Quit = 0
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_CloseWindow
      Quit = 1   
      
    ElseIf Event = #PB_Event_Menu
      Select EventMenuID()
        Case #MENU_Open
          a=CountGadgetItems(#GADGET_MDI)
          zam=AddGadgetItem(#GADGET_MDI, 1, Str(a))              
          ButtonGadget(windowlist(0)\button+a*4,100,100,30,30,"test")
          ButtonGadget(windowlist(0)\button2+a*4,130,100,30,30,"test")
          ButtonGadget(windowlist(0)\button3+a*4,160,100,30,30,"test")
          ButtonGadget(windowlist(0)\button4+a*4,190,100,30,30,"test")
          
          
          
          
        Case #MENU_Quit
          Quit = 1     
          
        Case #MENU_TileV
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileVertically)
          
        Case #MENU_TileH
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileHorizontally)
          
        Case #MENU_Cascade
          SetGadgetState(#GADGET_MDI, #PB_MDI_Cascade)
          
        Case #MENU_Arrange
          SetGadgetState(#GADGET_MDI, #PB_MDI_Arrange)
          
        Case #MENU_Previous
          SetGadgetState(#GADGET_MDI, #PB_MDI_Previous)
          
        Case #MENU_Next
          SetGadgetState(#GADGET_MDI, #PB_MDI_Next)
          
      EndSelect
      
      
    ElseIf Event = #PB_Event_Gadget
      If EventGadgetID() = #GADGET_MDI
        
        Type = EventType()
        
        If Type = #PB_EventType_SizeItem          
          Item = GetGadgetAttribute(#GADGET_MDI, #PB_MDI_SizedItem)          
          Width  = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemWidth)
          Height = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemHeight)          
          
          SelectElement(MDIWindow(), Item)
          
          
        ElseIf Type = #PB_EventType_CloseItem
          Item = GetGadgetState(#GADGET_MDI)         
          RemoveGadgetItem(#GADGET_MDI, Item)
          
          
          DeleteElement(MDIWindow())         
          
        EndIf
        
        
        
      ElseIf EventGadgetID()=101
        SetWindowStyles(1,#WS_VISIBLE |#swp_nomove| #WS_BORDER |#PB_Window_TitleBar,#WS_EX_TOOLWINDOW)
        SetWindowPos_(1,#WS_VISIBLE,0,30,110,500,#swp_nomove)
        ResizeGadget(#GADGET_MDI,5, 30, 810, 500)
    ElseIf EventGadgetID()=100
      SetWindowStyles(1,#WS_VISIBLE |#PB_Window_BorderLess| #WS_BORDER,#WS_EX_TOOLWINDOW)
      UseWindow(#WINDOW) 
      
      x = WindowX() 
      y = WindowY()
      UseWindow(1)
      MoveWindow(x+3,y+80)
      ResizeGadget(#GADGET_MDI,110, 30, 700, 500)
      EndIf
      
    EndIf
    
  Until Quit = 1  
EndIf

give it a try and hit me up with suggestions

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

PB complains about MDIGadget() not being a function, array or linked list (on line 87). Do you know what library is missing on my side?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

you have to have 3.89 beta or 3.9 installed to use the MDI gadget

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
AlGonzalez
User
User
Posts: 53
Joined: Sun Feb 15, 2004 6:04 am
Location: Easley, SC, USA

Post by AlGonzalez »

Pretty Neat!

The calls to SetWindowStyles in line 172 and 176 don't work for me.

I replaced them with calls to SetWindowLong_(WindowID(1) and it seems to work now.
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Pretty nice :), but when it's docked and you move the main window..... it stays in place 8O
Paid up PB User !
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

you know what, i just realized that this morning, ill have to try and figure out how to fix that. any suggestions are welcome. im actually going to try and finish this project and make a library out of it for creating docked windows like this. can anyone fix this slight problem?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi localmotion34,

I can only be 10% of help.

Somewhere on this forum, somebody helped me with some docking and windows moving code. Unfortunately I can't remember who, or find the posts, or find the code on my HD. (I decided on another approach and stored the code "somewhere safe").

Now I am pretty sure I am not dreaming. I just know it is somewhere around on this forum. If I find the code on my HD I will post it. From recollection it involved detecting the movement of the main window via callback, and forcing equivalent movement of the docked window.

Hope that was as much as 10% useful!
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

snap!!! figured out how to use a container gadget to act as the DOCKED window, and then use that gadget list to create a toolwindow.

Code: Select all

Structure MDIWindow
  ; info about the loaded image
  Image.l
  ImageWidth.l
  ImageHeight.l
  
  ; gadget numbers
  ScrollAreaGadget.l
  ImageGadget.l  
EndStructure

NewList MDIWindow.MDIWindow()
#SS_NOTIFY=256 
#WINDOW = 0
#TOOLBAR = 0
#MENU = 0

Enumeration
  #MENU_Open
  #MENU_Close
  #MENU_CloseAll
  #MENU_Quit
  
  #MENU_TileV
  #MENU_TileH
  #MENU_Cascade
  #MENU_Arrange
  #MENU_Previous
  #MENU_Next
  
  #MENU_FirstMDI
EndEnumeration
Structure gadgetlist
  button.l
  button2.l
  button3.l
  button4.l
EndStructure
Dim windowlist.gadgetlist(100)
windowlist(0)\button=1
windowlist(0)\button2=2
windowlist(0)\button3=3
windowlist(0)\button4=4
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()

#GADGET_MDI = 0
#Window_0=1
#WindowFlags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget

If OpenWindow(#WINDOW, 0, 0, 800, 600, #WindowFlags, "MDI ImageViewer/Docked ToolWindow")
  If CreateMenu(#MENU, WindowID())
    MenuTitle("File")
    MenuItem(#MENU_Open, "Open")
    MenuItem(#MENU_Close, "Close")
    MenuItem(#MENU_CloseAll, "Close All")
    MenuBar()
    MenuItem(#MENU_Quit, "Quit")      
    MenuTitle("Windows")
    MenuItem(#MENU_TileV, "Tile vertically")
    MenuItem(#MENU_TileH, "Tile horizontally")
    MenuItem(#MENU_Cascade, "Cascade")
    MenuItem(#MENU_Previous, "Previous")
    MenuItem(#MENU_Next, "Next")
    
    ; MDI subwindows will get added here
  EndIf
  
  If CreateToolBar(#TOOLBAR, WindowID())
    ToolBarStandardButton(#MENU_Open, #PB_ToolBarIcon_Open)
    ToolBarStandardButton(#MENU_Close, #PB_ToolBarIcon_Delete)
    ToolBarSeparator()
    ToolBarStandardButton(#MENU_Previous, #PB_ToolBarIcon_Undo)
    ToolBarStandardButton(#MENU_Next, #PB_ToolBarIcon_Redo)
  EndIf
  
  If CreateGadgetList(WindowID())
    MDIGadget(#GADGET_MDI, 110, 30, 700, 500, 1, #MENU_FirstMDI)
    ContainerGadget(5,0,30,110,500,#PB_Container_Raised)
    ButtonGadget(100, 10, 15, 80, 24,"Docked") 
    ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
    CloseGadgetList()
  EndIf
  Quit = 0
  Repeat
    Event = WaitWindowEvent()
    Select EventWindowID()
      Case 1 ;toolwindow 
        Select EventType() 
          Case #WM_rBUTTONup  
         SetWindowStyles(1,#WS_VISIBLE |#PB_Window_BorderLess| #WS_BORDER,#WS_EX_TOOLWINDOW)
          UseWindow(#WINDOW) 
          x = WindowX() 
          y = WindowY()
          UseWindow(1)
          MoveWindow(x+3,y+80)
          ResizeGadget(#GADGET_MDI,110, 30, 700, 500)  
          EndSelect
      EndSelect
    If Event = #PB_Event_CloseWindow
      Quit = 1   
     
    ElseIf Event = #PB_Event_Menu 
      Select EventMenuID()
        Case #MENU_Open
          a=CountGadgetItems(#GADGET_MDI)
          zam=AddGadgetItem(#GADGET_MDI, 1, Str(a))              
          ButtonGadget(windowlist(0)\button+a*4,100,100,30,30,"test")
          ButtonGadget(windowlist(0)\button2+a*4,130,100,30,30,"test")
          ButtonGadget(windowlist(0)\button3+a*4,160,100,30,30,"test")
          ButtonGadget(windowlist(0)\button4+a*4,190,100,30,30,"test") 
        Case #MENU_Quit
          Quit = 1     
          
        Case #MENU_TileV
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileVertically)
          
        Case #MENU_TileH
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileHorizontally)
          
        Case #MENU_Cascade
          SetGadgetState(#GADGET_MDI, #PB_MDI_Cascade)
          
        Case #MENU_Arrange
          SetGadgetState(#GADGET_MDI, #PB_MDI_Arrange)
          
        Case #MENU_Previous
          SetGadgetState(#GADGET_MDI, #PB_MDI_Previous)
          
        Case #MENU_Next
          SetGadgetState(#GADGET_MDI, #PB_MDI_Next)
      EndSelect 
    ElseIf Event = #PB_Event_Gadget
      event1=EventGadgetID()
      Select event1 
        Case #GADGET_MDI
          Type = EventType()
          If Type = #PB_EventType_SizeItem          
            Item = GetGadgetAttribute(#GADGET_MDI, #PB_MDI_SizedItem)          
            Width  = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemWidth)
            Height = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemHeight)          
            SelectElement(MDIWindow(), Item)
          ElseIf Type = #PB_EventType_CloseItem
            Item = GetGadgetState(#GADGET_MDI)         
            RemoveGadgetItem(#GADGET_MDI, Item)
            DeleteElement(MDIWindow())         
          EndIf
        Case 101
          [b]FreeGadget(5)
          ResizeGadget(#GADGET_MDI,5, 30, 810, 500)
          UseWindow(#WINDOW) 
          x = WindowX() 
          y = WindowY()
          slam=OpenWindow(1,x+3,y+80,110,500,#PB_Window_BorderLess| #WS_BORDER,"",WindowID(#WINDOW))
          SetWindowStyles(1,#WS_VISIBLE |#PB_Window_TitleBar| #WS_BORDER,#WS_EX_TOOLWINDOW)
          SetWindowLong_(WindowID(1),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW|#ws_child)
          SendMessage_(slam, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
          CreateGadgetList(WindowID(1))
          ButtonGadget(100, 10, 15, 80, 24,"Docked") 
          ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
          CloseGadgetList()
        Case 100
          CloseWindow(1)
          ResizeGadget(#GADGET_MDI,110, 30, 700, 500)
          UseGadgetList(WindowID(#WINDOW))
          ContainerGadget(5,0,30,110,500,#PB_Container_Raised)
          ButtonGadget(100, 10, 15, 80, 24,"Docked") 
          ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
          CloseGadgetList()[/b]      EndSelect 
    EndIf
    
  Until Quit = 1  
EndIf


try it out and hit me up with suggestions. the faster i can get this done, the faster i can make a library out of this to add to our collection to give PB programs a really cool interface.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Closer........ but the docked buttons all dissapear after you open a few windows with the file_open button 8O

Sorry can't test too much, busy here :roll:
Paid up PB User !
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

ok fixed that-i gave the container a # that is 500 instead of 5, so you can open windows until the button numbers reach 500.

Code: Select all

Structure MDIWindow 
  ; info about the loaded image 
  Image.l 
  ImageWidth.l 
  ImageHeight.l 
  
  ; gadget numbers 
  ScrollAreaGadget.l 
  ImageGadget.l  
EndStructure 

NewList MDIWindow.MDIWindow() 
#SS_NOTIFY=256 
#WINDOW = 0 
#TOOLBAR = 0 
#MENU = 0 

Enumeration 
  #MENU_Open 
  #MENU_Close 
  #MENU_CloseAll 
  #MENU_Quit 
  
  #MENU_TileV 
  #MENU_TileH 
  #MENU_Cascade 
  #MENU_Arrange 
  #MENU_Previous 
  #MENU_Next 
  
  #MENU_FirstMDI 
EndEnumeration 
Structure gadgetlist 
  button.l 
  button2.l 
  button3.l 
  button4.l 
EndStructure 
Dim windowlist.gadgetlist(100) 
windowlist(0)\button=1 
windowlist(0)\button2=2 
windowlist(0)\button3=3 
windowlist(0)\button4=4 
UseJPEGImageDecoder() 
UsePNGImageDecoder() 
UseTGAImageDecoder() 
UseTIFFImageDecoder() 

#GADGET_MDI = 0 
#Window_0=1 
#WindowFlags = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget 

If OpenWindow(#WINDOW, 0, 0, 800, 600, #WindowFlags, "MDI ImageViewer/Docked ToolWindow") 
  If CreateMenu(#MENU, WindowID()) 
    MenuTitle("File") 
    MenuItem(#MENU_Open, "Open") 
    MenuItem(#MENU_Close, "Close") 
    MenuItem(#MENU_CloseAll, "Close All") 
    MenuBar() 
    MenuItem(#MENU_Quit, "Quit")      
    MenuTitle("Windows") 
    MenuItem(#MENU_TileV, "Tile vertically") 
    MenuItem(#MENU_TileH, "Tile horizontally") 
    MenuItem(#MENU_Cascade, "Cascade") 
    MenuItem(#MENU_Previous, "Previous") 
    MenuItem(#MENU_Next, "Next") 
    
    ; MDI subwindows will get added here 
  EndIf 
  
  If CreateToolBar(#TOOLBAR, WindowID()) 
    ToolBarStandardButton(#MENU_Open, #PB_ToolBarIcon_Open) 
    ToolBarStandardButton(#MENU_Close, #PB_ToolBarIcon_Delete) 
    ToolBarSeparator() 
    ToolBarStandardButton(#MENU_Previous, #PB_ToolBarIcon_Undo) 
    ToolBarStandardButton(#MENU_Next, #PB_ToolBarIcon_Redo) 
  EndIf 
  
  If CreateGadgetList(WindowID()) 
    MDIGadget(#GADGET_MDI, 110, 30, 700, 500, 1, #MENU_FirstMDI) 
    ContainerGadget(500,0,30,110,500,#PB_Container_Raised) 
    ButtonGadget(100, 10, 15, 80, 24,"Docked") 
    ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
    CloseGadgetList() 
  EndIf 
  Quit = 0 
  Repeat 
    Event = WaitWindowEvent() 
    Select EventWindowID() 
      Case 1 ;toolwindow 
        Select EventType() 
          Case #WM_rBUTTONup  
            SetWindowStyles(1,#WS_VISIBLE |#PB_Window_BorderLess| #WS_BORDER,#WS_EX_TOOLWINDOW) 
            UseWindow(#WINDOW) 
            x = WindowX() 
            y = WindowY() 
            UseWindow(1) 
            MoveWindow(x+3,y+80) 
            ResizeGadget(#GADGET_MDI,110, 30, 700, 500)  
        EndSelect 
    EndSelect 
    If Event = #PB_Event_CloseWindow 
      Quit = 1    
      
    ElseIf Event = #PB_Event_Menu 
      Select EventMenuID() 
        Case #MENU_Open 
          a=CountGadgetItems(#GADGET_MDI) 
          zam=AddGadgetItem(#GADGET_MDI, 1, Str(a))              
          ButtonGadget(windowlist(0)\button+a*4,100,100,30,30,"test") 
          ButtonGadget(windowlist(0)\button2+a*4,130,100,30,30,"test") 
          ButtonGadget(windowlist(0)\button3+a*4,160,100,30,30,"test") 
          ButtonGadget(windowlist(0)\button4+a*4,190,100,30,30,"test") 
        Case #MENU_Quit 
          Quit = 1      
          
        Case #MENU_TileV 
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileVertically) 
          
        Case #MENU_TileH 
          SetGadgetState(#GADGET_MDI, #PB_MDI_TileHorizontally) 
          
        Case #MENU_Cascade 
          SetGadgetState(#GADGET_MDI, #PB_MDI_Cascade) 
          
        Case #MENU_Arrange 
          SetGadgetState(#GADGET_MDI, #PB_MDI_Arrange) 
          
        Case #MENU_Previous 
          SetGadgetState(#GADGET_MDI, #PB_MDI_Previous) 
          
        Case #MENU_Next 
          SetGadgetState(#GADGET_MDI, #PB_MDI_Next) 
      EndSelect 
    ElseIf Event = #PB_Event_Gadget 
      event1=EventGadgetID() 
      Select event1 
        Case #GADGET_MDI 
          Type = EventType() 
          If Type = #PB_EventType_SizeItem          
            Item = GetGadgetAttribute(#GADGET_MDI, #PB_MDI_SizedItem)          
            Width  = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemWidth) 
            Height = GetGadgetItemAttribute(#GADGET_MDI, Item, #PB_MDI_ItemHeight)          
            SelectElement(MDIWindow(), Item) 
          ElseIf Type = #PB_EventType_CloseItem 
            Item = GetGadgetState(#GADGET_MDI)          
            RemoveGadgetItem(#GADGET_MDI, Item) 
            DeleteElement(MDIWindow())          
          EndIf 
        Case 101 
          FreeGadget(500) 
          ResizeGadget(#GADGET_MDI,5, 30, 810, 500) 
          UseWindow(#WINDOW) 
          x = WindowX() 
          y = WindowY() 
          slam=OpenWindow(1,x+3,y+80,110,500,#PB_Window_BorderLess| #WS_BORDER,"",WindowID(#WINDOW)) 
          SetWindowStyles(1,#WS_VISIBLE |#PB_Window_TitleBar| #WS_BORDER,#WS_EX_TOOLWINDOW) 
          SetWindowLong_(WindowID(1),#GWL_EXSTYLE,#WS_EX_TOOLWINDOW|#ws_child) 
          SendMessage_(slam, #WM_NCLBUTTONDOWN, #HTCAPTION, 0) 
          CreateGadgetList(WindowID(1)) 
          ButtonGadget(100, 10, 15, 80, 24,"Docked") 
          ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
          CloseGadgetList() 
        Case 100 
          CloseWindow(1) 
          ResizeGadget(#GADGET_MDI,110, 30, 700, 500) 
          UseGadgetList(WindowID(#WINDOW)) 
          ContainerGadget(500,0,30,110,500,#PB_Container_Raised) 
          ButtonGadget(100, 10, 15, 80, 24,"Docked") 
          ButtonGadget(101, 10, 45, 80, 24,"Tool Window") 
          CloseGadgetList()     
          EndSelect 
    EndIf 
    
  Until Quit = 1  
EndIf 
any suggestions would be helpful, im trying my best to make a cool library. i think that the more we expand PB, the better it will get

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

I've solved the mystery of SetWindowStyle, it is part of the WindowEx library.

http://www.reelmedia.org/cgi-bin/Resour ... 21&search=

You just have to copy the ScreenEx and WindowEx files from the Zip files into the PureLibraries\UserLibraries folder and then it works.

You'll restart to restart the compiler in JAPBE to recognise the new library.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

localmotion. please not only create a lib but also share the source, that's good learning material for all of us
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

The libraries were actually produced by Roger Beausoleil (VPureBasic) and written in ASM.

The announcement of its release is here:
viewtopic.php?t=2771&highlight=screenex

The link in that post is no longer valid.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

This WindowEx lib makes no sense imho.
Why do you need a command SetWindowParent() when it is nothing else
than a direct wrapper to SetParent_() ??

Timo
quidquid Latine dictum sit altum videtur
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

its easy to change that in my code, but my point is that adding the ability to have toolwindows that dock or can be freed is kinda cool to have, especially now that we have an MDI gadget. you can have MDI windows that act as your interface for data handling or whatever, and then have toolwindows that contain commands that are executed on whatever MDI window is active. i just noticed this property in excel and other programs, and it was just my idea to introduce it to PB. any other help is welcome.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Post Reply