Prevent Window Resizing

Share your advanced PureBasic knowledge/code with the community.
Slyvnr
User
User
Posts: 58
Joined: Wed Jun 27, 2007 10:10 pm
Location: USA
Contact:

Prevent Window Resizing

Post by Slyvnr »

Ok, you have designed a data entry form that looks perfect. But if you resize the window either weird things start to happen or the perfectness of your creation is destroyed. Would you like to prevent people from resizing your window so that all the glory of your hard efforts can be seen in the correct setting?

Yes the above is suppose to be laced with a bit of sarcasm but there may be situations where you do not want the window to be resized by the end user. I recently encountered this and here is the solution.

Code: Select all

WindowBounds(windowID, minimum x, minimum y, maximum x, maximum y)
If you set the minimum and maximum values to your default window size in your OpenWindow() command then the user is effectively prohibited from resizing the window.

Of course if you want them to be able to resize the window some but not a lot you could also set the values such that they have a little leeway and can actual resize the window some but not a lot.

Slyvnr
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: Prevent Window Resizing

Post by USCode »

Maybe I don't completely understand your issue but if you don't want the window to be resized AT ALL then why don't you just create your window WITHOUT the #PB_Window_SizeGadget flag?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Prevent Window Resizing

Post by blueznl »

It may be a trick but this doesn't look like a tip :-)
( 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... )
Slyvnr
User
User
Posts: 58
Joined: Wed Jun 27, 2007 10:10 pm
Location: USA
Contact:

Re: Prevent Window Resizing

Post by Slyvnr »

Doh!
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: Prevent Window Resizing

Post by kvitaliy »

One more dynamic way:

Code: Select all

If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  ButtonGadget(1,10,10,180,20,"No resize!",0)
 
Repeat
EventID=WaitWindowEvent()
If EventID=#PB_Event_Gadget
  Select EventGadget()
    Case 1
      SetWindowLongPtr_(WindowID(0),#GWL_STYLE,GetWindowLongPtr_(WindowID(0),#GWL_STYLE)&~#WS_THICKFRAME)
    EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf
Post Reply