⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wpw_mfc_statusbar_95.html

📁 VC programing
💻 HTML
字号:
<HTML>
<HR><A NAME=MFC_CStatusBar_AddTime>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br> 
<H4>Subject: How Can I add time to the status bar?</H4><PRE>

In article <3j35vcFMz/6N083yn@linux.cowland.com>, monty@linux.cowland.com 
says...
>
>Hi,
> I have just taken up MS VC++ again. One of the things that is stumping
>me at the moment is how to add in the time (and naturally update it
>regularly). The only pre defined 'panes' seem to be overwrite, num lock,
>scroll lock and caps.
>
>Any and all help much appreciated.
>
>Thanks,
>
>Bryan


Create a pane, create a call to ON_UPDATE_UI handler for that pane and 
enable it in the called function, since all panes are disabled by 
default.  Where you set the text to the pane is up to you.  If you set 
the text in the pane, but dont have the ON_UPDATE_UI handler to enable 
the pane then the text will get updated, but will be made invisible.

I can post code if you need it.


Ken
(argo@rias.com)

<HR>
Quoting monty@linux.cowland.com (Bryan R. Montgomery):

  > Hi,
  >  I have just taken up MS VC++ again. One of the things that is stumping
  > me at the moment is how to add in the time (and naturally update it
  > regularly). The only pre defined 'panes' seem to be overwrite, num lock,
  > scroll lock and caps.


The following is from one of my apps, and shows the time/date in the right part of
the status bar:


// From mainfrm.h:

class CMainFrame : public CMDIFrameWnd
{
     DECLARE_DYNAMIC(CMainFrame)
public:
     CMainFrame();

protected:
     CStatusBar  m_wndStatusBar;
...



// From mainfrm.cpp:

static UINT BASED_CODE indicators[] =
{
     ID_SEPARATOR,                                      // Message Line field
     ID_SEPARATOR                                       // Date/Time field
};


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     // First call base class 'OnCreate'
     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
          return -1;


     // Add Status bar
     if (!m_wndStatusBar.Create(this) ||
         !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))
     {
          TRACE("Failed to create status bar\n");
          return -1;
     }
     else
     {
          // Finish setup of Status Bar
          m_wndStatusBar.SetPaneInfo(0, 0, SBPS_STRETCH, 0);
          if (!SetTimer(1,30000,NULL))                 // 30-sec timer to update time display
          {
               TRACE("Call to SetTimer failed\n");
               return -1;
          }
     }

     // Done
     return(0);
}


void CMainFrame::OnTimer(UINT nIDEvent)
{
     CStatusBar *     pBar;
     CTime               theTime = CTime::GetCurrentTime();
     CString             sTimeDate = theTime.Format("%I:%M%p    %B %d, %Y");

     // Process timer event
     if (nIDEvent == 1)
     {
          // Update time/date display
          if (pBar = (CStatusBar *) GetDescendantWindow(AFX_IDW_STATUS_BAR))
               pBar->SetPaneText(1,sTimeDate);
     }
}


Hope this helps!

Robin Rosas    <r_cubed@teleport.com>
</PRE>


<HR><A NAME=MFC_CStatusBar_UPdate>
Return to <a href="wpw_mfc_index.html#TOC">Table of Contents for this chapter</a><br> 
<H4>Subject: Write to Status Bar</H4><PRE>
In article <3tmafu$hvb@sgi.iunet.it> mc7151@mclink.it "Vincenzo Vasta" writes:

>I would like to write a number in the pane 1
>of the status bar of my application.
>I try to use :
>m_wndStatusBar.SetPaneText(1,str);
>
>but inside the pane 1 doesn't appear nothing.
>I have to write this number at any time,
>without answering to a message.
>
>Can anyone help me ?

You need to add an "OnUpdateUI" handler for your pane, and call the
"Enable(TRUE)" member of the "CCmdUI" class from it.

Chris
-- 
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK      | Author of SkyMap v2 shareware    |
| chris@chrism.demon.co.uk            | astronomy program for Windows.   |
|      For more info, see http://www.winternet.com/~jasc/skymap.html     |
|      Author member of Association of Shareware Professionals (ASP)     |
--------------------------------------------------------------------------
 
</PRE> 

</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -