It is currently Thu May 28, 2020 4:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 161 posts ]  Go to page 1, 2, 3, 4, 5 ... 11  Next
Author Message
 Post subject: PureRESIZE library : gadget automatic resizing and more
PostPosted: Sat Dec 11, 2004 8:44 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
PureRESIZE library V6.2x (MAR 22th 2013)

Purpose
Code:
Automatically resizing gadgets, monitoring window size and position


Functions
http://gnozal.ucoz.com/PureRESIZE_.htm

Example
Code:
If OpenWindow(0, 0, 0, 500, 300, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered, "Mini-Browser")
  CreateGadgetList(WindowID())
  ButtonGadget(1, 0, 0, 50, 25, "Back")
  ButtonGadget(2, 50, 0, 50, 25, "Next")
  ButtonGadget(3, 100, 0, 50, 25, "Stop")
  StringGadget(4, 150, 3, 325, 20, "C:\Program Files\Nvu\gnozal\index.html")
  ButtonGadget(5, 475, 0, 25 , 25, "Go")
  Frame3DGadget(6, 1, 30, 500, 2, "", 2)
  If WebGadget(10, 5, 35, 490, 260, "") = 0
    MessageRequester("Error", "ATL.dll not found", 0)
    End
  EndIf
  AddKeyboardShortcut(0, #PB_Shortcut_Return, 0)
  ; Define callback
  SetWindowCallback(@WindowCallBack())
  ; Set window minimum size
  PureRESIZE_SetWindowMinimumSize(0, 450, 250)
  ; Set gadget resize options
  PureRESIZE_SetGadgetResize(4, #True, #True, #True, #False)
  PureRESIZE_SetGadgetResize(5, #False, #True, #True, #False)
  PureRESIZE_SetGadgetResize(6, #True, #True, #True, #False)
  PureRESIZE_SetGadgetResize(10, #True, #True, #True, #True)

  ;PureRESIZE_SetWindowMonitoring(0, #PureRESIZE_Monitoring_DontMove)
  ;PureRESIZE_SetWindowMonitoring(0, ~#PureRESIZE_Monitoring_DontMove)
  ;PureRESIZE_SetWindowMonitoring(0, #PureRESIZE_Monitoring_DontResize)
  ;PureRESIZE_SetWindowMonitoring(0, ~#PureRESIZE_Monitoring_DontResize)

  ; Envent loop
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
        Select EventGadgetID()
          Case 1
            SetGadgetState(10, #PB_Web_Back)
          Case 2
            SetGadgetState(10, #PB_Web_Forward)
          Case 3
            SetGadgetState(10, #PB_Web_Stop)
          Case 5
            SetGadgetText(10, GetGadgetText(4))
        EndSelect
      Case #PB_Event_Menu
        SetGadgetText(10, GetGadgetText(4))
    EndSelect
  Until Event = #PB_Event_CloseWindow
EndIf


Download
Only available for Purebasic Windows x86
PB3.94 : http://gnozal.ucoz.com/PureRESIZE.zip
PB4.0x-4.20 : http://gnozal.ucoz.com/PureRESIZE_.zip
PB4.3x : http://gnozal.ucoz.com/PureRESIZE_430.zip
PB4.4x : http://gnozal.ucoz.com/PureRESIZE_440.zip
PB4.5x : http://gnozal.ucoz.com/PureRESIZE_450.zip
PB4.6x : http://gnozal.ucoz.com/PureRESIZE_460.zip
PB5.0x : http://gnozal.ucoz.com/PureRESIZE_500.zip
PB5.1x : http://gnozal.ucoz.com/PureRESIZE_510.zip

Other libs and tools at http://gnozal.ucoz.com/


Last edited by gnozal on Tue Aug 18, 2009 11:48 am, edited 30 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 11, 2004 1:08 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
i tried and it works very well.

please, Minimum size of window is usefull, Maximum size also...
in my project i use :
Code:
Global MiniX,MiniY,MaxiX,MaxiY

MiniX = 150
MiniY = 150
MaxiX = GetSystemMetrics_(#SM_CXSCREEN)
MaxiY = 150

Procedure GUI_CB(WindowID,Message,wParam,lParam)
 
  Result = #PB_ProcessPureBasicEvents
 
  Select Message
   
    Case #WM_GETMINMAXINFO
      *pMinMax.MINMAXINFO=lParam
      *pMinMax\ptMinTrackSize\x=MiniX
      *pMinMax\ptMinTrackSize\y=MiniY
      *pMinMax\ptMaxTrackSize\x=MaxiX
      *pMinMax\ptMaxTrackSize\y=MaxiY
      Result = #Null
  EndSelect
 
  ProcedureReturn PureRESIZE_CallBack(WindowID,Message,wParam,lParam,Result)
 
EndProcedure

If OpenWindow(0,0,0,350,150,#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered,"Test")
  If CreateGadgetList(WindowID(0))
    Frame3DGadget(0,5,5,340,140,"",#PB_Frame3D_Single)
    PureRESIZE_SetGadgetResize(0,#True,#True,#True,#True)
    SetWindowCallback(@GUI_CB())
    Repeat : Until WaitWindowEvent()=#wm_close
  EndIf
EndIf


So description function like that :

PureRESIZE_SetWindowMaximumSize(WindowId.l,Width.w,Height.w)
; With Width = -1 : GetSystemMetrics_(#SM_CXSCREEN)
; With Height = -1 : GetSystemMetrics_(#SM_CYSCREEN)

thanx for advance

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 11, 2004 2:31 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
bug

doesn't work on panel gadget

here is a GUI test :

Code:
Procedure GUI_CB(WindowID,Message,wParam,lParam)
  Result=#PB_ProcessPureBasicEvents
  Result=PureRESIZE_CallBack(WindowID,Message,wParam,lParam,Result)
  ProcedureReturn Result
EndProcedure

Enumeration
  #gFrame
  #gPanel
  #gPanelB1
  #gPanelB2
  #gContainer
  #gContainerB1
EndEnumeration

OpenWindow(0, 303, 182, 347, 300, #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered,"")
CreateGadgetList(WindowID(0))
Frame3DGadget(#gFrame, 5, 5, 335, 75, "Frame3D Gadget", #PB_Frame3D_Single)
PanelGadget(#gPanel, 5, 85, 335, 100)
AddGadgetItem(#gPanel,-1,"Panel Gadget - 1")
ButtonGadget(#gPanelB1,5,5,320,22,"Button inside Panel Gadget - 1")
AddGadgetItem(#gPanel,-1,"Panel Gadget - 2")
ButtonGadget(#gPanelB2,5,5,320,22,"Button inside Panel Gadget - 2")
CloseGadgetList()
ContainerGadget(#gContainer,5,190,335,105,#PB_Container_Flat)
ButtonGadget(#gContainerB1,5,5,325,95,"Button inside Container Gadget")
CloseGadgetList()

PureRESIZE_SetGadgetResize(#gFrame, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanel, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainer, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainerB1, #True, #True, #True, #True)

SetWindowCallback(@GUI_CB())

Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow

End

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 13, 2004 8:46 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

- some fixes
- renamed functions
- new functions

Quote:
bug
doesn't work on panel gadget

I will take a look. Thanks for your report.

Please note : I didn't mean to offend anybody with this lib !


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 13, 2004 11:50 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Mar 24, 2004 11:04 pm
Posts: 902
Location: Seattle, USA
gnozal,
I think the RESIZE code, along with your additional procedures, packaged as a PB library will be very useful to many folks - thanks again.
The only thing they need to be aware of is that it is platform-specific to Windows with the callback.
Perhaps sometime, when I can find the time, I'll package my cross-platform ReSize code as a PB library as well. But right now using the source code isn't too difficult.
:D


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 14, 2004 8:33 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

- fixed PanelGadget not resizing

But, there is a strange incompatibility (interference ?) between PanelGadget and ContainerGadget. Will be fixed soon.


Last edited by gnozal on Wed Dec 15, 2004 8:36 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 15, 2004 8:36 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update

Should now work for all gadgets

- fixed PureContainer / PanelGadget interference (the code example below now works)

It seems that PureContainer requires the callback to handle #WM_SIZE and #WM_SIZING messages (for all others gadgets, handling #WM_SIZE only seems enough).

Example :
Code:
Procedure GUI_CB(WindowId,Message,wParam,lParam)
  Result=#PB_ProcessPureBasicEvents
  Result=PureRESIZE_CallBack(WindowId,Message,wParam,lParam,Result)
  ProcedureReturn Result
EndProcedure

Enumeration
  #gFrame
  #gPanel
  #gPanelB1
  #gPanelB2
  #gContainer
  #gContainerB1
EndEnumeration

OpenWindow(0, 303, 182, 347, 300, #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered,"")
CreateGadgetList(WindowID(0))
Frame3DGadget(#gFrame, 5, 5, 335, 75, "Frame3D Gadget", #PB_Frame3D_Single)
PanelGadget(#gPanel, 5, 85, 335, 100)
AddGadgetItem(#gPanel,-1,"Panel Gadget - 1")
ButtonGadget(#gPanelB1,5,5,320,22,"Button inside Panel Gadget - 1")
AddGadgetItem(#gPanel,-1,"Panel Gadget - 2")
ButtonGadget(#gPanelB2,5,5,320,22,"Button inside Panel Gadget - 2")
CloseGadgetList()
ContainerGadget(#gContainer,5,190,335,105,#PB_Container_Flat)
ButtonGadget(#gContainerB1,5,5,325,95,"Button inside Container Gadget")
CloseGadgetList()

PureRESIZE_SetGadgetResize(#gFrame, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanel, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanelB1, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanelB2, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gContainer, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainerB1, #True, #True, #True, #True)

SetWindowCallback(@GUI_CB())

Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow

End


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 15, 2004 8:39 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
good news 8)

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 29, 2004 5:54 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
hi, hope christmas was good.
I'm coming back with a little but annoying bug.

In the example bellow, when the user maximize the window by clicking in the system menu, the new size is not detected.
Code:
; ---------------------------------------------
;            PureRESIZE test file 2
; ---------------------------------------------
;
Procedure GUI_CB(WindowId,Message,wParam,lParam)
  Result=#PB_ProcessPureBasicEvents
  Result=PureRESIZE_CallBack(WindowId,Message,wParam,lParam,Result)
  ProcedureReturn Result
EndProcedure

Enumeration
  #gFrame
  #gPanel
  #gPanelB1
  #gPanelB2
  #gContainer
  #gContainerB1
EndEnumeration

OpenWindow(0, 303, 182, 347, 300, #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered,"")
CreateGadgetList(WindowID(0))
Frame3DGadget(#gFrame, 5, 5, 335, 75, "Frame3D Gadget", #PB_Frame3D_Single)
PanelGadget(#gPanel, 5, 85, 335, 100)
AddGadgetItem(#gPanel,-1,"Panel Gadget - 1")
ButtonGadget(#gPanelB1,5,5,320,22,"Button inside Panel Gadget - 1")
AddGadgetItem(#gPanel,-1,"Panel Gadget - 2")
ButtonGadget(#gPanelB2,5,5,320,22,"Button inside Panel Gadget - 2")
CloseGadgetList()
ContainerGadget(#gContainer,5,190,335,105,#PB_Container_Flat)
ButtonGadget(#gContainerB1,5,5,325,95,"Button inside Container Gadget")
CloseGadgetList()

PureRESIZE_SetGadgetResize(#gFrame, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanel, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanelB1, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gPanelB2, #True, #True, #True, #False)
PureRESIZE_SetGadgetResize(#gContainer, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainerB1, #True, #True, #True, #True)

SetWindowCallback(@GUI_CB())

Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow

End

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 30, 2004 8:38 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
You are right... :cry: It works for example 1 but not for example 2. It's a gadget inside gadget thing ...
I probably forgot something in the callback ; I will take a look.
Thanks for the report.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 31, 2004 8:30 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Library update
- fixed PureContainer not resizing after a WM_MOVE event (this gadget really does not behave like the others)
- help is now CHM

Please report any bugs.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Dec 31, 2004 4:10 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
hummm, the bug is corrected for the source example, but not for my program.
my source includes many gadgets ( over 50... ).
i'm trying to locate with precision the problem and i'll tell you in which case it happens.

more i'll appreciate if you can include this function :
PureResize_SetWindowMaximumSize(WindowNumber.l, MaximumWidth.l, MaximumHeight.l)

or
PureResize_SetWindowSize(WindowNumber.l, MinimumWidth.l, MinimumHeight.l, MaximumWidth.l, MaximumHeight.l))

based on this code for example :
Code:
;-
;- PART 1 - RESIZE STUFF
;-

Structure RESIZE_WindowStruct
 
  Handle.l      ; Handle of Window
  MinWidth.w    ; Minimum width
  MinHeight.w   ; Minimum height
  MaxWidth.w    ; Maximum width
  MaxHeight.w   ; Maximum height
 
EndStructure

NewList RESIZE_Window.RESIZE_WindowStruct()

Procedure.b RESIZE_SetWindow(Window.l,MinWidth.w,MinHeight.w,MaxWidth.w,MaxHeight.w)
 
  Protected Window.l,MinWidth.w,MinHeight.w,MaxWidth.w,MaxHeight.w
 
  If AddElement(RESIZE_Window()) = #False
    ProcedureReturn #False
  EndIf
 
  If MaxWidth = -1
    MaxWidth = GetSystemMetrics_(#SM_CXSCREEN)
  EndIf
 
  If MaxHeight = -1
    MaxHeight = GetSystemMetrics_(#SM_CYSCREEN)
  EndIf
 
  RESIZE_Window()\Handle    = WindowID(Window)
  RESIZE_Window()\MinWidth  = MinWidth
  RESIZE_Window()\MinHeight = MinHeight
  RESIZE_Window()\MaxWidth  = MaxWidth
  RESIZE_Window()\MaxHeight = MaxHeight
 
  ProcedureReturn #True
 
EndProcedure

Procedure RESIZE_Callback(WindowID,Message,wParam,lParam,Result)
 
  If (Message=#WM_GETMINMAXINFO)
   
    ForEach RESIZE_Window()
     
      If RESIZE_Window()\Handle = WindowID
       
        *rs_MinMax.MINMAXINFO = lParam
        *rs_MinMax\ptMinTrackSize\x = RESIZE_Window()\MinWidth
        *rs_MinMax\ptMinTrackSize\y = RESIZE_Window()\MinHeight
        *rs_MinMax\ptMaxTrackSize\x = RESIZE_Window()\MaxWidth
        *rs_MinMax\ptMaxTrackSize\y = RESIZE_Window()\MaxHeight
       
        ProcedureReturn #Null
       
      EndIf
     
    Next
   
  EndIf
 
  ProcedureReturn Result
 
EndProcedure

;-
;- PART 2 - TEST EXAMPLE
;-

Procedure GUI_CB(WindowID,Message,wParam,lParam)
 
  Result = #PB_ProcessPureBasicEvents
  Result = RESIZE_Callback(WindowID,Message,wParam,lParam,Result)
  ProcedureReturn Result
 
EndProcedure

OpenWindow(0,0,0,320,240,#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered,"rs_lib Test")

RESIZE_SetWindow(0,220,140,420,340)
;RESIZE_SetWindow(0,220,140,-1,-1)

SetWindowCallback(@GUI_CB())

Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow

End

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 03, 2005 9:57 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Flype wrote:
hummm, the bug is corrected for the source example, but not for my program.
my source includes many gadgets ( over 50... ).
i'm trying to locate with precision the problem and i'll tell you in which case it happens.

Thanks, I can't fix it if I don't have an example.
Have you tried to call the PureRESIZE_SetGadgetResize() functions in a different order ?
for example :
PureRESIZE_SetGadgetResize(#gContainerB1, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainer, #True, #True, #True, #True)
instead of :
PureRESIZE_SetGadgetResize(#gContainer, #True, #True, #True, #True)
PureRESIZE_SetGadgetResize(#gContainerB1, #True, #True, #True, #True)
The gadgets are resized in the same order in the callback, so it could explain some 'bugs' ? Maybe I should resize the 'container gadgets' like panel / container before the gadgets ? Any idea ?

Flype wrote:
more i'll appreciate if you can include this function :
PureResize_SetWindowMaximumSize(WindowNumber.l, MaximumWidth.l, MaximumHeight.l)

Ok, I will add this.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 03, 2005 1:24 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jul 22, 2003 5:02 pm
Posts: 1542
Location: In a long distant galaxy
yes you are right, in a specific order, it works but it's becoming a little bit tricky as long as my source code grows...

thanx for adding the Maximize function. :wink:

_________________
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 03, 2005 3:11 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat Apr 26, 2003 8:27 am
Posts: 4229
Location: Strasbourg / France
Flype wrote:
yes you are right, in a specific order, it works but it's becoming a little bit tricky as long as my source code grows...

Could you provide some code ?
All my test programs run well.

_________________
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).


Last edited by gnozal on Sat Jan 29, 2005 12:56 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 161 posts ]  Go to page 1, 2, 3, 4, 5 ... 11  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye