Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. StatusBar Question in MFC

StatusBar Question in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++toolshelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    I've created a menu called Tools where in I have created a menu item called Preferences. If we click the Prefernces menu item Preferences Dialog Box will open. In that Dialog Box I have an edit box. The message entered in this edit box is displayed in the second panel of the status bar (i.e) panel no.1. My Requirement is: The second panel should be of a default size and it should grow according to the length of the message entered in the edit box. How can I achieve this in MFC? Can any one help?

    K F 2 Replies Last reply
    0
    • T T RATHA KRISHNAN

      I've created a menu called Tools where in I have created a menu item called Preferences. If we click the Prefernces menu item Preferences Dialog Box will open. In that Dialog Box I have an edit box. The message entered in this edit box is displayed in the second panel of the status bar (i.e) panel no.1. My Requirement is: The second panel should be of a default size and it should grow according to the length of the message entered in the edit box. How can I achieve this in MFC? Can any one help?

      K Offline
      K Offline
      kasturi_haribabu
      wrote on last edited by
      #2

      Use CStatusBar::SetPaneInfo( int nIndex, UINT nID, UINT nStyle, int cxWidth ); :)

      1 Reply Last reply
      0
      • T T RATHA KRISHNAN

        I've created a menu called Tools where in I have created a menu item called Preferences. If we click the Prefernces menu item Preferences Dialog Box will open. In that Dialog Box I have an edit box. The message entered in this edit box is displayed in the second panel of the status bar (i.e) panel no.1. My Requirement is: The second panel should be of a default size and it should grow according to the length of the message entered in the edit box. How can I achieve this in MFC? Can any one help?

        F Offline
        F Offline
        freeman868
        wrote on last edited by
        #3

        you just need to do it as follows: void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { CString strValue; strValue.Format("%s", message.GetString()); pCmdUI->Enable(TRUE); pCmdUI->SetText(strValue); CDC* pDC = m_wndStatusBar.GetDC(); CSize mSize = pDC->GetTextExtent(strValue); m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx); }

        freeman

        T 1 Reply Last reply
        0
        • F freeman868

          you just need to do it as follows: void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { CString strValue; strValue.Format("%s", message.GetString()); pCmdUI->Enable(TRUE); pCmdUI->SetText(strValue); CDC* pDC = m_wndStatusBar.GetDC(); CSize mSize = pDC->GetTextExtent(strValue); m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx); }

          freeman

          T Offline
          T Offline
          T RATHA KRISHNAN
          wrote on last edited by
          #4

          void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; CString strValue; //strValue.SetLength(100); strValue.Format("%s", message.GetString()); //sprintf(str1, "%s",message.GetString()); pCmdUI->Enable(TRUE); pCmdUI->SetText(strValue); CDC* pDC = m_wndStatusBar.GetDC(); CSize mSize = pDC->GetTextExtent(strValue); m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); } When I add this code I got an exception stating , 'Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014.' When I break this exception, it ends in a class barstat.cpp which is not created by me. Also this exception occurs only when we add the status bar variable(m_wndStatusBar) to this class CPerspectiveDoc. The Status Bar Pane is created in some other class. How to resolve this? Pls help -- modified at 4:01 Tuesday 6th February, 2007

          F 1 Reply Last reply
          0
          • T T RATHA KRISHNAN

            void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; CString strValue; //strValue.SetLength(100); strValue.Format("%s", message.GetString()); //sprintf(str1, "%s",message.GetString()); pCmdUI->Enable(TRUE); pCmdUI->SetText(strValue); CDC* pDC = m_wndStatusBar.GetDC(); CSize mSize = pDC->GetTextExtent(strValue); m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); } When I add this code I got an exception stating , 'Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014.' When I break this exception, it ends in a class barstat.cpp which is not created by me. Also this exception occurs only when we add the status bar variable(m_wndStatusBar) to this class CPerspectiveDoc. The Status Bar Pane is created in some other class. How to resolve this? Pls help -- modified at 4:01 Tuesday 6th February, 2007

            F Offline
            F Offline
            freeman868
            wrote on last edited by
            #5

            Oh, dear friend, I think u've made a mistake! In my opinion, the CDoc class in your project is constructed before the CMainFrame class, and the status bar is created in Oncreate() function of the CMainFrame class. So, you'd used a status object before you created it. Am I right? OK, U can resolve this by many methods.there r 2 simple resolutions follow: 1. U can do this in the CMainFrame class after the status bar object is created. 2. U can do it in the CView class as the same. -- modified at 4:36 Tuesday 6th February, 2007

            freeman

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups