Problem with MainFrame.cpp
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: Problem with MainFrame.cpp

  1. #1
    Join Date
    Jun 1999
    Posts
    488

    Problem with MainFrame.cpp

    Hi,
    Sorry I cant see the text on the icons above this text box. I am trying to execute a tutorial code which I got from:
    http://msdn.microsoft.com/en-us/library/gg466500.aspx

    However, i cant perform step 8 which says:

    In Solution Explorer, double-click MainFrm.cpp to open it for modification. In the CMainFrame::OnCreate method, locate the section that has several calls to lstBasicCommands.AddTail. Just after that section, add the following code.
    I have got following stuff in my OnCreate:
    Code:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
    		return -1;
    	
    	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    	{
    		TRACE0("Failed to create toolbar\n");
    		return -1;      // fail to create
    	}
    
    	if (!m_wndStatusBar.Create(this) ||
    		!m_wndStatusBar.SetIndicators(indicators,
    		  sizeof(indicators)/sizeof(UINT)))
    	{
    		TRACE0("Failed to create status bar\n");
    		return -1;      // fail to create
    	}
    
    	// TODO: Delete these three lines if you don't want the toolbar to be dockable
    	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockControlBar(&m_wndToolBar);
    
    	return 0;
    }
    Somebody plz guide me.

    Zulfi.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    1. Did you run through the steo
    3. In the MFC Application Wizard dialog box, verify that Application Type is Multiple Documents, Project Style is Visual Studio, and the Document/View Architecture support option is selected. Click Finish.
    Whhat IDE are you using (VS 2010, 2012, 2013, ...?)
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 1999
    Posts
    488

    Re: Problem with MainFrame.cpp

    Hi,
    Thanks for your reply. I have VS2008. I know that it was MultiDocument and i did not change it to Single Document. I dont know about project Styles but document/View architecture support was checked.

    Plz guide me.

    Zulfi.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    Well, these lines mentioned in the p.8 are for the menu personalization (most-recently used commands). if you did not choose this option then you do not have these lines.
    I have just created a new MDI project in VS 2008 and CMainFrame::OnCreate does have these lstBasicCommands.AddTail. lines.
    Victor Nijegorodov

  5. #5
    Join Date
    Jun 1999
    Posts
    488

    Re: Problem with MainFrame.cpp

    Hi,
    Thanks for your reply. The steps which i followed are:

    File>New>Project>(Note : project type : MFC (already selected) and Visual Studio Installed Templates (MFC Application already selected), I provided Name, Solution Name and then pressed OK>Next>It shows Project Styles (MFC Standard with radio button selected) and document / view support checked , I then pressed Finish>

    Somebody plz guide me.

    Zulfi.
    Last edited by Zulfi Khan2; April 29th, 2014 at 01:23 PM.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,068

    Re: Problem with MainFrame.cpp

    That doesn't look familiar to me. Possibly it's not code that 2008 generates.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    Quote Originally Posted by GCDEF View Post
    That doesn't look familiar to me. Possibly it's not code that 2008 generates.
    Agree. It looks more like the one created with VC++6.0.
    Victor Nijegorodov

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,068

    Re: Problem with MainFrame.cpp

    Quote Originally Posted by VictorN View Post
    Agree. It looks more like the one created with VC++6.0.
    I was thinking it was new. The link references 2013.

  9. #9
    Join Date
    Jun 1999
    Posts
    488

    Re: Problem with MainFrame.cpp

    Hi,
    Thanks for your time. Sorry but plz remove my confusion. I am not using VC6.0 any more. Do you mean that the reference link uses VC6.0 code??

    Plz guide me.

    Zulfi.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    Quote Originally Posted by Zulfi Khan2 View Post
    I am not using VC6.0 any more. Do you mean that the reference link uses VC6.0 code??
    No. I only meant that the code you posted (CMainFrame::OnCreate) is exactly the same VC++ 6.0 AppWizard created for every my MDI application.
    And this is the code VS2008 AppWizard created for me (MDI, Visual Studio style, using personalized menu):
    Code:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
    	BOOL bNameValid;
    	// set the visual manager and style based on persisted value
    	OnApplicationLook(theApp.m_nAppLook);
    
    	CMDITabInfo mdiTabParams;
    	mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // other styles available...
    	mdiTabParams.m_bActiveTabCloseButton = TRUE;      // set to FALSE to place close button at right of tab area
    	mdiTabParams.m_bTabIcons = FALSE;    // set to TRUE to enable document icons on MDI taba
    	mdiTabParams.m_bAutoColor = TRUE;    // set to FALSE to disable auto-coloring of MDI tabs
    	mdiTabParams.m_bDocumentMenu = TRUE; // enable the document menu at the right edge of the tab area
    	EnableMDITabbedGroups(TRUE, mdiTabParams);
    
    	if (!m_wndMenuBar.Create(this))
    	{
    		TRACE0("Failed to create menubar\n");
    		return -1;      // fail to create
    	}
    
    	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
    
    	// prevent the menu bar from taking the focus on activation
    	CMFCPopupMenu::SetForceMenuFocus(FALSE);
    
    	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
    	{
    		TRACE0("Failed to create toolbar\n");
    		return -1;      // fail to create
    	}
    
    	CString strToolBarName;
    	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
    	ASSERT(bNameValid);
    	m_wndToolBar.SetWindowText(strToolBarName);
    
    	CString strCustomize;
    	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
    	ASSERT(bNameValid);
    	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);
    
    	// Allow user-defined toolbars operations:
    	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);
    
    	if (!m_wndStatusBar.Create(this))
    	{
    		TRACE0("Failed to create status bar\n");
    		return -1;      // fail to create
    	}
    	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
    
    	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
    	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndMenuBar);
    	DockPane(&m_wndToolBar);
    
    
    	// enable Visual Studio 2005 style docking window behavior
    	CDockingManager::SetDockingMode(DT_SMART);
    	// enable Visual Studio 2005 style docking window auto-hide behavior
    	EnableAutoHidePanes(CBRS_ALIGN_ANY);
    
    	// Load menu item image (not placed on any standard toolbars):
    	CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);
    
    	// create docking windows
    	if (!CreateDockingWindows())
    	{
    		TRACE0("Failed to create docking windows\n");
    		return -1;
    	}
    
    	m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndFileView);
    	CDockablePane* pTabbedBar = NULL;
    	m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
    	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndOutput);
    	m_wndProperties.EnableDocking(CBRS_ALIGN_ANY);
    	DockPane(&m_wndProperties);
    
    
    	// Enable enhanced windows management dialog
    	EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
    
    	// Enable toolbar and docking window menu replacement
    	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);
    
    	// enable quick (Alt+drag) toolbar customization
    	CMFCToolBar::EnableQuickCustomization();
    
    	if (CMFCToolBar::GetUserImages() == NULL)
    	{
    		// load user-defined toolbar images
    		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
    		{
    			m_UserImages.SetImageSize(CSize(16, 16), FALSE);
    			CMFCToolBar::SetUserImages(&m_UserImages);
    		}
    	}
    
    	// enable menu personalization (most-recently used commands)
    	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
    	CList<UINT, UINT> lstBasicCommands;
    
    	lstBasicCommands.AddTail(ID_FILE_NEW);
    	lstBasicCommands.AddTail(ID_FILE_OPEN);
    	lstBasicCommands.AddTail(ID_FILE_SAVE);
    	lstBasicCommands.AddTail(ID_FILE_PRINT);
    	lstBasicCommands.AddTail(ID_APP_EXIT);
    	lstBasicCommands.AddTail(ID_EDIT_CUT);
    	lstBasicCommands.AddTail(ID_EDIT_PASTE);
    	lstBasicCommands.AddTail(ID_EDIT_UNDO);
    	lstBasicCommands.AddTail(ID_APP_ABOUT);
    	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
    	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
    	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
    	lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC);
    	lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE);
    	lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS);
    	lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE);
    
    	CMFCToolBar::SetBasicCommands(lstBasicCommands);
    
    	return 0;
    }
    Do you see the difference?
    Victor Nijegorodov

  11. #11
    Join Date
    Jun 1999
    Posts
    488

    Re: Problem with MainFrame.cpp

    Hi,
    Thanks for your reply. Do you have any idea why its not working properly?? Are my steps correct? Should i install it again??

    Zulfi.

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    Quote Originally Posted by Zulfi Khan2 View Post
    Do you have any idea why its not working properly?? Are my steps correct?
    But how could I know it?
    Just try to create a new project and perform all the steps described in Walkthrough: Adding Animation to an MFC Project in the section
    Prerequisites
    To complete this walkthrough, you must have Visual Studio 2010.
    To create an MFC application
    1. On the File menu, point to New and then click Project.
    2. In the New Project dialog box, in the left pane under Installed Templates, expand Visual C++ and then select MFC. In the middle pane, select MFC Application. In the Name box, type MFCAnimationWalkthrough. Click OK.
    3. In the MFC Application Wizard dialog box, verify that Application Type is Multiple Documents, Project Style is Visual Studio, and the Document/View Architecture support option is selected. Click Finish.
    Victor Nijegorodov

  13. #13
    Join Date
    Jun 1999
    Posts
    488

    Re: Problem with MainFrame.cpp

    Hi,
    I have installed VC++ 2010 express. But I cant find the required stuff as mentioned in the tutorial whose link i have already provided. Is VC++ 2010 different from VS 2010?? The image of Start Page is:
    Name:  vc express 2010 start page.jpg
Views: 44
Size:  28.7 KB
    It says:
    2. In the New Project dialog box, in the left pane under Installed Templates, expand Visual C++ and then select MFC. In the middle pane, select MFC Application. In theName box, type MFCAnimationWalkthrough.
    but I cant find :MFC in the installed Templates. It has only 3 things: CLR , win32 & General. It does not have MFC option as discussed in the tutorial.

    Somebody plz guide me.

    Zulfi.

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,354

    Re: Problem with MainFrame.cpp

    VS 2010 Express does NOT contain MFC.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center