Solved

Status Bar Problem with OVR

Posted on 1998-06-04
3
340 Views
Last Modified: 2013-11-19
Ive been developing a text editor (Im working with CRichEditView as my base class) and I wanted to use the OVR text in the status bar. Now, I managed to make it light up when you hit the INSERT key and turn off, but it always inserts even if the OVR is turned on. For this I used the CCmdUI Enable() function. My question is, how do I make it INSERT or OVERSTRIKE the text while enabling or desabling OVR in the status bar?
0
Comment
Question by:VisualLR
  • 2
3 Comments
 

Accepted Solution

by:
midthune earned 50 total points
ID: 1316034
First, make a bool member of your view class "m_Insert"

void CMyAppView::OnUpdateIns(CCmdUI* pCmdUI)
{
    CString string;

    if( m_Insert )
        string = "INS";
    else
        string = "OVR";

    pCmdUI->SetText( string );
}


void CMyAppView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    if( nChar == VK_INSERT )
        m_Insert = !m_Insert;

    CRichEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}

Your problem may be the last line above... are you calling the base-class implementation of OnKeyDown even when the insert key is pressed?
Actually, you might want to do all this in your MainFrame if you are using an MDI...
0
 

Author Comment

by:VisualLR
ID: 1316035
Im having problems inplementing the code you've given me... first I get an error that says I can't access CRichEditView::OnKeyDown cause it's a protected memeber. And my other problem is how do I write the messages for these functions (the ON_COMMAND's)? I understand what OnUpdateIns does perfectly, Im not quite certain on what OnKeyDown does... or what parameters to use and how. Thanks.
0
 

Expert Comment

by:midthune
ID: 1316036
Try putting the code in your view class. Use the Class Wizard to create a handler for WM_KEYDOWN and put the code in the generated function. The code in OnKeyDown just turns your bool m_Insert from true to false or false to true. You'll have to write in your own message map entries for OnUpdateIns.
ON_UPDATE_COMMAND_UI(ID_INDICATOR_INS, OnUpdateIns) in view.cpp
afx_msg void OnUpdateIns(CCmdUI* pCmdUI); in view.h
This is assuming that your status bar has an indicator called ID_INDICATOR_INS.
Initialize the ID_INDICATOR_INS to "OVR" (because it's wider, if you set it to "INS" then "OVR" won't fit in the box) by setting it in your string table. Then, in your view constructor set m_Insert to TRUE.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 112
modThree challenge 4 103
MaxSpan challenge 9 123
Problem to event 3 112
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question