Resize Windows and make scrollbar appear ? [Solved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Resize Windows and make scrollbar appear ? [Solved]

Post by Fig »

Hi,

I would like to make scroll bars from scrollareagadget() appear when I make the window smaller. (manual resizing)
How do I get this effect ?

Code: Select all

If OpenWindow(0, 0, 0, 1920, 1080, "test", #PB_Window_Maximize | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_BorderLess | #PB_Window_SizeGadget)=0
	MessageRequester("Error","Error can't open windowed screen"):End
EndIf
Procedure WindowResizeEvent()
	Debug "change size"
	If EventWindow()=0
		Debug "newsize"
		SetGadgetAttribute(0,#PB_ScrollArea_InnerWidth,WindowWidth(0))  ;doesn't work...
		SetGadgetAttribute(0,#PB_ScrollArea_InnerHeight,WindowHeight(0))
		Debug Str(WindowWidth(0))
		Debug Str(WindowHeight(0))
	EndIf	
EndProcedure
BindEvent(#PB_Event_SizeWindow,@WindowResizeEvent())
ScrollAreaGadget(0, 0, 0, 1920, 1080, 1898, 1006, 30)
;add some other gadgets...
CloseGadgetList() 
Repeat
	Event = WaitWindowEvent()
	If Event = #PB_Event_CloseWindow  
		Quit = 1
	EndIf
Until Quit = 1
Last edited by Fig on Sun Mar 21, 2021 8:38 am, edited 1 time in total.
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Resize Windows and make scrollbar appear ?

Post by RASHAD »

Hi Fig
I still don't know what do you want exactly
So the next is a shoot in the dark (For Windows)

Code: Select all

If OpenWindow(0, 0, 0, 1920, 1080, "test", #PB_Window_Maximize | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_BorderLess | #PB_Window_SizeGadget)=0
   MessageRequester("Error","Error can't open windowed screen"):End
EndIf
Procedure WindowResizeEvent()
  w = WindowWidth(0)
  h = WindowHeight(0)
  If EventWindow()=0
    ResizeGadget(0,0,0,w,h)
    SetScrollRange_(GadgetID(0),#SB_HORZ,0,w-20,1)
    SetScrollRange_(GadgetID(0),#SB_VERT,0,h-20,1)    
  EndIf   
EndProcedure
ScrollAreaGadget(0, 0, 0, 1920, 1080, 1898, 1006, 30)
;add some other gadgets...
CloseGadgetList()
BindEvent(#PB_Event_SizeWindow,@WindowResizeEvent())
Repeat
   Event = WaitWindowEvent()
   If Event = #PB_Event_CloseWindow 
      Quit = 1
   EndIf
Until Quit = 1
Egypt my love
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Resize Windows and make scrollbar appear ?

Post by Danilo »

Fig wrote:I would like to make scroll bars from scrollareagadget() appear when I make the window smaller. (manual resizing)
How do I get this effect ?
Just resize the ScrollArea gadget to the new window size. Scrollbars appear automagically.

Code: Select all

If OpenWindow(0, 0, 0, 1920, 1080, "test", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_SizeGadget)=0
   MessageRequester("Error","Error can't open windowed screen"):End
EndIf

Procedure WindowResizeEvent()
    Debug "change size"
    If EventWindow()=0
        ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0))
    EndIf   
EndProcedure
BindEvent(#PB_Event_SizeWindow,@WindowResizeEvent())

ScrollAreaGadget(0, 0, 0, 1920, 1080, 1898, 1006, 30)
    ;add some other gadgets...
CloseGadgetList() 

Repeat
   Event = WaitWindowEvent()
   If Event = #PB_Event_CloseWindow  
      Quit = 1
   EndIf
Until Quit = 1
(I added Titlebar because I can't resize a borderless window on macOS)
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: Resize Windows and make scrollbar appear ?

Post by Fig »

Rashad, you basically answered. I struggle all the time explaining my problem in english, my apologies... :oops:

Exactly what I was looking for Danilo, thank you !
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

About resizing a ScrollAreaGadget() there is found what is called a "bug", or wrong manual:

From the manual in the ScrollAreaGadget() entry:
The following event is supported through EventType():
#PB_EventType_Resize: The gadget has been resized.
Why is not working? :shock: :?: :?: :?:
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by mk-soft »

The event works without problems.
But you have to bind the gadget event when you bind the event size window. Otherwise the event only comes after the mouse is released.

Code: Select all

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  
EndEnumeration

Enumeration Gadgets
  #MainScrollArea
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

; ----

Procedure DoEventResizeScrollArea()
  Debug "Bind Event: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
EndProcedure

; ----

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar); - MenuHeight()
  ; Resize gadgets
  ResizeGadget(#MainScrollArea, 0, 0, dx, dy)
EndProcedure

; ----

Procedure Main()
  Protected dx, dy
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar); - MenuHeight()
    ScrollAreaGadget(#MainScrollArea, 0, 0, dx, dy, dx * 2, dy * 3)
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    BindGadgetEvent(#MainScrollArea, @DoEventResizeScrollArea(), #PB_EventType_Resize)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
              
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainScrollArea
              Select EventType()
                Case #PB_EventType_Resize
                  ;Debug "Main Loop: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
                  
              EndSelect
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
Structured event processing is important in order to query events only when they are valid.
EventGadget() and EventType() valid after an event #PB_Gadget_Event. EventTypes valid see after description of the gadget. EventTimer() after an event #PB_Event_Timer, etc.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

mk-soft wrote: Sun Mar 20, 2022 12:15 pm The event works without problems.
But you have to bind the gadget event when you bind the event size window. Otherwise the event only comes after the mouse is released.

Code: Select all

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  
EndEnumeration

Enumeration Gadgets
  #MainScrollArea
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

; ----

Procedure DoEventResizeScrollArea()
  Debug "Bind Event: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
EndProcedure

; ----

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar); - MenuHeight()
  ; Resize gadgets
  ResizeGadget(#MainScrollArea, 0, 0, dx, dy)
EndProcedure

; ----

Procedure Main()
  Protected dx, dy
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar); - MenuHeight()
    ScrollAreaGadget(#MainScrollArea, 0, 0, dx, dy, dx * 2, dy * 3)
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    BindGadgetEvent(#MainScrollArea, @DoEventResizeScrollArea(), #PB_EventType_Resize)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
              
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainScrollArea
              Select EventType()
                Case #PB_EventType_Resize
                  ;Debug "Main Loop: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
                  
              EndSelect
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
Structured event processing is important in order to query events only when they are valid.
EventGadget() and EventType() valid after an event #PB_Gadget_Event. EventTypes valid see after description of the gadget. EventTimer() after an event #PB_Event_Timer, etc.
I referred to resize the scrollarea, NOT the window. Please re-read my previous post carefully.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by mk-soft »

Still works as it should.
- Event ResizeWindow triggers UpdateWindow
- ResizeGadget in UpdateWindow triggers DoEventResizeScollArea.

You can trigger it manually from the Test menu.

Code: Select all

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  
EndEnumeration

Enumeration Gadgets
  #MainScrollArea
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

; ----

Procedure DoEventResizeScrollArea()
  Debug "Bind Event: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
EndProcedure

; ----

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
  ; Resize gadgets
  ResizeGadget(#MainScrollArea, 0, 0, dx, dy)
EndProcedure

; ----

Procedure Main()
  Protected dx, dy
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("Test")
    MenuItem(1,"Resize ScrollAreay")
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
    ScrollAreaGadget(#MainScrollArea, 0, 0, dx, dy, dx * 2, dy * 3)
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    BindGadgetEvent(#MainScrollArea, @DoEventResizeScrollArea(), #PB_EventType_Resize)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
            
          Case 1
             ResizeGadget(#MainScrollArea, 0, 0, dx/2, dy/2)
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainScrollArea
              Select EventType()
                Case #PB_EventType_Resize
                  ;Debug "Main Loop: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
                  
              EndSelect
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

mk-soft wrote: Wed Mar 23, 2022 5:25 pm Still works as it should.
- Event ResizeWindow triggers UpdateWindow
- ResizeGadget in UpdateWindow triggers DoEventResizeScollArea.

You can trigger it manually from the Test menu.

Code: Select all

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  
EndEnumeration

Enumeration Gadgets
  #MainScrollArea
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

; ----

Procedure DoEventResizeScrollArea()
  Debug "Bind Event: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
EndProcedure

; ----

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
  ; Resize gadgets
  ResizeGadget(#MainScrollArea, 0, 0, dx, dy)
EndProcedure

; ----

Procedure Main()
  Protected dx, dy
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("Test")
    MenuItem(1,"Resize ScrollAreay")
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
    ScrollAreaGadget(#MainScrollArea, 0, 0, dx, dy, dx * 2, dy * 3)
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    BindGadgetEvent(#MainScrollArea, @DoEventResizeScrollArea(), #PB_EventType_Resize)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
            
          Case 1
             ResizeGadget(#MainScrollArea, 0, 0, dx/2, dy/2)
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainScrollArea
              Select EventType()
                Case #PB_EventType_Resize
                  ;Debug "Main Loop: dx = " + GadgetWidth(#MainScrollArea) + " / dy = " + GadgetHeight(#MainScrollArea)
                  
              EndSelect
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
Sorry, it does not work :)
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by mk-soft »

What is not work ???

Works here unter macOS, window, linux ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

mk-soft wrote: Sun Mar 27, 2022 12:36 am What is not work ???

Works here unter macOS, window, linux ...
Dear, you force me to repost my message:
About resizing a ScrollAreaGadget() there is found what is called a "bug", or wrong manual:

From the manual in the ScrollAreaGadget() entry:
The following event is supported through EventType():
#PB_EventType_Resize: The gadget has been resized.
Why is not working? :shock: :?: :?: :?:
So please, post something to argue this, or else, keep peacefully.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by mk-soft »

Sorry,
Then I don't understand what you mean or why it doesn't work for you.

In the PB help it says that after changing the gadget size with ResizeGadget() the event PB_Event_Gadget is triggered on the ScrollAreaGadget and with EventType() the event #PB_EventType_Resize can be queried.

Or maybe show me the code where it doesn't work.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

mk-soft wrote: Sun Mar 27, 2022 2:30 pm Sorry,
Then I don't understand what you mean or why it doesn't work for you.

In the PB help it says that after changing the gadget size with ResizeGadget() the event PB_Event_Gadget is triggered on the ScrollAreaGadget and with EventType() the event #PB_EventType_Resize can be queried.

Or maybe show me the code where it doesn't work.
Mhhh, ok, you win, I will try tomorrow to post a short video
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by Psychophanta »

http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Resize Windows and make scrollbar appear ? [Solved]

Post by RASHAD »

Hi Psychophanta
I hope that I just understood you correctly
After resize you can do what you want with the gadget

Code: Select all

Procedure SizeCB()
  w = WindowWidth(0)
  h = WindowHeight(0)
  ResizeGadget(0,10,10,w-20,h-20)
EndProcedure

OpenWindow(0, 0, 0, 800,600, "test",  #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget |  #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
ScrollAreaGadget(0, 10, 10, 780,580 , 2000,1500, 30)
;add some other gadgets...
CloseGadgetList()
BindEvent(#PB_Event_SizeWindow,@sizeCB())
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow 
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_Resize  ;The gadget has been resized.
              SetGadgetAttribute(0, #PB_ScrollArea_X, 2000)
              hpos = GetGadgetAttribute(0, #PB_ScrollArea_X)
    
              SetGadgetAttribute(0, #PB_ScrollArea_Y, 1500)
              vpos = GetGadgetAttribute(0, #PB_ScrollArea_Y)              

              SetGadgetAttribute(0, #PB_ScrollArea_X, hpos/2)
              SetGadgetAttribute(0, #PB_ScrollArea_Y, vpos/2)
          EndSelect
      EndSelect
  EndSelect
Until Quit = 1
Egypt my love
Post Reply