본문 바로가기

3.구현/VC++

윈도우 타이틀과 테두리 없애기

작성자: Ospace (ospace114@empal.com)

최근 UI가 화려해지고 미려해지면서 기존 윈도우 모양을 탈피하고 있다..
기본적인 윈도우 모양을 타이틀 바, 메뉴, 그리고 테두리가 있는 형태이다.

MFC에서는 이런 문제를 간단히 해결할 수 있다.
먼저 MFC에서 새 프로젝트를 실행하고 프로젝트를 Dialog-based appl로 하면, 기본적인 대화상자 기반의
응용프로그램을 작성할 수 있다. 이 환경에서는 기본적으로 메뉴가 없다. 그렇기에 타이틀바와 테두리만 없애면 된다. 없애는 방법은;

1) Resource View를 뛰운다.
2) Dialog 항목에서 메인 Dialog를 뛰운다.
3) Dialog를 선택하고 Properties 창에서 Border 속성을 찾는다.
4) Border속성을 None으로 설정한다.

위의 방법은 실제 win32 api로 본다면 윈도우를 생성할때 윈도우 스타일을 지정한다. 아래는 윈도우 생성하는 api인 create 함수를 보여주고 있다.
함수 매개변수들 중에서 dwStyle인 윈도우 스타일을 지정하는 곳이 있다. 이부분에서 원하는 스타일로 설정하면 된다.

관련 스타일은 두 가지가 있다.

  • WS_BORDER Creates a window that has a border.

  • WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style.

Create 함수 프로토타입

virtual BOOL Create(
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle,
   const RECT& rect,
   CWnd* pParentWnd,
   UINT nID,
   CCreateContext* pContext = NULL
);

Parameters

  • lpszClassName

    Points to a null-terminated character string that names the Windows class (a WNDCLASS structure). The class name can be any name registered with the global AfxRegisterWndClass function or any of the predefined control-class names. If NULL, uses the default CWnd attributes.

  • lpszWindowName

    Points to a null-terminated character string that contains the window name.

  • dwStyle

    Specifies the window style attributes. WS_POPUP cannot be used. If you wish to create a pop-up window, use CWnd::CreateEx instead.

  • rect

    The size and position of the window, in client coordinates of pParentWnd.

  • pParentWnd

    The parent window.

  • nID

    The ID of the child window.

  • pContext

    Pointer to an optional CCreateContext structure used to override portions of the creation process.

반응형