ttrigonwin.cpp
来自「C++Builder程序员编程手记《配书光盘》」· C++ 代码 · 共 69 行
CPP
69 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "TtrigonWin.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Ttrigon *trigon;
//---------------------------------------------------------------------------
__fastcall Ttrigon::Ttrigon(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void Ttrigon::SetTrigonWin(HWND Window)
{
HRGN TrigonWin;
TPoint vertexes[4];
TRect RectWin;
if(!SetWindowRgn(Window,0,false))
ShowMessage("窗口初始化失败!");
if(!GetWindowRect(Window,&RectWin))
ShowMessage("取窗口信息失败!");
vertexes[0].x=0;
vertexes[0].y=0;
vertexes[1].x=0;
vertexes[1].y=GetSystemMetrics(SM_CYCAPTION);
vertexes[2].x=(RectWin.Right-RectWin.Left)/2;
vertexes[2].y=RectWin.Bottom-RectWin.Top;
vertexes[3].x=RectWin.Right-RectWin.Left;
vertexes[3].y=vertexes[1].y;
vertexes[4].x=vertexes[3].x;
vertexes[4].y=vertexes[0].y;
TrigonWin=CreatePolygonRgn(vertexes,5,WINDING);
if(TrigonWin==0)
ShowMessage("创建窗体过程失败");
else
if(!SetWindowRgn(Window,TrigonWin,true))
ShowMessage("设置窗口失败!");
}
void __fastcall Ttrigon::FormShow(TObject *Sender)
{
SetTrigonWin(Handle);
}
//---------------------------------------------------------------------------
void __fastcall Ttrigon::FormResize(TObject *Sender)
{
SetTrigonWin(Handle);
Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall Ttrigon::FormClose(TObject *Sender, TCloseAction &Action)
{
SetWindowRgn(Handle,0,false);
}
//---------------------------------------------------------------------------
void __fastcall Ttrigon::FormClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?