Size limits on a resizable window?

Windows specific forum
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Size limits on a resizable window?

Post by RichardL »

Hi,
I have used PureResize() for a long time, but as the developer seems to have gone silent I'm having to write my own version so I can upgrade to the most recent version of PB. I have 90% of the functionality working OK, but having problems with restricting the maximum and minimum size of a standard resizable window. Can someone please nudge me in the right direction, please.

This is a skeleton of a general PB program... I would really like a platform independent method of imposing limits but if push comes to shove a Windows only solution would be better than nothing!

Code: Select all

Procedure WinCallback(Win,msg,wParam,lParam) 
  Protected dx,dy
  
  Select msg 
      
    Case #WM_SIZE 
      ; 
      
  EndSelect
  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 
  

; Test code
OpenWindow(2,420,100,400,90,"Test2",#PB_Window_SystemMenu|#PB_Window_SizeGadget)
EditorGadget(3,5,5,190,20)               
EditorGadget(4,200,5,195,20)          
ButtonGadget(5,5,40,190,20,"Button 4") 
ButtonGadget(6,340,70,50,20,"Hello")    
SetWindowCallback(@WinCallback()) 

Repeat 
  
  
Until WaitWindowEvent() = #PB_Event_CloseWindow
Thanks...
RichardL
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 539
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Size limits on a resizable window?

Post by BasicallyPure »

Code: Select all

WindowBounds(#Window, MinimalWidth, MinimalHeight, MaximalWidth, MaximalHeight) 
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: Size limits on a resizable window?

Post by RASHAD »

For SetWindowCallback() and Native Command

Code: Select all

Procedure CallBack(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_GETMINMAXINFO
      *mminfo.MINMAXINFO = lParam
      *mminfo\ptMinTrackSize\x = 400 + 2*GetSystemMetrics_(#SM_CXFRAME)
      *mminfo\ptMinTrackSize\y = 400 + GetSystemMetrics_(#SM_CYMINTRACK)
      *mminfo\ptMaxTrackSize\x = 800 + 2*GetSystemMetrics_(#SM_CXFRAME)
      *mminfo\ptMaxTrackSize\y = 800 + GetSystemMetrics_(#SM_CYMINTRACK)
      result=0
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,400,400,"Min & Max size Restriction",#PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_SizeGadget| #PB_Window_ScreenCentered)
;WindowBounds(0, 400, 400, 800, 800)
SetWindowCallback(@CallBack())

Repeat:Until WaitWindowEvent()=#WM_CLOSE
Egypt my love
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Re: Size limits on a resizable window?

Post by RichardL »

Hi guys,

I've been programming with PB for a long, long time and never met WindowBounds() :oops:

Thank you both for your assistance.

RichardL
Post Reply