Cursor Pos on Status Bar
PRAVEEN K. DADUY -- msa3431@msbg.med.ge.com Wednesday, October 09, 1996 .int mfc-l@netcom.com Hi, Environment : MS Windows 3.1 & Visual C++ 1.50 I am displaying the cursor position (in terms of line number and column no) on the status bar. I want to ERASE it when there are NO DOCUMENTS open. Can anyone help me how to erase it. Thanks in advance Praveen
Severino Delaurenti -- del@alpha.ico.olivetti.com Thursday, October 10, 1996 [Mini-digest: 10 responses] Hi Praveen, You can handle this situation in your CView derived class: Override the two functions OnSetFocus and OnKillFocus: when your view = receives the focus display coordinates with a string like "X =3D xx Y = =3D yy"; when the view loose focus display an empty string "". In this way, when you have more Views on more Documents, you are sure = that the View with the focus displays its coordinates on the status bar = pane. I hope this helps you Bye Severino Delaurenti del@alpha.ico.olivetti.com Olivetti Lexikon Spa Italy ---------- From: PRAVEEN K. DADUY[SMTP:MSA3431@msbg.med.ge.com] Sent: 09 October 1996 14:56 To: mfc-l@netcom.com Subject: Cursor Pos on Status Bar .int mfc-l@netcom.com Hi, Environment : MS Windows 3.1 & Visual C++ 1.50 I am displaying the cursor position (in terms of line number and column = no) on the status bar. I want to ERASE it when there are NO DOCUMENTS open. Can anyone help me how to erase it. Thanks in advance Praveen -----From: Daniel GreenIt seems there are two issues involved. Firstly, how to erase a pane. Secondly, when and where to erase a pane. In answer to the first question to you can hopefully use a function similar to this: void CMainFrame::ClrPaneText(const int& nPane) { m_wndStatusBar.SetPaneText(nPane, NULL); } As to when are where to call the function, perhaps OnActivateView is appropriate. I hope much (some?, any?) of this applies to VC 1.50 as well. Dan. -----From: David.Lowndes@bj.co.uk Praveen, How about doing the update during idle processing. Use GetActiveDocument, and if it returns NULL (no document) you can clear the pane. Dave Lowndes -----From: Mark Conway You can need to add an update handler for the indicator in your mainframe, which disables the indicator (or sets the text to NULL). When you have a document open, it's update handler will get called and the line/col will get displated. When no documents are open (or none with the revelant update handler), the mainframe one will get called, and clear the text. Mark. -----From: Raja Segar That's Easy Man . pStatusBar->SetText( " ", pane_no, 0); Bye. ( _ \/ __)(_ ) ) /\__ \ / /_ (_)\_)(___/(____)@pc.jaring.my -----From: David Little I you can display numbers, you can display blanks, and if you can't display blanks, surely you can display grayed out text..... -----From: Raja Segar Sorry for the previous posting. It was for the Win95 Enviroment Control. The correct code to use is for win 3.1 is as follows:- pStatusBar->SetPaneText( pane_no , " ", TRUE); BTW, pStatusBar is the pointer to your Status Bar. Hope this helps. ( _ \/ __)(_ ) ) /\__ \ / /_ (_)\_)(___/(____)@pc.jaring.my -----From: "Robertson David" I have used the following: void CMainFrame::OnUpdatePosition(CCmdUI* pCmdUI) { pCmdUI->Enable(TRUE); CString strText = _T(""); // In case of no document // Attempt to get the status bar. CStatusBar* pStatusBar = (CStatusBar*)GetDescendantWindow(AFX_IDW_STATUS_BAR); if (pStatusBar != NULL) { // Attempt to get an active frame. CMDIChildWnd* pFrame = MDIGetActive(); if (pFrame != NULL) { // Attempt to get the frame's view. CRichEditView* pView = (CRichEditView*)pFrame->GetActiveView(); if (pView != NULL) { // Get the current line/column information. // Create the text to be centered in the display pane. strText.Format(_T("Ln %u, Col %u"), line, col); } } // Set the indicator's text. pStatusBar->SetPaneText(pStatusBar->CommandToIndex(ID_LINE_COLUMN), strText); } } -----From: "MHENRY.UMI.COM" I assume that you're probably setting the line and cursor position in your document in some kind of "OnUpdatePosition" function (or whatever you happen to call it). Do it in your mainframe instead; get the active view and then get the information from the view to update the position indicator. If there is no active view then blank it out. --matt /~~~~~~~~~~~~~~~~~~~~~~~~~~~ Matthew Henry -- UMI mhenry@umi.com (Work) mhenry1384@aol.com (Home) ~~~~~~~~~~~~~~~~~~~~~~~~~~/ -----From: "Ferguson, Jeff" You should be able to set an empty string ("") into the status bar when documents are closed. The empty string should "erase" the status bar.
| Вернуться в корень Архива |