Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling form size with maxheight and maxwidth

Status
Not open for further replies.

samsnead

Programmer
Sep 3, 2005
100
CA
I want to set the maxheight and width properties and then control form size if user uses the maximize button. Setting these properties works if user uses mouse to drag and resize forms but not if using the maxbutton. I tried putting following code in resize but didn't work so any suggestions would be appreciated.

IF THISFORM.MaxHeight<>-1
IF THISFORM.Height>THISFORM.MaxHeight
THISFORM.Height=THISFORM.MaxHeight
ENDIF
ENDIF
IF THISFORM.MaxWIDTH<>-1
IF THISFORM.WIDTH>THISFORM.MaxWIDTH
THISFORM.WIDTH=THISFORM.MaxWIDTH
ENDIF
ENDIF

THISFORM.REFRESH
 
I wanted them to be able to maximize but control what happens - might have to resort to this.
 

Sam,

Your code looks more or less OK. But trying adding something like this:

IF THISFORM.WindowState = 2
NODEFAULT
ENDIF

I'm not sure if it will work, but it might be worth a try.

Also, take out the Refresh. That doesn't affect the form size and will just slow things down.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike - that does change how screen is displayed (but first time in still goes to max - then if I click the max button - it doesn't go back to original size but goes to size I want!

You know this is all your doing - saw your article in Advisor on Resizeable forms and decided to experiment. I will post my notes when done. Thanks for all the help.
 

Sam,

Yes, let us know what you discover.

For what it's worth, I now disable the Max button whenever I impose a maximum height and width. I think it's better, user interface-wise.

Then again, there are lot of apps out there that do what you are trying to do. The Find Message dialogue in Outlook Express is one that comes to mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Sam,

OK, how about this ....

Create an assign method on the form's WindowState property. Then add this code:

Code:
LPARAMETERS vNewVal
*To do: Modify this routine for the Assign method

IF vNewVal = 2
  thisform.Height = thisform.MaxHeight 
  thisform.Width = thisform.MaxWidth 
  thisform.WindowState = 0
ENDIF

That seems to work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top