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

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


Hiding a Docked/Floating CDialogBar

Simon Judge -- SJudge@rce.ricardo.com
Friday, January 17, 1997

Environment: VC++ 4.2b, NT 4.0

I have a CDialogBar derived class that I can dock, float and resize.
How can I easily hide/re-show the CDialogBar window?

I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
dialog (created from a resource) rather than the docked or floating
window. I have also tried a CWnd::MoveWindow() to a position outside the
viewing area, but again this only affects the contained dialog window.

I have also tried forcing the parent to RecalcLayout() which causes a
CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
there is a hide in progress. This works but only when the CDialogBar is
docked. When the CDialogBar floats, it seems to become disassociated
with the parent window and can even be displayed outside the main
application frame.

Simon Judge Email: SJudge@rce.ricardo.com
Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
West Sussex, BN43 5FG, United Kingdom.
Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565



Marc Temanson -- met@indy.net
Saturday, January 18, 1997

[Mini-digest: 6 responses]

Why not try the ShowControlBar function within the CFrameWnd class.  That
is what MFC uses to hide and display CDialogBars inserted from component
gallery.  You can verify this by looking at the command handler for the
inserted component.  For example:

 	ON_COMMAND_EX(CG_ID_VIEW_DIALOGBAR, OnBarCheck)

The function OnBarCheck is a member of CFrameWnd which merely toggles the
current show/hidden status of the control bar based on the selection of the
item in the menu.

----------
> From: Simon Judge 
> To: 'mfc-l@netcom.com'
> Subject: Hiding a Docked/Floating CDialogBar
> Date: Friday, January 17, 1997 9:00 AM
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565
-----From: Menny  Hamburger 



>----------
>From: 	Simon Judge[SMTP:SJudge@rce.ricardo.com]
>Sent: 	Friday, January 17, 1997 4:00 PM
>To: 	'mfc-l@netcom.com'
>Subject: 	Hiding a Docked/Floating CDialogBar
>
>Environment: VC++ 4.2b, NT 4.0
>
>I have a CDialogBar derived class that I can dock, float and resize.
>How can I easily hide/re-show the CDialogBar window?
>
>I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the
>contained
>dialog (created from a resource) rather than the docked or floating
>window. I have also tried a CWnd::MoveWindow() to a position outside
>the
>viewing area, but again this only affects the contained dialog window.
>
>I have also tried forcing the parent to RecalcLayout() which causes a
>CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
>there is a hide in progress. This works but only when the CDialogBar is
>docked. When the CDialogBar floats, it seems to become disassociated
>with the parent window and can even be displayed outside the main
>application frame.
>
>Simon Judge Email: SJudge@rce.ricardo.com
>Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
>West Sussex, BN43 5FG, United Kingdom.
>Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565

Hello Simon,
I can see two ways to do this:
1) Use CWnd::ShowControlBar(...).
2) Send the parent frame window of the control bar WM_COMMAND message
with the ID of the control bar.
if the parent has the following lines in the message map, it should
respond
in showing/hiding the control bar, and checking/unchecking the menu item
that has ID_VIEW_MYCONTROLBAR assigned to it:

ON_UPDATE_COMMAND_UI(D_VIEW_MYCONTROLBAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_MYCONTROLBAR, OnBarCheck)
>
-----From: Alex 

Simon Judge wrote:
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea,
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565

Hi, Simon!
You are right, You have to do some more stuff with floating controlbar.
You have to hide/show its mini frame window too. But there is the easy
way to do it - just use the MFCs code.
Try to use the following functions of CFrameWnd
to hide/show the control bars:

CYourMainFrame::ShowHideContolBar()
{
ShowControlBar(&ContraolBar, !ControlBar.IsWindowVisible(), FALSE);
RecalcLayout();
}

It switches between visible/unvisible state of the ControlBar.
Hope it will help.
-- 
 ____________________________________________________________
|                     |                                      |
| 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 |
|_____________________|______________________________________|
-----From: Jim Lawson Williams 

At 02:00 PM 17/01/97 -0000, Simon Judge  wrote:
>
>I have a CDialogBar derived class that I can dock, float and resize.
>How can I easily hide/re-show the CDialogBar window?
>
G'day!
This might be what you want (where CMainframe owns it in this case):

void CMainFrame::OnShowBar() 
{
    //"Show" pressed:
    SetVisibilityForBar(SW_SHOW);
}

void CMainFrame::SetVisibilityForBar(int SW_XXX)
{
    //Handles the button-press above, plus restoring it
    CWnd* pWnd = m_pBar->GetParentOwner();
    if  (pWnd == this)
        pWnd=m_pBar;
    pWnd->ShowWindow(SW_XXX);
}

Regards,
Jim LW


>From the BBC's "Barchester Chronicles":

    "I know that ultimately we are not supposed to understand.
    But I also know that we must try."

       -- the Reverend Septimus Harding, crypt-analyst, clog-dancer, C++ programmer
-----From: Jack Poorte 

Simon:

I believe the ShowControlBar is the function you are after,
as in: 
	ShowControlBar( &m_wndDialogBar, m_bDialog, FALSE );

HTH

Jack Poorte
Austin, Texas


Simon Judge wrote:
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea,
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565
-----From: Ewen Roberts 

Simon Judge wrote:
> Environment: VC++ 4.2b, NT 4.0
> 

Have you tried CFrameWnd::ShowControlBar ?

Syntax (from the help): 
void ShowControlBar( CControlBar* pBar, BOOL bShow, BOOL bDelay );

pBar   Pointer to the control bar to be shown or hidden.
bShow   If TRUE, specifies that the control bar is to be shown. If FALSE, specifies that the control bar is to be hidden.
bDelay   If TRUE, delay showing the control bar. If FALSE, show the control bar immediately.

This works for all CControlBar derived classes, docked or floating.

Ewen (ewen_r@london.altris.com)
"No skeletons in my closet, they're all in the living room drinking martinis"

> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565
> 





Mark Kurt -- mark@toolsfordesign.com
Monday, January 20, 1997

[Mini-digest: 2 responses]

Try using CFrameWnd::ShowControlBar().

----------
> From: Simon Judge 
> To: 'mfc-l@netcom.com'
> Subject: Hiding a Docked/Floating CDialogBar
> Date: Friday, January 17, 1997 6:00 AM
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565
-----From: Shaju Mathew 

Hi Simon,
	Here's what I did to hide and show a CDialogBar :
//my CMainFrame interface:

#include "CustomStatusBar.h"

#define ID_DLGBAR	9999

class CMainFrame : public CMDIFrameWnd//not from CFrameWnd
{
	DECLARE_DYNAMIC(CMainFrame)
public:
	CMainFrame(void);
	void CloseAllChildren(void);
// Attributes
public:

// Operations
public:

// Implementation
public:
	virtual ~CMainFrame(void);
	//inline CStatusBar GetStatusBar(void) { return(m_wndStatusBar); }
#ifdef _DEBUG
	virtual void AssertValid(void) const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
	//CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;
public:
	CStatusBar/*CCustomStatusBar*/  m_wndStatusBar;
protected:
	CDialogBar m_wndDialogBar;//new dialog bar member

// Generated message map functions
protected:
	//{{AFX_MSG(CMainFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnCloseall();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//end CMainFrame header	

Here're the routines that I use to hide this mainframe dialogbar
from one of my views:
void CMyView::OnWindowHidedialogbar(void)
{
	CDialogBar *theDlgBar = (CDialogBar*)
		AfxGetMainWnd()->GetDescendantWindow(ID_DLGBAR);	
		
	theDlgBar->ShowWindow(SW_HIDE);
	((CFrameWnd*)AfxGetMainWnd())->RecalcLayout();
	                                    
	CFrameWnd *theFrameWindow = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
	
	CMenu *theMenu = theFrameWindow->GetMenu();

	ASSERT(theMenu->IsKindOf(RUNTIME_CLASS(CMenu)));

	theMenu->CheckMenuItem(ID_WINDOW_HIDEDIALOGBAR, MF_BYCOMMAND | MF_CHECKED);
	theMenu->CheckMenuItem(ID_WINDOW_SHOWDIALOGBAR, MF_BYCOMMAND | MF_UNCHECKED);
	
	CMyApp *theApp = (CMyApp*)AfxGetApp();
	CMainFrame *theMainFrame = (CMainFrame*)theApp->m_pMainWnd;

	theMainFrame->m_wndStatusBar.SetPaneText(0, "Hides the dialog bar...");
}

void CMyVw::OnWindowShowdialogbar(void)
{
	CDialogBar *theDlgBar = (CDialogBar*)
		AfxGetMainWnd()->GetDescendantWindow(ID_DLGBAR);	
		
	theDlgBar->ShowWindow(SW_SHOW);
	((CFrameWnd*)AfxGetMainWnd())->RecalcLayout();	
	
	CFrameWnd *theFrameWindow = (CFrameWnd*)AfxGetApp()->m_pMainWnd;
	
	CMenu *theMenu = theFrameWindow->GetMenu();

	ASSERT(theMenu->IsKindOf(RUNTIME_CLASS(CMenu)));

	theMenu->CheckMenuItem(ID_WINDOW_SHOWDIALOGBAR, MF_BYCOMMAND | MF_CHECKED);
	theMenu->CheckMenuItem(ID_WINDOW_HIDEDIALOGBAR, MF_BYCOMMAND | MF_UNCHECKED);
	
	CMyApp *theApp = (CMyApp*)AfxGetApp();
	CMainFrame *theMainFrame = (CMainFrame*)theApp->m_pMainWnd;

	theMainFrame->m_wndStatusBar.SetPaneText(0, "Displays the dialog bar...");
}

	This should work - if not, let me know, since it works for me!!
 
> Environment: VC++ 4.2b, NT 4.0
> 
> I have a CDialogBar derived class that I can dock, float and resize.
> How can I easily hide/re-show the CDialogBar window?
> 
> I have tried CWnd::ShowWindow(SW_HIDE) but this just hides the contained
> dialog (created from a resource) rather than the docked or floating
> window. I have also tried a CWnd::MoveWindow() to a position outside the
> viewing area, but again this only affects the contained dialog window.
> 
> I have also tried forcing the parent to RecalcLayout() which causes a
> CalcDynamicLayout() which I have coded to set the SIZE(0,0) whenever
> there is a hide in progress. This works but only when the CDialogBar is
> docked. When the CDialogBar floats, it seems to become disassociated
> with the parent window and can even be displayed outside the main
> application frame.
> 
> Simon Judge Email: SJudge@rce.ricardo.com
> Ricardo Consulting Engineers, Bridge Works, Shoreham-By-Sea, 
> West Sussex, BN43 5FG, United Kingdom.
> Tel. +44 (0) 1273 455611 x 2774 Fax. +44 (0) 1273 794565
> 


--
***********************************************************************
                              .---.         .---.
Shaju Mathew                 /" "  \  WWW  /  " "\    Off:(916)785-9018 
Performance Technology Lab  / / ""  \(*|*)/  "" \ \ 
WCSO Group R & D           //////   '. V .`   \\\\\\ Home:(916)722-4576
Hewlett-Packard Company   //// / // : """ : \\ \ \\\\
8000, Foothills Blvd     // /   /  /`.""" '\  \   \ \\Fax:(916)785-1264
MS 5723, Roseville      //          //.".\\          \\
CA 95747-5723        	     -------UU---UU-------
                                   '//|||\\`        Shaju_Mathew@hp.com
***********************************************************************




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