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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimum window height\width

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
How do you define a clean minimum height and width for a form? I have currently, a function that if the width\height is less than or equal to a certain number, it should stay at that number. the problem is then that when the user tries to make it smaller, it jumps back to the designated sopt. it doesnt just sit there. it jumps back and forth when the user tries to drag it in.
I'm trying to make sense here, I hope that did it.
If anybody has a solution here, please let me know. I've been looking at sites all day trying to get an answer.


Thanks, Cyprus
 
You need to use WM_GETMINMAXINFO. More info is available from Borland C++ Builder How-To:The Definitive C++ Builder Problem-Solver by John Miano, Tom Cabanski, and Harold Howe. Look at Chapter 1 section 1.4. The following code comes from their CD.
Code:
void __fastcall TForm1::WMGetMinMaxInfo(TWMGetMinMaxInfo &Msg)
{
  Msg.MinMaxInfo->ptMaxSize.x=300; //ptMaxSize is the size of the window
  Msg.MinMaxInfo->ptMaxSize.y=250; //when the window is fully maximized

  // ptMaxPosition is the coordinate of the frame’s upper left
  // corner when it’s maximized.
  Msg.MinMaxInfo->ptMaxPosition.x=GetSystemMetrics(SM_CXSCREEN)-300;
  Msg.MinMaxInfo->ptMaxPosition.y=0;

  Msg.MinMaxInfo->ptMaxTrackSize.x=300; //ptMaxTrackSize = max size allowed
  Msg.MinMaxInfo->ptMaxTrackSize.y=250; //by dragging with the mouse

  Msg.MinMaxInfo->ptMinTrackSize.x=170; //ptMinTrackSize = min size allowed
  Msg.MinMaxInfo->ptMinTrackSize.y=150; //by dragging with the mouse.
}

In addition, they included the following declaration in the header file under the private section.
Code:
void __fastcall WMGetMinMaxInfo(TWMGetMinMaxInfo &Msg);  // prototype for msg handler

They also have the following code in the public section.
Code:
BEGIN_MESSAGE_MAP
  MESSAGE_HANDLER (WM_GETMINMAXINFO,TWMGetMinMaxInfo,WMGetMinMaxInfo)
END_MESSAGE_MAP(TForm)

If you still have the disk this source code is under X:\Source\Chapter 1\Ht04. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that they think I am now
qualified to do anything with nothing.
 
In bcb 5 there is MinWidth, MinHeight, MaxWidth and MaxHeight properties when you expand the Constraints item. [pc3]
 
Thanks, both of you. That was exactly what I was looking for Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top