Help: How to enable a 'Full Screen' mode?
Mao Zhihong -- maozhihong@hotmail.com Friday, December 06, 1996 Environment: VC++ 1.52, VC++ 4.0 with patch, Win3.1, Win 95 Dear MFC Acers, everbody know in MS WORD you can enable a "Full Screen" mode: let the working window expand out of the screen to enlarge workspace. I tried to add this feature in my app, but failed. I tried to MoveWindow(), SetWindowPos(),..., but system refuse to resize and move my window to the size and place I wanna.I also add OnGetMinMaxInfo() in my CMainFrame, but sometime it can work, and sometime it doesn't. Can any one help me? the following is some of my code: ... void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CSize scrn; CPoint sizeNew; CPoint pt; scrn.cx = GetSystemMetrics(SM_CXSCREEN); scrn.cy = GetSystemMetrics(SM_CYSCREEN); if (bFullScreenMode) { sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; sizeNew.y = scrn.cy - GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYMENU) ; pt.x = - (GetSystemMetrics(SM_CXFRAME)); pt.y = - (GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYBORDER)); } else { sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; sizeNew.y = scrn.cy + GetSystemMetrics(SM_CYFRAME) * 2 ; pt.x = - (GetSystemMetrics(SM_CXFRAME)); pt.y = - (GetSystemMetrics(SM_CYFRAME)); } lpMMI->ptMaxPosition = pt; lpMMI->ptMaxSize = sizeNew; CMDIFrameWnd::OnGetMinMaxInfo(lpMMI); } ... Yours truly Mao Zhihong -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Mao Zhihong ( Robert Mao ) DreamyRainbow Software Studio Voc/Fax : 86-25-5408086 E-Mail : maozhihong@hotmail.com mao@seu.edu.cn URL : http://seic3.seu.edu.cn/~mao -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Roger Onslow/Newcastle/Computer Systems Australia/ Monday, December 09, 1996 [Mini-digest: 5 responses] Mao Zhihong, Stingsoft (Stingray) eMailed a news letter (it might also be on their site) that has source code for this. This also mentioned a couple of other sources for (similar) code. It is at http://www.stingsoft/stinginfo/scoop/scoop3.htm Here is the relevant extract from that newsletter... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Q: I want to implement a 'Full screen' mode for one of my windows, how do I do it? A: Try this- void CFrame::OnViewFullScreen() { if (m_bBlownUpMode) { if (!m_rNonBlownUpRect.IsRectEmpty()) { m_bBlownUpMode = FALSE; SetWindowPos(NULL, m_rNonBlownUpRect.left, m_rNonBlownUpRect.top, m_rNonBlownUpRect.Width(), m_rNonBlownUpRect.Height(), SWP_NOZORDER); } } else { m_bBlownUpMode = TRUE; GetWindowRect(&m_rNonBlownUpRect); int x=0, y=0, cx, cy; GetBlownUpPosition(&x, &y); GetBlownUpSize(&cx, &cy); SetWindowPos(NULL, x, y, cx, cy, SWP_NOZORDER); } } void CFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CFrameWnd::OnGetMinMaxInfo(lpMMI); lpMMI-ptMinTrackSize=CPoint(MIN_FRAME_WIDTH, 320); int cx, cy; GetBlownUpSize(&cx, &cy); lpMMI-ptMaxTrackSize=CPoint(cx, cy); } void CFrame::OnNcLButtonDown(UINT nHitTest, CPoint point) { if (m_bBlownUpMode) return ; CFrameWnd::OnNcLButtonDown(nHitTest, point); } void CFrame::GetBlownUpPosition(int *px, int* py) { *px=0, *py=0; *px-=GetSystemMetrics(SM_CXFIXEDFRAME); *px-=GetSystemMetrics(SM_CXEDGE); *py-=GetSystemMetrics(SM_CYFIXEDFRAME); *py-=GetSystemMetrics(SM_CYCAPTION); *py-=GetSystemMetrics(SM_CYEDGE); *py-=GetSystemMetrics(SM_CYMENU); } void CFrame::GetBlownUpSize(int *pcx, int* pcy) { int x, y; GetBlownUpPosition(&x, &y); *pcx=GetSystemMetrics(SM_CXSCREEN); *pcy=GetSystemMetrics(SM_CYSCREEN); *pcx+=-x*2; *pcy+=-y; *pcy+=GetSystemMetrics(SM_CYEDGE); *pcy+=GetSystemMetrics(SM_CYFIXEDFRAME); } Dicky Singh - Dicky@Landmark.COM A2: Rumor has it that MikeB at http://www.nwlink.com/~mikeblas has an implementation too. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Hope this helps Roger -----From: "Dean Wiles"Try calling: CMainFrame::ActivateFrame(SW_SHOWMAXIMIZED); CMainFrame::PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); -------------------------------------------------------------------------- Dean Wiles (deanw@mail.isc-br.com) Olivetti North America Phone: (509)927-7037 22425 East Appleway Ave Fax: (509)927-2499 Liberty Lake, WA 99019-9534 If the Son sets you free, you will be free indeed. (John 8:36) ---------- > From: Mao Zhihong > To: MFC Board <" mfc-l"@netcom.com> > Subject: Help: How to enable a "Full Screen" mode? > Date: Friday, December 06, 1996 1:42 AM > > Environment: VC++ 1.52, VC++ 4.0 with patch, Win3.1, Win 95 > > Dear MFC Acers, > everbody know in MS WORD you can enable a "Full Screen" mode: let the > working window expand out of the screen to enlarge workspace. I tried to add > this feature in my app, but failed. > I tried to MoveWindow(), SetWindowPos(),..., but system refuse to resize > and move my window to the size and place I wanna.I also add OnGetMinMaxInfo() > in my CMainFrame, but sometime it can work, and sometime it doesn't. Can any > one help me? > the following is some of my code: > ... > void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) > { > CSize scrn; > CPoint sizeNew; > CPoint pt; > scrn.cx = GetSystemMetrics(SM_CXSCREEN); > scrn.cy = GetSystemMetrics(SM_CYSCREEN); > > if (bFullScreenMode) { > sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; > sizeNew.y = scrn.cy - GetSystemMetrics(SM_CYBORDER) + > > GetSystemMetrics(SM_CYCAPTION) + > > GetSystemMetrics(SM_CYFRAME) * 2 + > > GetSystemMetrics(SM_CYMENU) ; > pt.x = - (GetSystemMetrics(SM_CXFRAME)); > pt.y = - (GetSystemMetrics(SM_CYCAPTION) + > GetSystemMetrics(SM_CYMENU) + > GetSystemMetrics(SM_CYFRAME) - > GetSystemMetrics(SM_CYBORDER)); > } > else { > sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; > sizeNew.y = scrn.cy + GetSystemMetrics(SM_CYFRAME) * 2 ; > pt.x = - (GetSystemMetrics(SM_CXFRAME)); > pt.y = - (GetSystemMetrics(SM_CYFRAME)); > } > lpMMI->ptMaxPosition = pt; > lpMMI->ptMaxSize = sizeNew; > > CMDIFrameWnd::OnGetMinMaxInfo(lpMMI); > } > > ... > > Yours truly > Mao Zhihong > -- > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Mao Zhihong ( Robert Mao ) DreamyRainbow Software Studio > > Voc/Fax : 86-25-5408086 > E-Mail : maozhihong@hotmail.com mao@seu.edu.cn > URL : http://seic3.seu.edu.cn/~mao > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -----From: "Rajesh Babu T" >Environment: VC++ 1.52, VC++ 4.0 with patch, Win3.1, Win 95 > >Dear MFC Acers, > everbody know in MS WORD you can enable a "Full Screen" mode: let the >working window expand out of the screen to enlarge workspace. I tried to add >this feature in my app, but failed. > I tried to MoveWindow(), SetWindowPos(),..., but system refuse to resize >and move my window to the size and place I wanna.I also add OnGetMinMaxInfo() >in my CMainFrame, but sometime it can work, and sometime it doesn't. Can any >one help me? > the following is some of my code: > ... >void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) >{ > CSize scrn; >CPoint sizeNew; >CPoint pt; >scrn.cx = GetSystemMetrics(SM_CXSCREEN); >scrn.cy = GetSystemMetrics(SM_CYSCREEN); > > if (bFullScreenMode) { > sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; > sizeNew.y = scrn.cy - GetSystemMetrics(SM_CYBORDER) + > >GetSystemMetrics(SM_CYCAPTION) + > >GetSystemMetrics(SM_CYFRAME) * 2 + > >GetSystemMetrics(SM_CYMENU) ; > pt.x = - (GetSystemMetrics(SM_CXFRAME)); > pt.y = - (GetSystemMetrics(SM_CYCAPTION) + >GetSystemMetrics(SM_CYMENU) + > GetSystemMetrics(SM_CYFRAME) - >GetSystemMetrics(SM_CYBORDER)); >} >else { > sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; > sizeNew.y = scrn.cy + GetSystemMetrics(SM_CYFRAME) * 2 ; > pt.x = - (GetSystemMetrics(SM_CXFRAME)); > pt.y = - (GetSystemMetrics(SM_CYFRAME)); >} > lpMMI->ptMaxPosition = pt; > lpMMI->ptMaxSize = sizeNew; > >CMDIFrameWnd::OnGetMinMaxInfo(lpMMI); >} > > ... > > Yours truly > Mao Zhihong Hi there, U can do this by hiding the nonclient components of the FrameWindow. U can achieve this by Setting the Windowstyle to simple. That is use... SetWindowWord(hWnd, GWW_STYLE, ... for VC++ 1.52 and SetWindowLong(hWnd, GWL_STYLE, ... for VC++ 4.0 or higher ...to override the style of the existing window. Befor doing this store the previous style so that U can retrieve it back whenever U want. Bye, Rajesh Babu KL,Malaysia _/_/_/ _/_/_/ _/_/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ --------------------------------------------------------- Get Your *Web-Based* Free Email at http://www.hotmail.com --------------------------------------------------------- -----From: Dong Chen The example fully.zip from Mike B.'s home page shows how to do that: http://www.nwlink.com/~mikeblas/samples/index.htm -- Dong d_chen@ix.netcom.com -----From: tcatchick@aesprodata.com.au If you just want to maximise your app then in your overriden InitInstance() member method place the following: // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); On the other hand if you want the active view to be maximised then you have to find the frame associated with this view and use ShowWindow(SW_SHOWMAXIMIZED). The piece of code I used in my CWinApp derived class to find the frame for the currently active view is follows CWnd* CMyApp::GetFrameWindowAndActivate(CDocTemplate* pTemplate, CRuntimeClass* pDocClass, CRuntimeClass* pViewClass) { CView* pView; pView = GetView(pTemplate, pDocClass, pViewClass); if (pView->IsKindOf(pViewClass)) { pView->GetParentFrame()->ActivateFrame(); return (CWnd*)(pView->GetParentFrame()); } return (CWnd*)NULL; } CView* CMyApp::GetView(CDocTemplate* pTemplate, CRuntimeClass* pDocClass, CRuntimeClass* pViewClass) { POSITION doc_pos, vw_pos; doc_pos = pTemplate->GetFirstDocPosition(); CDocument* pDoc; while (doc_pos) { pDoc = pTemplate->GetNextDoc(doc_pos); if (pDoc->IsKindOf(pDocClass)) { CView* pView; vw_pos = pDoc->GetFirstViewPosition(); while (vw_pos) { pView = pDoc->GetNextView(vw_pos); if (pView->IsKindOf(pViewClass)) return pView; } } } return (CView*)NULL; } I hope this helps Theron. C. tcatchick@aesprodata.com.au ______________________________ Reply Separator _________________________________ Subject: Help: How to enable a "Full Screen" mode? Author: mfc-l@netcom.com at INTERNET Date: 09/12/96 19:31 Environment: VC++ 1.52, VC++ 4.0 with patch, Win3.1, Win 95 Dear MFC Acers, everbody know in MS WORD you can enable a "Full Screen" mode: let the working window expand out of the screen to enlarge workspace. I tried to add this feature in my app, but failed. I tried to MoveWindow(), SetWindowPos(),..., but system refuse to resize and move my window to the size and place I wanna.I also add OnGetMinMaxInfo() in my CMainFrame, but sometime it can work, and sometime it doesn't. Can any one help me? the following is some of my code: ... void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CSize scrn; CPoint sizeNew; CPoint pt; scrn.cx = GetSystemMetrics(SM_CXSCREEN); scrn.cy = GetSystemMetrics(SM_CYSCREEN); if (bFullScreenMode) { sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; sizeNew.y = scrn.cy - GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYMENU) ; pt.x = - (GetSystemMetrics(SM_CXFRAME)); pt.y = - (GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYBORDER)); } else { sizeNew.x = scrn.cx + GetSystemMetrics(SM_CXFRAME) * 2 ; sizeNew.y = scrn.cy + GetSystemMetrics(SM_CYFRAME) * 2 ; pt.x = - (GetSystemMetrics(SM_CXFRAME)); pt.y = - (GetSystemMetrics(SM_CYFRAME)); } lpMMI->ptMaxPosition = pt; lpMMI->ptMaxSize = sizeNew; CMDIFrameWnd::OnGetMinMaxInfo(lpMMI); } ... Yours truly Mao Zhihong -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Mao Zhihong ( Robert Mao ) DreamyRainbow Software Studio Voc/Fax : 86-25-5408086 E-Mail : maozhihong@hotmail.com mao@seu.edu.cn URL : http://seic3.seu.edu.cn/~mao -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Syed -- sxs296@psu.edu Thursday, December 12, 1996 It's not difficult really. the idea is you are able to change the style and extended style of the parent frame dynamically. Then, you have to decide what kind of style is it that you need. I have done this before but I am very lazy to look back at the source code but here's what I remember :- style :- NO CAPTION, POPUP, ShowWindow(FALSE) Make sure set the background color rg Black - RGB(0,0,0) Try experimenting by changing the style and extended style trial and error .. I can assure you it's not really difficult.. the function you might need is ModifyStle or/and ModifyStyleEx
| Вернуться в корень Архива |