Status Pane
-
You have not answered my first question about index, have you passed 0th index ? And where exactly it is crashing in above code? you are definitely using invalid pointer here.
Prasad Notifier using ATL | Operator new[],delete[][^]
Actually my requirement is to set width of the second pane only. I have told that first pane by mistake. My initial statement, m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100); is the right requirement only. If I use this code, I got the afore mentioned exception.(refer last message by me).
-
Actually my requirement is to set width of the second pane only. I have told that first pane by mistake. My initial statement, m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100); is the right requirement only. If I use this code, I got the afore mentioned exception.(refer last message by me).
Ok, At which line exactly, debugger is showing crash ? I can run this code in sample SDI app, without any problem.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Ok, At which line exactly, debugger is showing crash ? I can run this code in sample SDI app, without any problem.
Prasad Notifier using ATL | Operator new[],delete[][^]
If I remove the comments from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); an exception occurs. If I break that exception, it goes to a file called barstat.cpp void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth) { ASSERT_VALID(this); BOOL bChanged = FALSE; AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex); pSBP->nID = nID; if (pSBP->nStyle != nStyle) ********{ if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH) bChanged = TRUE; else { pSBP->nStyle = nStyle; pSBP->nFlags |= SBPF_UPDATE; SetPaneText(nIndex, pSBP->strText); } pSBP->nStyle = nStyle; } if (cxWidth != pSBP->cxText) { // change width of one pane -> invalidate the entire status bar pSBP->cxText = cxWidth; bChanged = TRUE; } if (bChanged) UpdateAllPanes(TRUE, FALSE); } The yellow pointer appears in the line where ******** is shown. What may be the problem? -- modified at 1:27 Monday 12th February, 2007
-
If I remove the comments from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); an exception occurs. If I break that exception, it goes to a file called barstat.cpp void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth) { ASSERT_VALID(this); BOOL bChanged = FALSE; AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex); pSBP->nID = nID; if (pSBP->nStyle != nStyle) ********{ if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH) bChanged = TRUE; else { pSBP->nStyle = nStyle; pSBP->nFlags |= SBPF_UPDATE; SetPaneText(nIndex, pSBP->strText); } pSBP->nStyle = nStyle; } if (cxWidth != pSBP->cxText) { // change width of one pane -> invalidate the entire status bar pSBP->cxText = cxWidth; bChanged = TRUE; } if (bChanged) UpdateAllPanes(TRUE, FALSE); } The yellow pointer appears in the line where ******** is shown. What may be the problem? -- modified at 1:27 Monday 12th February, 2007
T.RATHA KRISHNAN wrote:
AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex); pSBP->nID = nID; if (pSBP->nStyle != nStyle)
It may be beacuase, pSBP is NULL. Are you sure, there are two panes present in status bar ? Have you called this function after creating status bar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
If I remove the comments from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); an exception occurs. If I break that exception, it goes to a file called barstat.cpp void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth) { ASSERT_VALID(this); BOOL bChanged = FALSE; AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex); pSBP->nID = nID; if (pSBP->nStyle != nStyle) ********{ if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH) bChanged = TRUE; else { pSBP->nStyle = nStyle; pSBP->nFlags |= SBPF_UPDATE; SetPaneText(nIndex, pSBP->strText); } pSBP->nStyle = nStyle; } if (cxWidth != pSBP->cxText) { // change width of one pane -> invalidate the entire status bar pSBP->cxText = cxWidth; bChanged = TRUE; } if (bChanged) UpdateAllPanes(TRUE, FALSE); } The yellow pointer appears in the line where ******** is shown. What may be the problem? -- modified at 1:27 Monday 12th February, 2007
Is
pSBP
valid?
WhiteSky
-
T.RATHA KRISHNAN wrote:
AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex); pSBP->nID = nID; if (pSBP->nStyle != nStyle)
It may be beacuase, pSBP is NULL. Are you sure, there are two panes present in status bar ? Have you called this function after creating status bar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
Yes, There are two status bar panes. I've called SetPaneInfo function after creating the Status Bar only. The code for displaying message in the status bar pane is, void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); } Here this line, CDC* pDC = m_wndStatusBar.GetDC(); compiles without any problem. This line also, pDC->SetTextAlign(TA_RIGHT); compiles without problem. But not displaying message right aligned. If I remove commenting from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); then only that exception occurs.
-
Yes, There are two status bar panes. I've called SetPaneInfo function after creating the Status Bar only. The code for displaying message in the status bar pane is, void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); } Here this line, CDC* pDC = m_wndStatusBar.GetDC(); compiles without any problem. This line also, pDC->SetTextAlign(TA_RIGHT); compiles without problem. But not displaying message right aligned. If I remove commenting from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); then only that exception occurs.
Show the code, how you have created this status bar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Show the code, how you have created this status bar ?
Prasad Notifier using ATL | Operator new[],delete[][^]
The code for creating Status Bar is, if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } Here is the Indicators. static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; IDS_MESSAGE is the ID of the second pane. The pane in which we display the message. ID_SHOWFPS is the ID of the First pane. I display the message in some other class using the following code. void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); }
-
The code for creating Status Bar is, if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } Here is the Indicators. static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; IDS_MESSAGE is the ID of the second pane. The pane in which we display the message. ID_SHOWFPS is the ID of the First pane. I display the message in some other class using the following code. void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); }
T.RATHA KRISHNAN wrote:
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; }
I'm seeing nothing wrong with your code, its creation is succesful. May be you mail send across your sample code ay prasad.som at mail dot com.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Yes, There are two status bar panes. I've called SetPaneInfo function after creating the Status Bar only. The code for displaying message in the status bar pane is, void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); } Here this line, CDC* pDC = m_wndStatusBar.GetDC(); compiles without any problem. This line also, pDC->SetTextAlign(TA_RIGHT); compiles without problem. But not displaying message right aligned. If I remove commenting from this line, //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); then only that exception occurs.
I think its strange that one problem persists for such a long time... :sigh: I have some questions for you. 1. Have you used "SetIndicators" function? >> If you are not using function, your prograam will definitely crash. 2. What is the idea behind doing these operations in a DOC class? 3. Is it possible to share the code you are using to create status bars? thanks and regards haribabu
-
The code for creating Status Bar is, if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } Here is the Indicators. static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; IDS_MESSAGE is the ID of the second pane. The pane in which we display the message. ID_SHOWFPS is the ID of the First pane. I display the message in some other class using the following code. void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); }
If you call, m_wndStatusBar.SetPaneInfo(0, IDS_MESSAGE, SBPS_STRETCH, len); is program crashing?
-
I think its strange that one problem persists for such a long time... :sigh: I have some questions for you. 1. Have you used "SetIndicators" function? >> If you are not using function, your prograam will definitely crash. 2. What is the idea behind doing these operations in a DOC class? 3. Is it possible to share the code you are using to create status bars? thanks and regards haribabu
Here is the indicators array. static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; The code that is used to create status bars. if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } These two codes are in the same file only(MainFrm.cpp)
-
T.RATHA KRISHNAN wrote:
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; }
I'm seeing nothing wrong with your code, its creation is succesful. May be you mail send across your sample code ay prasad.som at mail dot com.
Prasad Notifier using ATL | Operator new[],delete[][^]
Could U pls send me your correct email ID? (like this one rtr_18@yahoo.com)
-
Actually my requirement is to set width of the second pane only. I have told that first pane by mistake. My initial statement, m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_STRETCH,100); is the right requirement only. If I use this code, I got the afore mentioned exception.(refer last message by me).
T.RATHA KRISHNAN wrote:
Actually my requirement is to set width of the second pane only.
Do you have to use
SetPaneInfo()
to do this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
The code for creating Status Bar is, if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } Here is the Indicators. static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; IDS_MESSAGE is the ID of the second pane. The pane in which we display the message. ID_SHOWFPS is the ID of the First pane. I display the message in some other class using the following code. void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI) { char str1[150]; //int len = message.GetLength(); sprintf(str1, "%s",message.GetString()); CDC* pDC = m_wndStatusBar.GetDC(); pDC->SetTextAlign(TA_RIGHT); pCmdUI->Enable(TRUE); //m_wndStatusBar.SetPaneInfo(1,IDS_MESSAGE,SBPS_NORMAL,100); pCmdUI->SetText((const char *)str1); //m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len); }
T.RATHA KRISHNAN wrote:
static UINT indicators[] = { 0,// ID_SEPARATOR IDS_MESSAGE, ID_SHOWFPS, }; IDS_MESSAGE is the ID of the second pane.
Do you have an entry for
IDS_MESSAGE
in the stringtable resource?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Could U pls send me your correct email ID? (like this one rtr_18@yahoo.com)
T.RATHA KRISHNAN wrote:
Could U pls send me your correct email ID?
It is correct.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb