|
책에있는 겁니다.
님께서는
Msg.MinMaxInfo->ptMinTrackSize.x=170; //ptMinTrackSize = min size allowed
Msg.MinMaxInfo->ptMinTrackSize.y=150; //by dragging with the mouse.
부분을 사용하시면 될것같은데...
마우스 고정은 안되지만 깔끔하지요..
//---------------------------------------------------------------------------
#ifndef MAINFORMH
#define MAINFORMH
//---------------------------------------------------------------------------
#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
void __fastcall FormResize(TObject *Sender);
private: // User declarations
void __fastcall WMGetMinMaxInfo(TWMGetMinMaxInfo &Msg); // prototype for msg handler
public: // User declarations
__fastcall TForm1(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_GETMINMAXINFO,TWMGetMinMaxInfo,WMGetMinMaxInfo)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "MAINFORM.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
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뭩 upper left
// corner when it뭩 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.
}
void __fastcall TForm1::FormResize(TObject *Sender)
{
Label1->Caption = "Width = " + AnsiString(Width) +
" Height = " + AnsiString(Height);
}
//---------------------------------------------------------------------------
.끝.
샘이 님이 쓰신 글 :
: 만약 TMainForm 이라는 것이 있을 때...
: 폼크기의 최소크기가 320x200 일 때...
:
: TMainForm::FormResize(...)
: {
: if (Width<320) Width=320;
: if (Height<200) Height=200;
: }
:
: 위와 같이 하면 폼크기 최소값을 유지하지만
: 마우스가 폼크기 최소값보다 적은 위치에 갈 수 있게 됩니다.
: 따라서 폼크기가 작아졌다 커졌다하면서 최소값을 유지하게 되는데
: 최소값이 되었을 때는 마우스가 더이상 움직이지 않았으면 합니다.
: 어떻게 하면 되죠?
|