15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Loading toolbar state problem

Alex -- alexp@sharnoa.co.il
Sunday, January 19, 1997

Environment: VC++ 4.0, Win95.

Hi, Guys!
I have an problem with loading of visible state of toolbars.
I use the CMDIFrameWnd:: SaveBarState() in OnClose() message handler,
and CMDIFrameWnd:: LoadBarState() in OnCreate() handler (after the
toolbars
creation), to save/load the toolbars visible state to/from  application
INI file.
Everything works fine, but in one case I get an assertion fault from MFC
code at
the loading of toolbars information.
The problematic case is when I put two toolbars together on one side of
the frame
window in the LINE. The CFrameWnd::GetControlBar() function generates an
Assertion,
and I don=92t understand why.
This is the MS implementation of CFrameWnd::GetControlBar()
CControlBar* CFrameWnd::GetControlBar(UINT nID)
{
	if (nID =3D=3D 0)
		return NULL;
	POSITION pos =3D m_listControlBars.GetHeadPosition();
	while (pos !=3D NULL)
	{
		CControlBar* pBar =3D (CControlBar*)m_listControlBars.GetNext(pos);
		ASSERT(pBar !=3D NULL);
		ASSERT_VALID(pBar);
		if (_AfxGetDlgCtrlID(pBar->m_hWnd) =3D=3D nID)
		{
			ASSERT_KINDOF(CControlBar, pBar);
			return pBar;
		}
	}
	return NULL;
}

The ASSERT_VALID(pBar); macro fails in its validation of the toolbars,
putted in
line on the same side of the Frame window. =

The ASSERT_VALID macro implementation looks as following:
void CDockBar::AssertValid() const
{
	CControlBar::AssertValid();
	ASSERT(m_arrBars.GetSize() !=3D 0);
	ASSERT(m_arrBars[0] =3D=3D NULL);
	ASSERT(m_arrBars[m_arrBars.GetUpperBound()] =3D=3D NULL);
}

The last assertion  ASSERT(m_arrBars[m_arrBars.GetUpperBound()] =3D=3D
NULL); fails!!!
My questions are: =

1.There is an bug in MFC or I am doing something wrong?
2. Can anybody help me to fix this problem?
3. Can anybody show me the way how can I create toolbar initially
invisible?
Thank You in advance. =


-- =

 ____________________________________________________________
|                     |                                      |
| Alexander Fok       | E-mail:  alexp@sharnoa.co.il         |
| Software Engineer   | Office:  +972-7-6285058              |
|                     |    Fax:  +972-7-6277859              |
| Xtrol (Sharnoa)     | Home:    +972-7-6271886              |
| Corporation Israel  | WWW : http://www.cs.bgu.ac.il/~alexf |
|_____________________|______________________________________|



Manolis Chr.Papadopoulos -- papadop@metal.ntua.gr
Tuesday, January 21, 1997

[Mini-digest: 3 responses]

Hi,

there has been a thread in this list about the inability of VC++ to load =
a saved bar, so you can check in the mfc-list archive =
(advn.com/pub/mfc/). The problem only arises if the toolbar is a =
resource. If it is created dynamically, there is no problem. There is a =
sample in the CD, \msdev\samples\mfc\general\docktool. There, you can =
see that the toolbars are dynamically created, so there is no problem. I =
think, the 4.2 version is working fine, they fixed it, but I don't know =
for sure, I also have 4.0.=20

----------
From: 	Alex
Sent: 	=CA=F5=F1=E9=E1=EA=DE, 19 =C9=E1=ED=EF=F5=E1=F1=DF=EF=F5 1997 =
11:51 =F0=EC
To: 	mfc-l list
Subject: 	Loading toolbar state problem

Environment: VC++ 4.0, Win95.

Hi, Guys!
I have an problem with loading of visible state of toolbars.
I use the CMDIFrameWnd:: SaveBarState() in OnClose() message handler,
and CMDIFrameWnd:: LoadBarState() in OnCreate() handler (after the
toolbars
creation), to save/load the toolbars visible state to/from  application
INI file.
Everything works fine, but in one case I get an assertion fault from MFC
code at
the loading of toolbars information.
The problematic case is when I put two toolbars together on one side of
the frame
window in the LINE. The CFrameWnd::GetControlBar() function generates an
Assertion,
and I don't understand why.
This is the MS implementation of CFrameWnd::GetControlBar()
CControlBar* CFrameWnd::GetControlBar(UINT nID)
{
	if (nID =3D=3D 0)
		return NULL;
	POSITION pos =3D m_listControlBars.GetHeadPosition();
	while (pos !=3D NULL)
	{
		CControlBar* pBar =3D (CControlBar*)m_listControlBars.GetNext(pos);
		ASSERT(pBar !=3D NULL);
		ASSERT_VALID(pBar);
		if (_AfxGetDlgCtrlID(pBar->m_hWnd) =3D=3D nID)
		{
			ASSERT_KINDOF(CControlBar, pBar);
			return pBar;
		}
	}
	return NULL;
}

The ASSERT_VALID(pBar); macro fails in its validation of the toolbars,
putted in
line on the same side of the Frame window.=20
The ASSERT_VALID macro implementation looks as following:
void CDockBar::AssertValid() const
{
	CControlBar::AssertValid();
	ASSERT(m_arrBars.GetSize() !=3D 0);
	ASSERT(m_arrBars[0] =3D=3D NULL);
	ASSERT(m_arrBars[m_arrBars.GetUpperBound()] =3D=3D NULL);
}

The last assertion  ASSERT(m_arrBars[m_arrBars.GetUpperBound()] =3D=3D
NULL); fails!!!
My questions are:=20
1.There is an bug in MFC or I am doing something wrong?
2. Can anybody help me to fix this problem?
3. Can anybody show me the way how can I create toolbar initially
invisible?
Thank You in advance.=20

--=20
 ____________________________________________________________
|                     |                                      |
| Alexander Fok       | E-mail:  alexp@sharnoa.co.il         |
| Software Engineer   | Office:  +972-7-6285058              |
|                     |    Fax:  +972-7-6277859              |
| Xtrol (Sharnoa)     | Home:    +972-7-6271886              |
| Corporation Israel  | WWW : http://www.cs.bgu.ac.il/~alexf |
|_____________________|______________________________________|




Mike Marshall -- marshall@milner.com
Thursday, January 23, 1997

	Be careful here.  I'm assuming you are using an AppWizard Generated application.
      The default toolbar that is created in an SDI or MDI app is created in the top level
      CFrameWnd's (CMDIFrameWnd or CFrameWnd) OnCreate().  But, when the
      CToolBar::Create() function is called, the last parameter, which is the toolbar's
      control ID, is left out.  In this case, AFX_IDW_TOOLBAR is used as the ID, because
      it is the default for the nID parameter.

      If you have multiple toolbars, make sure that your toolbar ID's are unique.  If more than
      one use the same ID, LoadBarState will not work correctly.  So make sure that two bars
      are not using that same default bar ID (AFX_IDW_TOOLBAR).


      Mike

----------
From:  Manolis Papadopoulos[SMTP:papadop@metal.ntua.gr]
Sent:  Tuesday, January 21, 1997 5:11 AM
To:  'alexp@sharnoa.co.il'
Cc:  'mfc-l@netcom.com'
Subject:  RE: Loading toolbar state problem

[Mini-digest: 3 responses]

[.. snip .. ]

>Everything works fine, but in one case I get an assertion fault from MFC
>code at
t>he loading of toolbars information.





| Вернуться в корень Архива |