📄 parabolawin.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ParabolaWin.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tparabola *parabola;
//---------------------------------------------------------------------------
__fastcall Tparabola::Tparabola(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void Tparabola::SetParabolaWin(HWND Window)
{
HRGN ParabolaWin;
TRect RectWin;
TPoint vertexes[500];
int i,step;
double WinHeight,WinWidth,a,b;
if(!SetWindowRgn(Window,0,false))
ShowMessage("窗口初始化失败!");
if(!GetWindowRect(Window,&RectWin))
ShowMessage("取窗口信息失败!");
WinHeight=RectWin.Bottom-RectWin.Top;
WinWidth=RectWin.Right-RectWin.Left;
step=WinWidth/3;
a=-(4*WinHeight)/(WinWidth*WinWidth);
b=(4*WinHeight)/WinWidth;
vertexes[0].x=0;
vertexes[0].y=0;
vertexes[1].x=0;
vertexes[1].y=GetSystemMetrics(SM_CYCAPTION);
for(i=2;i<=step-2;i++)
{
vertexes[i].x=i*3;
vertexes[i].y=(double)a*(i*3)*(i*3)+b*(i*3);
}
vertexes[step-2].x=RectWin.Right-RectWin.Left;
vertexes[step-2].y=vertexes[1].y;
vertexes[step-1].x=vertexes[step-2].x;
vertexes[step-1].y=vertexes[0].y;
ParabolaWin=CreatePolygonRgn(vertexes,step,WINDING);
if(ParabolaWin==0)
ShowMessage("创建窗体过程失败");
else
if(!SetWindowRgn(Window,ParabolaWin,true))
ShowMessage("设置窗口失败!");
}
void __fastcall Tparabola::FormShow(TObject *Sender)
{
SetParabolaWin(Handle);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall Tparabola::FormClose(TObject *Sender, TCloseAction &Action)
{
SetWindowRgn(Handle,0,false);
}
//---------------------------------------------------------------------------
void __fastcall Tparabola::FormClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall Tparabola::FormResize(TObject *Sender)
{
SetParabolaWin(Handle);
Invalidate();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -