📄 main.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
float SplitterScale;
bool CanResizeFlag;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1Resize(TObject *Sender)
{
Memo1->Width=Panel1->Width;
Memo2->Width=Panel1->Width;
Panel2->Width=Panel1->Width;
Memo1->Height=SplitterScale*Form1->ClientHeight;
Panel2->Top=Memo1->Height;
Memo2->Top=Panel2->Top+Panel2->Height;
Memo2->Height=Form1->ClientHeight-Memo1->Height-Panel2->Height;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo2MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
int MoveRectTop,MoveRectBottom;
MoveRectTop=0-Panel2->Width;
MoveRectBottom=10;
if(Y>MoveRectTop&&Y<MoveRectBottom)
{
Memo2->Cursor=crVSplit;
CanResizeFlag=true;
}
else
{
Memo2->Cursor=crDefault;
CanResizeFlag=false;
}
if(Shift.Contains(ssLeft)&&CanResizeFlag)
{
Panel2->Top=Y;
Memo1->Height=Panel2->Top-1;
Memo2->Top=Panel2->Top-Panel2->Height+1;
Memo2->Height=Form1->ClientHeight-Memo1->Height-Panel2->Height;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
int MoveRectTop,MoveRectBottom;
MoveRectTop=Memo1->Height-10;
MoveRectBottom=Memo1->Height+Panel2->Width;
if(Y>MoveRectTop&&Y<MoveRectBottom)
{
Memo1->Cursor=crVSplit;
CanResizeFlag=true;
}
else
{
Memo1->Cursor=crDefault;
CanResizeFlag=false;
}
if(Shift.Contains(ssLeft)&&CanResizeFlag)
{
Panel2->Top=Y;
Memo1->Height=Panel2->Top-1;
Memo2->Top=Panel2->Top-Panel2->Height+1;
Memo2->Height=Form1->ClientHeight-Memo1->Height-Panel2->Height;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo1MouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
Memo1->Cursor=crDefault;
CanResizeFlag=false;
SplitterScale=(float)Memo1->Height/Form1->ClientHeight;
Memo1->Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo2MouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
Memo2->Cursor=crDefault;
CanResizeFlag=false;
SplitterScale=(float)Memo1->Height/Form1->ClientHeight;
Memo2->Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
SplitterScale=(float)Memo1->Height/Form1->ClientHeight;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -