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

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


CToolBars

Mario Contestabile -- Mario_Contestabile.UOS__MTL@UOSMTL2.universal.com
Monday, July 15, 1996

Env: MSVC 4.1 Win95 NT 3.51

My last post dealt with using LoadBarState()/SaveBarState() with a heap based
toolbar. 
Although that question still stands, it has been brought to my 
attention that these APIs apparently are bugged as of MSVC 4.1? Is this the 
case?
Apparently they increase the size of the registry file with each call.

At any rate, I'm trying to capture when the user closes the toolbar (small 'x' 
in top right corner).
This was discussed on this list a while ago (see 
www.visionx.com/mfcpro/mfc-l/dce507.htm).
The previous suggestion that your CToolBar derived class should handle 
ON_WM_CLOSE() does not work for me. Note my toolbar is new'ed, it is not
simply a m_ToolBar member in my mainframe class. The toolbar's OnDestroy()
is only called when the mainframe, who is the parent, is destroyed [exit app].
The m_bAutoDelete public CToolBar member is set to true, so I don't have
to delete the allocated toolbar. I thought that setting that member would
call OnDestroy() when the toolbar is closed, but it isn't the case.

Anybody accomplish this?
mcontest@universal.com




Douglas Earl -- dae@Rational.COM
Thursday, July 18, 1996

[Mini-digest: 3 responses]

Mario Contestabile wrote:

> 
> 
> At any rate, I'm trying to capture when the user closes the toolbar (small 'x'
> in top right corner).
> This was discussed on this list a while ago (see
> www.visionx.com/mfcpro/mfc-l/dce507.htm).
> The previous suggestion that your CToolBar derived class should handle
> ON_WM_CLOSE() does not work for me. Note my toolbar is new'ed, it is not

Toolbars don't get WM_CLOSED when the user closes it via the small x, rather 
they just get hidden.
-----From: Bill McGarry 

Well, I can answer this half of the question.  Yes, the problem still exists
in MFC 4.1 but Microsoft did come up with a fix which I have been using with
no problems so far.  The fix is to clean up the data structures before they
are saved to the .ini file or registry.  The fix is in the Knowledge Base
(ID #151446).

Here's the URL to take you directly to the article:

http://www.microsoft.com/kb/developr/visual_c/q151446.htm

Hope this helps!
Bill McGarry
Olivetti North America
billm@mail.spk.olivetti.com

-----From: "Greg Tighe" 

Mario,
	The following works for me (at least under Win95:)

1)  Derive a class from CMiniDockFrameWnd (defined in afxpriv.h.)  
Add a WM_CLOSE message handler to this class.

2)  In CYourMainFrame class (presumably in OnCreate()) add the 
following line after your call to EnableDocking():

    m_pFloatingFrameClass = RUNTIME_CLASS(CMyMiniDock);

CMyMiniDock::OnClose() will be called whenever the (floating) toolbar 
is close by clicking on the 'x' in the upper right corner.

Beware that this method uses undocumented features of MFC 4.1 - 
standard disclaimer applies.


	-Greg Tighe
	Applied Intelligent Systems, Inc.
	Ann Arbor, MI
	gdt@aisinc.com




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