Solved

Status Bar Problem with OVR

Posted on 1998-06-04
3
306 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now