Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals



  1. In the constructor of the CMainFrame class, initialize the CFloatingSheet pointer
    using the new operator:


CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
Floater = new CFloaterDlg;
FSheet = new CFloatingSheet("Properties");
}


  1. On the CMainFrame::OnCreate() event, create and and display the property sheet
    with the followsing:


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

...


Floater->Create(IDD_DLG_FLOATER, this);
FSheet->Create(this,
WS_CHILD | WS_POPUP | WS_CAPTION |
WS_SYSMENU | WS_VISIBLE,
WS_EX_TOOLWINDOW);

return 0;
}


  1. Implement the OnViewFloating() event as follows:


void CMainFrame::OnViewFloating()
{
// TODO: Add your command handler code here
// Display the property sheet, even if it is already displaying
FSheet->ShowWindow(SW_SHOW);
}


  1. Test the application

  2. Return to MSVC

Free download pdf