Click to See Complete Forum and Search --> : CStatusBar


MarcV
July 13th, 1999, 08:10 AM
Hi,

I seem unable to update the statusbar in an MDI.
I have tried ON_COMMAND_UPDATE_UI, and SetTimer.

Each work, but only when a Document/View is not
open.

Any thoughts?


--

P eter C.
July 13th, 1999, 08:28 AM
try m_wndStatusBar.UpdateWindow()

where m_wndStatusBar is your object.

MarcV
July 13th, 1999, 08:38 AM
Thanks... I'll try that now :-)


--

MarcV
July 13th, 1999, 09:21 AM
Nop...

What I am trying to do is place the time in the statusbar. The code works when a doc/view is not open (i.e. the mainframe only ). But when I create a new document (CFormView) time disappears.

As the app opens with a new document it the time is not displayed until the document is closed.

All the code for displaying the time is in the MainFrame - I wondered if it should go in the ChildFrame and then update the statusbar in from there?

kind regards,

--
Marc

bimmer boy
July 13th, 1999, 10:48 AM
are you calling UpdateWindow after a change is made?

miked

P eter C.
July 14th, 1999, 07:18 AM
Aahh, I think now I got your problem. Of course, you have to update the status bar in your document or in its related view or even in the childframe, either way is possible, depending upon where your command handlers are situated.
try this:
place if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,...

and so on...
in OnCreate(...) of CChildFrame or its derivative in the same manner as this is done in CMainFrame.
Put static CStatusBar m_wndStatusBar;

in the header file of ChildFrame(i.e. in its class declaration)
Put CStatusBar CCameraWnd::m_wndStatusBar;

in the class definition of Childframe, that means, in the .cpp file. If now you want to update the status bar from the view, put include "ChildFrame.h"

in view.cpp (or however you called it). Now you can update it by
CChildFrame::m_wndStatusBar.UpdateWindow();


From the document it should also work, if you include here as well.

This was a solution, if the child window has its own status bar. But you can easily update the status bar of the MainFrame from whereever you want:
Place CMainFrame* pMain=(CMainFrame*)AfxGetMainWnd();


in the file, from where it shall be updated.
With pMain->m_wndStatusBar.UpdateWindow();

it should work.
Of course, this requires #include "MainFrm.h"

in the same file.

hope, that'll work!

MarcV
July 14th, 1999, 07:54 AM
Yep... no go.

If I do SetPaneText( 0, "testing" ) this works for the far left, but setting the index to 1 does nothing (there is one sunked pane)



--
Marc

MarcV
July 14th, 1999, 07:58 AM
Cheers!

I'll give this a go.

I've now got through the timers which I now have one in the App class and am updating the Child/MainFrames statusbars from there. This seems to work well, execept the updating :-(

Anyhow. Many thanks, I'll try the code.

Kind regards,

--
Marc