From: Leo on 11 Jun 2010 15:08 Thanks everyone for your help. In my situation, I don't need to consider multi-monitor case, so I did the following which did the trick: First, the style needs to be WS_POPUP. Otherwise the taskbar area won't be covered / hidden. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { .... cs.style = WS_POPUP | WS_MAXIMIZE; cs.dwExStyle &= ~WS_EX_CLIENTEDGE; return TRUE; } And then put the following code which will be always called. Of course, the SetWindowPos method doesn't need to be called here. You can put it anywhere / message override AFTER OnCreate is called. void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/) { // forward focus to the view window m_wndView.SetFocus(); if (!m_bFullScreen) { m_bFullScreen = true; int cyCaption = ::GetSystemMetrics(SM_CYCAPTION); int cxFrame = ::GetSystemMetrics(SM_CXFRAME); int cyFrame = ::GetSystemMetrics(SM_CYFRAME); int cxScroll = ::GetSystemMetrics(SM_CXVSCROLL); int cxScreen = ::GetSystemMetrics(SM_CXSCREEN); int cyScreen = ::GetSystemMetrics(SM_CYSCREEN); SetWindowPos(0, -cxFrame, -(cyFrame + cyCaption), cxScreen + 2 * cxFrame + cxScroll, cyScreen + 2 * cyFrame + cyCaption, 0); } } Thanks. Leo
From: Leo on 11 Jun 2010 16:36 Also tried Joe's suggestion to find a solution for multimonitor case. Generally it works great, but I have to do the following to hide the disabled vertical scrollbar: // Remember this for OnGetMinMaxInfo() rectDesktop.right += ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXFRAME); m_FullScreenWindowRect = rectDesktop; I guess this should be OK,right? --- I am just using the width of VSCROLL and FRAME, not the view. The following is what I did: // Public method to be called from InitInstance void CMainFrame::SetFullScreen() { RECT rectDesktop; WINDOWPLACEMENT wpNew; if (!m_bFullScreen) { //Adjust RECT to new size of window ::GetWindowRect(::GetDesktopWindow(), &rectDesktop); ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle()); // Remember this for OnGetMinMaxInfo() rectDesktop.right += ::GetSystemMetrics(SM_CXVSCROLL) + ::GetSystemMetrics(SM_CXFRAME); m_FullScreenWindowRect = rectDesktop; GetWindowPlacement(&wpNew); wpNew.showCmd = SW_SHOWNORMAL; wpNew.rcNormalPosition = rectDesktop; m_bFullScreen = true; } SetWindowPlacement(&wpNew); } void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { if (m_bFullScreen) { lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height(); lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y; lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width(); lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x; } } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { .... cs.style = WS_MAXIMIZE; cs.dwExStyle &= ~WS_EX_CLIENTEDGE; cs.lpszClass = AfxRegisterWndClass(0); return TRUE; }
From: Martin Richter [MVP] on 12 Jun 2010 03:14 Hallo Leo! > I have a CFrameWnd based SDI application. I want it to start in full > screen. Simply set CWinApp::m_nCmdShow to SW_MAXIMIZED! -- Martin Richter [MVP] WWJD http://blog.m-ri.de "A well-written program is its own heaven; a poorly written program is its own hell!" The Tao of Programming FAQ: http://www.mpdvc.de Samples: http://www.codeproject.com
From: Joseph M. Newcomer on 12 Jun 2010 19:37 Note that the first ShowWindow issued in an app for the main window completely ignores its parameter, and uses the nCmdShow parameter from WinMain. There's an MSDN article somewhere that explains this. joe On Sat, 12 Jun 2010 09:14:36 +0200, "Martin Richter [MVP]" <martin.richter(a)mvps.org> wrote: >Hallo Leo! > >> I have a CFrameWnd based SDI application. I want it to start in full >> screen. > >Simply set CWinApp::m_nCmdShow to SW_MAXIMIZED! Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
First
|
Prev
|
Pages: 1 2 Prev: Getting Pixels in the wrong RGB Order Next: Wildcat! Live Exchange V1.0e Available |