资料收集站

SDL

Wednesday
Dec 03rd
Text size
  • Increase font size
  • Default font size
  • Decrease font size

This example illustrates how to change a standard frame window to full screen mode and to remove the title bar and 3D frame. This technique is used in many drawing and architectural programs to cause the drawing that is normally contained in the client area to occupy the entire screen area. 

This example assumes that you wish to expand or contract the viewing area by double-clicking the client area. You, of course, may use whichever technique is appropriate for your project. 

In the header file of your frame class, instantiate an instance of CMenu. 

	CMenu  m_Menu;

In the PreCreateWindow over-ride of your frame class, remove the default menu from the window. 

	cs.hMenu = NULL;

In the OnCreate over-ride in your frame class, load and set the default menu. Do this after the call to the CFrameWnd::OnCreate() class member. 

	m_Menu.LoadMenu(IDR_MAINFRAME);

	SetMenu(&m_Menu);

Create an integer variable in your view class header file that will be used as a "state" flag for the view. 

	iIsFullScreen = 0;

In the implementation file of your view class, create a handler for the WM_LBUTTONDBLCLK message. In the code below, you will test the state of the flag and set the view appearance accordingly. 

	void CTestView::OnLButtonDblClk(UINT nFlags,CPoint point)


	// get a pointer to the frame object


		CMainFrame * pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);

	// if the view is now full screen, change the view to normal size and state


		if(iIsFullScreen) {

	// add the WS_CAPTION and WS_THICKFRAME styles to the frame window


			pFrame->ModifyStyle(0,WS_CAPTION);

			pFrame->ModifyStyle(0,WS_THICKFRAME);

	// restore the frame window to normal size and state

			pFrame->ShowWindow(SW_SHOWNORMAL);

	// restore the default menu and show it

			pFrame->SetMenu(&(pFrame->m_Menu));

	// set flag to indicate that frame window is now NOT full screen

			iIsFullScreen = 0;

		}

	// if the view is now normal, change the view to full screen

		else {

	// remove the WS_CAPTION and WS_THICKFRAME styles from the frame window

			pFrame->ModifyStyle(WS_CAPTION,0);

			pFrame->ModifyStyle(WS_THICKFRAME,0);

	// remove the default menu and erase the menu

			pFrame->SetMenu(NULL);

	// show the now menuless and frameless window full screen

			pFrame->ShowWindow(SW_MAXIMIZE);

	// reset the flag to indicate that the view is now full screen

			iIsFullScreen = 1;

		}


		CView::OnLButtonDblClk(nFlags,point);


If your window contains a toolbar or a status bar, you will probably want to modify this code so that they are hidden or restored as well. 
Comments (0)Add Comment

Write comment

busy
 

Google 搜索

在线用户

We have 55 guests online