Solved

Load and Save CDialogBar

Posted on 1997-03-07
5
837 Views
Last Modified: 2013-11-19
Hello,
I tried to load and to save CDialogBar based on the Knowledge Base's article "How To Save and Restore State of Dockable Toolbars."  However, I can't seem to get this to work.  I embedded my CNewSldClass dialog bar which is derived from CMyOwnDialogBar inside my CMDIChildWnd code.  CMyOwnDialogBar is derived from CDialogBar.  I get an assert failed in DOCKSTAT.CPP line 477.  Following is an excerpt of my code in the CMDIChildWnd:
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
      // TODO: Add your specialized creation code here
      //allow docking to left, right and bottom
      DWORD dwStyle = CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_FIXED;//CBRS_SIZE_DYNAMIC for allowing size change
      if (!m_wndPaletteBar.Create(this, IDD_DIALOGBAR1_DIALOG,
                                                dwStyle,
                                                IDD_DIALOGBAR1_DIALOG, FALSE))//TRUE to create sizeable CDialogBar
      {
            TRACE0("Failed to create dialog bar\n");
            return -1;      // fail to create
      }
      if (m_wndPaletteBar.CreatePaletteToolbar() == FALSE)
      {
            TRACE("Failed to create toolbar.");
            return -1;
      }
      m_wndPaletteBar.SetCaptionText("Tools");

      //create the slide
      dwStyle = CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC;//CBRS_SIZE_DYNAMIC for allowing size change
      if (!m_wndSlideBar.Create(this, IDD_DIALOGBAR2_DIALOG,
                                                dwStyle,
                                                IDD_DIALOGBAR2_DIALOG, TRUE))//TRUE to create sizeable CDialogBar
      {
            TRACE("Failed to create dialog bar.\n");
            return -1;      // fail to create
      }
      if (m_wndSlideBar.CreateStudyFolder(NULL) == FALSE)
      {
            TRACE("Failed to create slide toolbar.\n");
            return -1;
      }

      m_wndSlideBar.SetCaptionText("Slides");
      EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT | CBRS_ALIGN_BOTTOM);
      DockControlBar(&m_wndPaletteBar,AFX_IDW_DOCKBAR_RIGHT);
      DockControlBar(&m_wndSlideBar,AFX_IDW_DOCKBAR_LEFT);
      // we need to do that ourseleves.
      LoadBarState(_T("DockState"));
      RecalcLayout();
      return 0;
}

I called the SaveBarState(_T("DockState")) in the OnClose() of CMainFrame.  I hope someone can help me with this problem.

Jennifer
0
Comment
Question by:jli
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:rhgaracci
ID: 1300355
What the assert is saying is that one of the toobar identifiers (IDD_...) that is in the registry entry does not match an existing toolbar.  Did you change identifiers during development?  You should probably check to see what is in the registry for your application.
0
 

Author Comment

by:jli
ID: 1300356
No I did not change the IDD during development.  For some reason the registry only shows DockState-Bar0 containing BarID=0x0000e801 and DockState-Summary containing Bars=0x00000001,ScreenCX=0x00000480 and ScreenCY=0x00000360 even though I create two dialog bars in CChildFrame.  When I first ran the program for the first time without anything entries in the registry, I created my dialog bars docked as you have seen in the code.  Then I dragged one of the two dialog bar to floated state to test the SaveBarState().  I then exit the program.  After this, I ran the program again, and I got the assertion that I have mentioned in my question.  I don't understand why the IDD of the dialog bar in the registry does not match the existing dialog bars.

Jennifer
0
 
LVL 1

Accepted Solution

by:
xbwen earned 50 total points
ID: 1300357
If you create toolbar in CMDIChildWnd, then you should call SaveBarState(_T("DockState"))
in CMDIChildWnd instead of CMainFrame.
0
 

Author Comment

by:jli
ID: 1300358
xbwen,

I changed the SaveBarState(_T("DockState")) call to the destructor of the CMDIChildWnd.  The registry still only shows DockState-Bar0 containing BarID=0x0000e801 and DockState-Summary containing Bars=0x00000001,ScreenCX=0x00000480 and ScreenCY=0x00000360.  However, I do not get the assertion and invalid operation after moving to the MDI child.  Still my problem is not resolved.  When I call the LoadBarState(_T("DockState")) in the OnCreate() of the MDI child the two dialog bar still were docked even though I purposely floated the two dialog bars before I exited the program.  Please help because my deadline is coming up soon.  Thanks.

Jennifer
0
 
LVL 1

Expert Comment

by:xbwen
ID: 1300359
  If you move all your stuff in CMDIChildWnd::OnCreate() to CMainFrame, which means all the toolbars are define as the member
of CMainFrame,(I think it is the recommand way), I am sure the
LoadBarState,SaveBarState() things will work very well.
but in CMDIChildWnd,  I am not sure, maybe it cann't support in MDIChildWnd or maybe it is a bug of MFC, please check with the online document about FrameWnd. The normal way we use is put toolbar in MainFrame.
 
   Hope this can help you.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now