이글루스 로그인

MFC Fullscreen Mode

풀스크린... 스테레오 뷰잉을 구현하기 위해 꼭 필요한 설정임에도 불구하고, 자료를 찾는데 엄청난 시간이 소요되었다.
역시 검색어의 선택이 얼마나 중요한가를 깨닫게 된..쩝.
이번 여름동안의 프로그래밍이 하나씩 결실을 맺어가는군하~ 캬~^^

풀스크린 모드 구현
1. 우선, C(something)View의 헤더파일에 멤버변수 및 인스턴스의 설정 및 변수 초기화
(isFull=false; 생성자 함수에서).

boolean isFull;
CWnd *saveParent;
CMenu *ContextMenu;


2. 리소스 뷰에서 메뉴 및 아이콘을 생성한 후 new ID를 설정한다.(Menu & toolbar)
ID_BUTTON_FULLSCREEN

3. 클래스뷰에서 C--View클래스의 이벤트를 설정하여 OnButtonFullscreen() 생성하여 다음의 알고리즘 삽입
void CMfcglView::OnButtonFullscreen()
{
/* if normal mode - start (enable) full screen mode */
if(!isFull){
isFull=true;

/* Variable saveParent is used to save
address of parent window (address is necessary
in disabling this mode -to place view in former position) */
saveParent=this->GetParent();

/* this (our view) is placed on desktop window -
CWnd::GetDesktopWindow() - Returns the Windows desktop window */
this->SetParent(GetDesktopWindow());

CRect rect; /* temporary variable */

/* Next function copies the dimensions of
the bounding rectangle of the desktop */
GetDesktopWindow()->GetClientRect(&rect);

/* view is placed on desktop */
this->SetWindowPos(&wndTopMost,rect.left,rect.top,
rect.right,rect.bottom,SWP_SHOWWINDOW);
}
else{
/* disable full screen mode */
isFull=false;

/* our view is placed in old window - using address saveParent
(pointer that has been used in former if-section) */
this->SetParent( saveParent);

/* pointer to the main frame and function RecalcLayout()
(run on behalf of CmainFrame object)
- that repositions all control bars
in the frame (#include ) */
((CMainFrame *)AfxGetMainWnd())->RecalcLayout(); // 툴바 리프레쉬.
}
}



풀스크린 모드 해제를 위한 설정(마우스 오른쪽 버튼을 이용)

1. 리소스뷰의 menu에서 IDR_MENU_VIEW 추가


2. 컨텍스트 메뉴의 초기화 (생성자함수 부분에)
ContextMenu= new CMenu();
if(!ContextMenu->LoadMenu(IDR_MENU_VIEW)){
AfxMessageBox("Fail to create context menu");
}


3. OnRButtonDown 메시지 추가 & 함수 정의
void CMfcglView::OnRButtonDown(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
if(ContextMenu->GetSubMenu(0)){
CMenu *pSubMenu= ContextMenu->GetSubMenu(0);
if(isFull){
/* check menu item if full screen mode */
pSubMenu->CheckMenuItem(ID_BUTTON_FULLSCREEN,MF_CHECKED );
}

else{
/* uncheck menu item */
pSubMenu->CheckMenuItem(ID_BUTTON_FULLSCREEN,MF_UNCHECKED );
}

pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x,point.y,this);
}
CView::OnRButtonDown(nFlags, point);
}


주의할점
It's impossible to show other windows (dialog boxes, etc.) in full screen mode.
This mode serves to review content of view.

출처 : http://www.codeproject.com/dialog/Viewsinfullscreenmode.asp
by KaKaLoT | 2007/08/13 09:28 | Major[C&C++] | 트랙백


트랙백 주소 : http://kakalot.egloos.com/tb/1403337
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
※ 로그인 사용자만 덧글을 남길 수 있습니다.







rss

skin by jiinny