티스토리 툴바

 

 

Notice»

Recent Comment»

Recent Trackback»

Archive»

« 2012/01 »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

보통 MFC로 프로그램이 실행되면 윈도우 창이 자신의 의도와 다르게 될 때가 많다.
좀 깔끔하게 하나의 Application을 돌리고 싶을 경우 전체화면으로 바꿔주고 싶을 경우가 있는데, 그때 사용해야할 코드들이 있다.

방법은 생성된 프로젝트의 MainFrm.cpp에서 약간의 코드를 작성하면 된다.
(MainFrm.cpp상의 OnCreate 함수)
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
    //전체화면 확장
	int cx = GetSystemMetrics(SM_CXSCREEN);
	int cy = GetSystemMetrics(SM_CYSCREEN);
	::SetWindowPos(this->m_hWnd, HWND_TOPMOST, -1, -1, cx+3, cy+3, SWP_FRAMECHANGED); 
	//전체화면 확장 끝
	return 0;
}  

위와 같이 작성하게 되면 제목표시줄메뉴창이 표시된 채로 전체화면으로 활성화된다.
제목표시줄 삭제를 위해서는 다음코드를 참고 한다.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	//전체화면으로 확장
	LONG style = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
	::ShowWindow(this->m_hWnd, SW_MAXIMIZE);
	style = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
	style &= ~(WS_DLGFRAME | WS_THICKFRAME);
	::SetWindowLong(this->m_hWnd, GWL_STYLE, style); 
	//전체화면으로 확장 끝
	return 0;
}

Dialog Box 일경우
BOOL TestDlg::OnInitDialog()
{
CDialog::OnInitDialog();

HWND m_hwnd = this->m_hWnd;

LONG style = ::GetWindowLong( m_hWnd, GWL_STYLE );

style &= ~WS_CAPTION;
style &= ~WS_SYSMENU;

::SetWindowLong( m_hWnd, GWL_STYLE, style );
int screenx = GetSystemMetrics( SM_CXSCREEN );
int screeny = GetSystemMetrics( SM_CYSCREEN );

// resize:
SetWindowPos( NULL, -4, -4, screenx+8, screeny+4, SWP_NOZORDER );

return TRUE;
}

'Programming > MFC' 카테고리의 다른 글

MFC 프로그램 전체화면으로 전환하여 띠우기  (0) 2011/07/29