📄 pentagonwin.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "PentagonWin.h"
#include "PolygonWin.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tpentagon *pentagon;
//---------------------------------------------------------------------------
__fastcall Tpentagon::Tpentagon(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void Tpentagon::SetPentagonWin(HWND Window)
{
HRGN PentagonWin;
TPoint vertexes[5];
TRect RectWin;
long sidelong;
if(!SetWindowRgn(Window,0,false))
ShowMessage("窗口初始化失败!");
if(!GetWindowRect(Window,&RectWin))
ShowMessage("取窗口信息失败!");
sidelong=2*(RectWin.Bottom-RectWin.Top)/tanl(pai*72.0/180.0);
vertexes[0].x=(RectWin.Right-RectWin.Left)/2-(sidelong/2);
vertexes[0].y=0;
vertexes[1].x=vertexes[0].x-sidelong*sinl(pai/10);
vertexes[1].y=sidelong*cosl(pai/10);
vertexes[2].x=(RectWin.Right-RectWin.Left)/2;
vertexes[2].y=RectWin.Bottom-RectWin.Top;
vertexes[3].x=vertexes[2].x+sidelong*sinl(pai*54.0/180.0);
vertexes[3].y=vertexes[1].y;
vertexes[4].x=vertexes[0].x+sidelong;
vertexes[4].y=0;
PentagonWin=CreatePolygonRgn(vertexes,5,WINDING);
if(PentagonWin==0)
ShowMessage("创建窗体过程失败");
else
if(!SetWindowRgn(Window,PentagonWin,true))
ShowMessage("设置窗口失败!");
}
void __fastcall Tpentagon::FormShow(TObject *Sender)
{
SetPentagonWin(Handle);
}
//---------------------------------------------------------------------------
void __fastcall Tpentagon::FormResize(TObject *Sender)
{
SetPentagonWin(Handle);
Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall Tpentagon::FormClose(TObject *Sender, TCloseAction &Action)
{
SetWindowRgn(Handle,0,false);
}
//---------------------------------------------------------------------------
void __fastcall Tpentagon::FormClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -