Is there an easy way to prevent a form window from being manually resized?
I found a solution but I’m having a problem with it. I’m using the Form Properties | Window Size settings, and by making both the minimum and maximum the same, the window can not be resized. Great!
The problem is that these minimum and maximum values are not updated if I use goform to move to a different size form.
For example, if I move to FORM-B and programmatically resize it to 200px by 200px, and then try to manually resize it, it will allow it, and will only resize it to 536px by 990px as defined in the previous form.
Note that FORM-B has it’s own settings set to 200px by 200px.
If I move into graphics mode and back, it updates the settings for that form as expected.
I was hoping for something simpler like: setwindowoptions "RESIZE","NO"
You could put some code in the Form Event Procedure of the Form Options panel to force any resize attempt to snap back to the desired size. This code will snap the window back to your stated size.
Hi Gary, I forgot to mention that I looked at that option. The idea is more to prevent from showing hidden stuff in some of the forms, only accessible to the developer.
Unfortunately, the formRESIZE event would be executed after the form has been already resized. Thank you for looking into this.
Instead of using goform, perhaps your application could use a tab panel. The main tab panel window can be set to a fixed size, then each panel is automatically centered within the panel when you switch to it. However, this would not allow hidden information within a panel. Instead, you could set up a separate form for the hidden information, or separate panels that are not normally accessible. For example, Panorama’s site license window uses this technique - different panels are visible depending on whether or not you are logged in, and what your privilege level is. The Preferences and Database Options panels use the same technique.
For a long time I have used a custom statement that I named FIXWINDOW. Anytime it is called it will do its window sizing thing. I just tried it with Goform followed by fixwindow, and it seems to work. Here’s the code from my custom statement:
formxy 0,0
setwindowoptions "Toolbar",false()
if getformoption("","","MAXIMUMHEIGHT")=0 or getformoption("","","MAXIMUMWIDTH")=0
beep
alertsheet "Max Height and/or Max Width are not set for this form."+cr()+cr()+"Form name: "+info("Formname")
return
endif
zoomwindow
getformoption("","","WINDOWTOPEDGE"),
getformoption("","","WINDOWLEFTEDGE"),
getformoption("","","MAXIMUMHEIGHT")+24,
getformoption("","","MAXIMUMWIDTH"), "notoolbars noscroll"
I have saved hours of dragging windows around with this statement.
I used Tom’s and Gary’s recommendation to create the following custom statement, which is called from the formRESIZE event:
if info("modifiers") notcontains "control"
sizewindow_c parameter(1),parameter(2)
endif
formxy 0,0
Holding the Control key while resizing the forms works as an override.
The statement gets the width and height of the form as parameters, then I don’t have to deal with the form options settings.
sizewindow_c is my custom statement replacement for the unimplemented sizewindow from Pan6.
If data needs to remain hidden, I will use Jim’s recommendation with Tab Panels.
Thank you everyone for your input.
What does your sizewindow_c code do? Call zoomwindow or zoomwindowrectangle? I can’t think of any other way it could work. But if that’s what you’re doing, it’s not immediately obvious to me why that would work. But if you say it does, great.
localparameters y,x
local left,top
left = rleft(info("windowrectangle"))
top = rtop(info("windowrectangle"))
zoomwindow top,left,y,x,info("windowoptions")