다들 아시는 내용이겠지만... 윈도우 클라이언트 영역을 변경하는 소스입니다.
윈도우 모양 변경등에서 주로 사용됬던 것 같네요...
SetWindowRgn을 이용합니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "RgnTestUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
SetWindowRgn();
}
//---------------------------------------------------------------------------
void TForm1::SetWindowRgn()
{
HRGN hRCompo = NULL;
int IX = GetSystemMetrics(SM_CXSIZEFRAME);
int IY = GetSystemMetrics(SM_CYCAPTION);
IY += GetSystemMetrics(SM_CYSIZEFRAME);
for(int i = 0; i< ControlCount; i++) {
TControl *C = Controls[i];
if(hRCompo) {
HRGN hR = CreateRectRgn(
C->BoundsRect.Left+IX,
C->BoundsRect.Top+IY,
C->BoundsRect.Right+IX,
C->BoundsRect.Bottom+IY);
CombineRgn(hRCompo, hRCompo, hR, RGN_OR);
DeleteObject(hR);
}
else {
hRCompo = CreateRectRgn(
C->BoundsRect.Left+IX,
C->BoundsRect.Top+IY,
C->BoundsRect.Right+IX,
C->BoundsRect.Bottom+IY);
}
}
HRGN hRgnTitle = ::CreateRectRgn(
0, 0, Width, IY);
::CombineRgn(hRCompo, hRCompo, hRgnTitle, RGN_OR);
::DeleteObject(hRgnTitle);
HRGN ClientRgn = ::CreateRectRgn(
0, 0, Width, Height);
::CombineRgn(ClientRgn, ClientRgn, hRCompo, RGN_AND);
::DeleteObject(hRCompo);
::SetWindowRgn(Handle, ClientRgn, true);
DeleteObject(ClientRgn);
}
void __fastcall TForm1::CreateParams(TCreateParams & Params)
{
TForm::CreateParams(Params);
// Params.ExStyle = Params.ExStyle | WS_EX_TRANSPARENT;
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// Brush->Style = bsClear;
}
//---------------------------------------------------------------------------
|