private: // User declarations
int form_Min(int x, int y);
int r,margn;
HRGN temp_RGN,temp_Ellipse;
void init_Date();
public: // User declarations
void rgn_Xor();
void rgn_Or();
void rgn_And();
void rgn_Diff();
__fastcall TForm1(TComponent* Owner);
};
int TForm1::form_Min(int x, int y)
{
if(x<y)
return x;
else
return y;
}
void TForm1::init_Date()
{
temp_RGN=CreateRectRgn(0,0,Width,Height);
r=form_Min(Height,Width);
margn=Height-ClientHeight;
temp_Ellipse=CreateEllipticRgn(0,margn,r,r);
}
void TForm1::rgn_Xor()
{
init_Date();
CombineRgn(temp_Ellipse,temp_RGN,temp_Ellipse,RGN_XOR);
SetWindowRgn(Handle,temp_Ellipse,true);
}
void TForm1::rgn_Or()
{
init_Date();
CombineRgn(temp_Ellipse,temp_RGN,temp_Ellipse,RGN_OR);
SetWindowRgn(Handle,temp_Ellipse,true);
}
void TForm1::rgn_And()
{
init_Date();
CombineRgn(temp_Ellipse,temp_RGN,temp_Ellipse,RGN_AND);
SetWindowRgn(Handle,temp_Ellipse,true);
}
void TForm1::rgn_Diff()
{
init_Date();
CombineRgn(temp_Ellipse,temp_RGN,temp_Ellipse,RGN_DIFF);
SetWindowRgn(Handle,temp_Ellipse,true);
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
rgn_Xor();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
rgn_Or();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
rgn_And();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
rgn_Diff();
}