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

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


Windows Explorer-like Status Bars

Erik Thomas -- ErikThomas@msn.com
Wednesday, March 05, 1997

Environment: VC++ 4.2-flat, Win 95

I have created an application that mimics much of the visual functionality of 
the Windows 95 Explorer, with a two paned splitter (left side is Tree view, 
right side can be List or Grid view depending on selection of Tree node).

I would like to implement a status bar control along the top of each pane 
(view) under the frame's toolbar to display status messages from their 
respective views. When the user moves the splitter bar left or right, the 
status bars need to resize to match the horizontal width of the respective 
splitter pane (look at the Windows Explorer's two status bars positioned over 
each of the two views to see exactly what I am trying to accomplish).

It seems the best place to create a CStatusBarCtrl is in the Frame window's 
OnCreate(), using CCS_TOP style, then override the CStatusBarCtrl control's 
OnSize() and recalculate the horizontal sizes of the two paned status bar 
based on the sizes of the splitter panes. Am I on the right track? 

I can't find any examples of how to do this in my MSDN CD (July 96) or in 
Microsoft.com/kb. If I drop back to using CStatusBar, I can successfully 
create it in the correct position, but only with a single pane or with 
indicators. When I try to create a CStatusBarCtrl, it appears in the wrong 
location of the screen (overwrites the top of the splitter client area instead 
of inserting an additional client area to accomodate the control like with 
CStatusBar).

Does anyone know where I can find an example? Thanks for your help.

Erik Thomas
E.J.Thomas & Associates
ErikThomas@msn.com



Jeff Lindholm -- JeffL@inter-intelli.com
Thursday, March 06, 1997

[Mini-digest: 4 responses]

Actually those windows are just static text windows.

>----------
>From: 	Erik Thomas[SMTP:ErikThomas@msn.com]
>Sent: 	Wednesday, March 05, 1997 1:34 PM
>To: 	mfc-l@netcom.com
>Subject: 	Windows Explorer-like Status Bars
>
>Environment: VC++ 4.2-flat, Win 95
>
>I have created an application that mimics much of the visual functionality of
>the Windows 95 Explorer, with a two paned splitter (left side is Tree view, 
>right side can be List or Grid view depending on selection of Tree node).
>
>I would like to implement a status bar control along the top of each pane 
>(view) under the frame's toolbar to display status messages from their 
>respective views. When the user moves the splitter bar left or right, the 
>status bars need to resize to match the horizontal width of the respective 
>splitter pane (look at the Windows Explorer's two status bars positioned over
>each of the two views to see exactly what I am trying to accomplish).
>
>It seems the best place to create a CStatusBarCtrl is in the Frame window's 
>OnCreate(), using CCS_TOP style, then override the CStatusBarCtrl control's 
>OnSize() and recalculate the horizontal sizes of the two paned status bar 
>based on the sizes of the splitter panes. Am I on the right track? 
>
>I can't find any examples of how to do this in my MSDN CD (July 96) or in 
>Microsoft.com/kb. If I drop back to using CStatusBar, I can successfully 
>create it in the correct position, but only with a single pane or with 
>indicators. When I try to create a CStatusBarCtrl, it appears in the wrong 
>location of the screen (overwrites the top of the splitter client area
>instead 
>of inserting an additional client area to accomodate the control like with 
>CStatusBar).
>
>Does anyone know where I can find an example? Thanks for your help.
>
>Erik Thomas
>E.J.Thomas & Associates
>ErikThomas@msn.com
>
-----From: "Eric Rosenquist" 

On  5 Mar 97 at 18:34, Erik Thomas wrote:

> Environment: VC++ 4.2-flat, Win 95
> 
> I have created an application that mimics much of the visual functionality of 
> the Windows 95 Explorer, with a two paned splitter (left side is Tree view, 
> right side can be List or Grid view depending on selection of Tree node).
> 
> I would like to implement a status bar control along the top of each pane 
> (view) under the frame's toolbar to display status messages from their 
> respective views. When the user moves the splitter bar left or right, the 
> status bars need to resize to match the horizontal width of the respective 
> splitter pane (look at the Windows Explorer's two status bars positioned over 
> each of the two views to see exactly what I am trying to accomplish).
> 
> It seems the best place to create a CStatusBarCtrl is in the Frame window's 
> OnCreate(), using CCS_TOP style, then override the CStatusBarCtrl control's 
> OnSize() and recalculate the horizontal sizes of the two paned status bar 
> based on the sizes of the splitter panes. Am I on the right track? 
> 
> I can't find any examples of how to do this in my MSDN CD (July 96) or in 
> Microsoft.com/kb. If I drop back to using CStatusBar, I can successfully 
> create it in the correct position, but only with a single pane or with 
> indicators. When I try to create a CStatusBarCtrl, it appears in the wrong 
> location of the screen (overwrites the top of the splitter client area instead 
> of inserting an additional client area to accomodate the control like with 
> CStatusBar).

If you *really* want it to act like Explorer, then build the status text
area into the top portion of each of the views.  If you look at
Explorer's windows with Spy++ you'll see that each view has its own
static text control (note also that the splitter bar goes all the way up
between the two status areas).

For something that looks very similar and is easier to code, create a
CStatusBar in the frame with the CBRS_TOP style and two indicators, then
do a:

	 m_StatusBar.SetPaneStyle(1, SBPS_STRETCH);

Now the only trick is to keep the width of the status bar panes in sync 
with the splitter width.  I couldn't find any place where the splitter 
informs the frame after a size change, so the cleanest way to catch 
changes is probably to derive a new class from CSplitterWnd and override 
RecalcLayout().  In your RecalcLayout() you can call the base class and 
then size the status bar panes.  Here's the code you'd need if the frame 
were doing the sizing:

	int		cxWidth;
	int		junk;
	UINT	nID;
	UINT	nStyle;

	m_StatusBar.GetPaneInfo(0, nID, nStyle, cxWidth);
	m_Splitter.GetColumnInfo(0, cxWidth, junk);
	m_StatusBar.SetPaneInfo(0, nID, nStyle, cxWidth - 1);

If you make your new splitter class do the sizing itself, then you can 
find the status bar via:

	CStatusWnd * pStat = STATIC_DOWNCAST(CStatusWnd, GetParentFrame()->GetMessageBar());

and you should be able to move it via code similar to the above.  The 
views can update their panes via:

	CStatusWnd * pStat = STATIC_DOWNCAST(CStatusWnd, GetParentFrame()->GetMessageBar());
	pStat->SetPaneText(myPaneNumber, "New text");

Hopefully this is what you're after.

Eric
---------------------------------------------------------------------
Eric Rosenquist, Strata Software Limited   http://www.strataware.com/
mailto:rosenqui@strataware.com   Tel: 613-591-1922  Fax: 613-591-3485
Quote: I'm filled with piss and vinegar.  At first I was just full of
       vinegar.
         -- Abraham (Grampa) Simpson
---------------------------------------------------------------------
-----From: Mike Blaszczak 

At 18:34 3/5/97 UT, Erik Thomas wrote:
>Environment: VC++ 4.2-flat, Win 95

MFC 4.2-flat isn't compatible with shipping versions of some
operating system components. 4.2-flat will break against released
versions of those components, which you must be using since the
beta versions aren't supported.  You need to upgrade to MFC 4.2b
by downloading it from the Microsoft web site.

>I would like to implement a status bar control along the top of each pane 
>(view) under the frame's toolbar to display status messages from their 
>respective views. [...] (look at the Windows Explorer's two
>status bars positioned over each of the two views to see exactly
>what I am trying to accomplish).

The explorer isn't using status bar controls where you say it is.  It
is actually using static text controls.  You can see for yourself by
using Spy++.

>I can't find any examples of how to do this in my MSDN CD
>(July 96) or in Microsoft.com/kb. 

Believe it or not, there doesn't exist an example for every single
possible coding practice in every possible platform.

As it stands, the sample at
http://www.microsoft.com/win32dev/ui/chicoapp.htm shows how to do what
you want, but does it using plain C.  You might want to review the
design of that application and translate it to MFC.

>If I drop back to using CStatusBar, I can successfully 
>create it in the correct position, but only with a single pane or with 
>indicators. When I try to create a CStatusBarCtrl, it appears in the wrong 
>location of the screen (overwrites the top of the splitter client area
instead 
>of inserting an additional client area to accomodate the control like with 
>CStatusBar).

This is mainly because CStatusBar knows how to work with a CFrameWnd
to lay itself out (and have the frame window lay out and size the
rest of the client area appropriately), but CStatusBarCtrl doesn't have
any of that layout code.  CStatusBar derives from CControlBar, and 
CStatusBarCtrl derives from CWnd. CWnd doesn't know how to lay itself
out in a frame window, and CControlBar does.


.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
           This performance was not lip-synched.

-----From: "petter.hesselberg" 

You are going about this in a needlessly complicated way. If you check out 
Explorer with a spying tool such as Spy++, you'll see that the information 
panes on the top are simple static child windows (direct children of the main 
window). The sunken look results from the WS_EX_CLIENTEDGE style. In other 
words: All you need is two static windows that are resized as appropriate 
whenever necessary.

This splitting business can also be greatly simplified. Explorer doesn't HAVE a 
splitter bar; it's just the parent window showing through between the cracks of 
the children. All you need to do to get splitter functionality is to handle 
WM_SETCURSOR and mouse messages in this area for the parent.

Regards,
Petter.Hesselberg @ ac.com

_____________________________
To: mfc-l @ netcom.com  @ internet
cc:  (bcc: Petter Hesselberg)
From: ErikThomas @ msn.com ("Erik Thomas") @ internet
Date: 06-03-97 00:34
Subject: Windows Explorer-like Status Bars
_____________________________
Environment: VC++ 4.2-flat, Win 95

I have created an application that mimics much of the visual functionality of 
the Windows 95 Explorer, with a two paned splitter (left side is Tree view, 
right side can be List or Grid view depending on selection of Tree node).

I would like to implement a status bar control along the top of each pane 
(view) under the frame's toolbar to display status messages from their 
respective views. When the user moves the splitter bar left or right, the 
status bars need to resize to match the horizontal width of the respective 
splitter pane (look at the Windows Explorer's two status bars positioned over 
each of the two views to see exactly what I am trying to accomplish).

It seems the best place to create a CStatusBarCtrl is in the Frame window's 
OnCreate(), using CCS_TOP style, then override the CStatusBarCtrl control's 
OnSize() and recalculate the horizontal sizes of the two paned status bar 
based on the sizes of the splitter panes. Am I on the right track? 

I can't find any examples of how to do this in my MSDN CD (July 96) or in 
Microsoft.com/kb. If I drop back to using CStatusBar, I can successfully 
create it in the correct position, but only with a single pane or with 
indicators. When I try to create a CStatusBarCtrl, it appears in the wrong 
location of the screen (overwrites the top of the splitter client area instead 
of inserting an additional client area to accomodate the control like with 
CStatusBar).

Does anyone know where I can find an example? Thanks for your help.

Erik Thomas
E.J.Thomas & Associates
ErikThomas@msn.com





Become an MFC-L member | Вернуться в корень Архива |