C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[69] 윈도우 클라이언트 영역 변경하기...
pulyip [] 8136 읽음    2000-08-28 00:00
다들 아시는 내용이겠지만... 윈도우 클라이언트 영역을 변경하는 소스입니다.

윈도우 모양 변경등에서 주로 사용됬던 것 같네요...

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;
}  
//---------------------------------------------------------------------------

+ -

관련 글 리스트
69 윈도우 클라이언트 영역 변경하기... pulyip 8136 2000/08/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.