to Zythum:<br><br>Croco已经说出了思路,这是我总结的(C++Builder程序,我注释得这么清楚,<br>你应该能看懂),已经很完善了.<br><br>Form1源文件: Unit1.cpp<br><br>//---------------------------------------------------------------------------<br>#include <vcl.h><br>#pragma hdrstop<br><br>#include "Unit1.h"<br>//---------------------------------------------------------------------------<br>#pragma package(smart_init)<br>#pragma resource "*.dfm"<br>TForm1 *Form1;<br>//---------------------------------------------------------------------------<br>__fastcall TForm1::TForm1(TComponent* Owner)<br> : TForm(Owner)<br>{<br>}<br>//---------------------------------------------------------------------------<br><br>void __fastcall TForm1::FormResize(TObject *Sender)<br>{<br> Label1->Caption = "宽度 = " + AnsiString(Width) +<br> " 高度 = " + AnsiString(Height);<br>}<br>//---------------------------------------------------------------------------<br>void __fastcall TForm1::WMGetMinMaxInfo(TWMGetMinMaxInfo &Msg) //++<br>{<br> /*<br> 一般是这样操作的:<br> 将窗体的 Form1->Width , Form1->Height 设置为正常时的尺寸,一般来说<br> Form1->Width = ptMinTrackSize.x;<br> Form1->Height = ptMinTrackSize.y;<br> */<br> /*<br> 规则:<br> Form1->Width 与 ptMaxSize.x , ptMaxTrackSize.x , ptMinTrackSize.x 是同步的<br> Form1->Height 与 ptMaxSize.y , ptMaxTrackSize.y , ptMinTrackSize.y 是同步的<br> ptMaxTrackSize.x >= ptMinTrackSize.x<br> ptMaxTrackSize.y >= ptMinTrackSize.y<br> ptMaxSize.x == ptMaxTrackSize.x<br> ptMaxSize.y == ptMaxTrackSize.y<br> 窗体刚生成时:<br> 若 Form1->Height < ptMinTrackSize.y , 则以 ptMinTrackSize.y 为准<br> 若 Form1->Height > ptMinTrackSize.y , 则以 Form1->Height 为准<br> 若 Form1->Width > ptMinTrackSize.x , 则以 Form1->Width 为准<br> 若 Form1->Width < ptMinTrackSize.x , 则以 ptMinTrackSize.x 为准<br> */<br><br> /*当窗体最大化时,窗体的宽度和高度*/<br> Msg.MinMaxInfo->ptMaxSize.x=500;<br> Msg.MinMaxInfo->ptMaxSize.y=130;<br><br> /*当窗体最大化时,窗体左上角的横,纵坐标*/<br> Msg.MinMaxInfo->ptMaxPosition.x=GetSystemMetrics(SM_CXSCREEN)-600;<br> Msg.MinMaxInfo->ptMaxPosition.y=0;<br><br> /*当用鼠标拖拽时,窗体允许的最大宽度和高度*/<br> Msg.MinMaxInfo->ptMaxTrackSize.x=500;<br> Msg.MinMaxInfo->ptMaxTrackSize.y=130;<br><br> /*当用鼠标拖拽时,窗体允许的最小宽度和高度*/<br> Msg.MinMaxInfo->ptMinTrackSize.x=275;<br> Msg.MinMaxInfo->ptMinTrackSize.y=120;<br>}<br><br>Form1头文件: Unit1.h<br><br>//---------------------------------------------------------------------------<br>#ifndef Unit1H<br>#define Unit1H<br>//---------------------------------------------------------------------------<br>#include <Classes.hpp><br>#include <Controls.hpp><br>#include <StdCtrls.hpp><br>#include <Forms.hpp><br>//---------------------------------------------------------------------------<br>class TForm1 : public TForm<br>{<br>__published: // IDE-managed Components<br> TLabel *Label1;<br> void __fastcall FormResize(TObject *Sender);<br>private: // User declarations<br> void __fastcall WMGetMinMaxInfo(TWMGetMinMaxInfo &Msg); //++<br>public: // User declarations<br> __fastcall TForm1(TComponent* Owner);<br>BEGIN_MESSAGE_MAP //++<br> MESSAGE_HANDLER(WM_GETMINMAXINFO,TWMGetMinMaxInfo,WMGetMinMaxInfo) //++<br>END_MESSAGE_MAP(TForm) //++<br>};<br>//---------------------------------------------------------------------------<br>extern PACKAGE TForm1 *Form1;<br>//---------------------------------------------------------------------------<br>#endif<br>