but when i tried them, they seemed not to work too good,
so i decided to post my version.
To the poeple who posted similar examples:
I am not claiming your way of doing it is wrong, but at least one
of the examples seemed to slowly resize the statusbar fields
until all but the last one disappreared

Never the less without these examples i would not have been
able to write this code!
Code: Select all
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#Gadget_0 = 0
#Gadget_1 = 1
;- StatusBar Constants & Variables
;
#StatusBar_0 = 0
Global hStatusBar.l ; Will hold the Statusbar ID (?)
Dim Fields.l(3) ; Used to send new Parameters to the Statusbar
Procedure WinCallback(wid,Msg,wPar,lPar)
ret=#PB_ProcessPureBasicEvents
Select Msg
Case #WM_SIZE : ; Default Dimensions in pixel
; x, y, w, h
; Window: 300,300,600,340
; Tree: 0, 0,150,300
; List: 150, 10,450,300
; StatF0: - , - ,150, -
; StatF1: - , - ,150, -
; StatF2: - , - ,310, -
;
;- Calculate the size of the GUI Elements
; in percent of Windowsize.
; Horizontal (width)
; 1% of Window: 600/100=6 pixel
; Tree: 150/6=25%
; List: 450/6=75%
; StatF0: 150/6=25%
; StatF1: 150/6=25%
; StatF2: 300/6=50%
;
; Vertical (height)
; Currently not needed, since all gadgets are full height.
; But when needed, the gadget height needs to be calculated
; by taking the Menu- and Statusbar-Height into account.
; ie.: wh.f=(WindowHeight()-(2*MenuHeight()))
;-> assuming that StatusbarHeight = MenuHeight <-
;
If (EventWindowID()=#Window_0)
; ^^ NEEDED IN AN MULTI-WINDOW APPLICATION
;- Resize Main Windows Contents
; NOTE: I use floats to hold the Window-Width and -Height
; to avoid rounding DURING the Calculation,
; this may not be needed, but better save than sorry!
; Also, for the same reason, i always multiply a number
; before deviding it, this should not be needed with the
; relatively small float-numbers used here,
; but SHOULD always be used when doing similar
; calculations on larger floats and integers!
; 1. Gadgets
UseWindow(#Window_0)
; ^^ MAY BE NEEDED IN AN MULTI-WINDOW APPLICATION
ww.f=WindowWidth() : x.l=0 : y.l=0
h.l=(WindowHeight()-(2*MenuHeigh()))
; ^^ THIS ASSUMES STATUSBAR & MENU ARE THE SAME HEIGHT
w.l=((ww.f*25.00)/100.00)
ResizeGadget(#Gadget_0,x,y,w,h)
x.l=x.l+w.l : w.l=((ww.f*75.00)/100.00)
ResizeGadget(#Gadget_1,x,y,w,h)
; 2. Statusbar
UpdateStatusBar(#StatusBar_0)
; right edge of first field (25% of Windows width - only happens to be 1/4)
Fields.l(0)=((ww.f*25.00)/100.00)
; right edge of second field (50% of Windows width - only happens to be 1/2)
Fields.l(1)=((ww.f*50.00)/100.00)
; right edge of last field (100% of Windows width - always 1/1)
Fields.l(2)=ww.f
SendMessage_(hStatusBar,#SB_SETPARTS,3,@Fields())
;RedrawWindow_(WindowID(#Window_0),0,0,#RDW_INVALIDATE)
; ^^ -> CURRENTLY NOT NEEDED! <-
ret=1
EndIf
Case #WM_GETMINMAXINFO :
;- Set minimum Windowsize
;
; NOTE: This seems to set the INNER minimum width and height
; or the Values in `Fields()` used above is altered
; during the system Call
;
; Anybody can tell me where i can find Bordersizes?
; PLEASE!
;
If (EventWindowID()=#Window_0)
; ^^ NEEDED IN AN MULTI-WINDOW APPLICATION
*ptr.MINMAXINFO = lPar
*ptr\ptMinTrackSize\x = 600 ; min width
*ptr\ptMinTrackSize\y = 340 ; min height
ret = 0
EndIf
EndSelect
ProcedureReturn ret
EndProcedure