📄 unit1.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#define NUM 50
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
void FormAnimate(HWND hWnd, BOOL Close);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void FormAnimate(HWND hWnd, BOOL Close)
{
int W, H;
RECT Rect;
HRGN hRgn;
HRGN hRgn0;
UINT uDelay;
hRgn0 = CreateRectRgn(0, 0, 0, 0);
if (GetWindowRgn(hWnd,hRgn0)==ERROR)
{
DeleteObject(hRgn0);
hRgn0 = NULL;
}
GetWindowRect(hWnd, &Rect);
W = Rect.right - Rect.left;
H = Rect.bottom - Rect.top;
for(int n=0; n<=NUM; n++)
{
int dx = (W/2) * n / NUM;
int dy = (H/2) * n / NUM;
if (!Close)
hRgn = CreateRectRgn(W/2-dx,H/2-dy,W/2+dx,H/2+dy);
else
hRgn = CreateRectRgn(dx, dy, W-dx, H-dy);
SetWindowRgn(hWnd, hRgn, 1);
UpdateWindow(hWnd);
DeleteObject(hRgn);
Sleep(500/NUM);
}
SetWindowRgn(hWnd, hRgn0, 0);
if (hRgn0) DeleteObject(hRgn0);
}
void __fastcall TForm1::FormActivate(TObject *Sender)
{
if (Tag == 0) //Form的Activate事件里
{
Tag = 1;
FormAnimate(Handle, false);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
Tag = 0; //Form的close事件里
FormAnimate(Handle, true);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -