Page 1 of 1

Prevent Window Resizing

Posted: Wed Dec 01, 2010 4:46 pm
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

Re: Prevent Window Resizing

Posted: Wed Dec 01, 2010 7:30 pm
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?

Re: Prevent Window Resizing

Posted: Wed Dec 01, 2010 9:00 pm
by blueznl
It may be a trick but this doesn't look like a tip :-)

Re: Prevent Window Resizing

Posted: Thu Dec 02, 2010 3:34 pm
by Slyvnr
Doh!

Re: Prevent Window Resizing

Posted: Fri Dec 03, 2010 6:57 am
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