CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: CStatusBar

  1. #1
    Join Date
    Jul 1999
    Posts
    29

    CStatusBar

    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?


    --

  2. #2
    Join Date
    Jun 1999
    Posts
    10

    Re: CStatusBar

    try m_wndStatusBar.UpdateWindow()

    where m_wndStatusBar is your object.


  3. #3
    Join Date
    Jul 1999
    Posts
    29

    Re: CStatusBar

    Thanks... I'll try that now :-)


    --

  4. #4
    Join Date
    Jul 1999
    Posts
    29

    Re: CStatusBar

    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

  5. #5
    Join Date
    Jun 1999
    Posts
    315

    Re: CStatusBar

    are you calling UpdateWindow after a change is made?

    miked

  6. #6
    Join Date
    Jun 1999
    Posts
    10

    Re: CStatusBar

    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!


  7. #7
    Join Date
    Jul 1999
    Posts
    29

    Re: CStatusBar

    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

  8. #8
    Join Date
    Jul 1999
    Posts
    29

    Re: CStatusBar

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured