Solved

Console type program

Posted on 2000-05-14
6
190 Views
Last Modified: 2013-12-03
How can I make a windows application that has a cursur where you enter text but once you press enter you can't go back and delete what you entered. Like what DOS does, but say in an edit control or on the client window area?
0
Comment
Question by:scooter1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2809250
You may derive your own class from CEdit and handle the OnChar function. If it is an Enter key, use CWnd::ModifyStyle to set the edit control style ES_READONLY.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2810061
MFC has an OnOK() function which will handle the ENTER-key.

So, what you might want to do here, is to (when the user has entered some data in the field), you update the data, if the CString is something else than _T("") then you do the following:

GetDlgItem(IDC_THENAMEOFTHEEDITBOX_EDIT)->EnableWindow(FALSE);

Just be sure to get rid of the CDialog::OnOK(); line which is the default of the OnOK Evenet handler.

Good luck,
CJ
0
 

Author Comment

by:scooter1
ID: 2812977
but after i press enter i still want the next line to be able to accept text. Like in DOS.
0
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!

 
LVL 22

Expert Comment

by:CJ_S
ID: 2813362
UHM...that's a good one.
What you might want to do then is by every enter key (OnOK()) to save the contents of that box, and in the onChange event you check whether the user tries to _delete_ the sentences before it, by checking the value of the box. If it does, just put it back in.

I don't really have some code for you out of the top of my head.

Good luck,
CJ
0
 

Author Comment

by:scooter1
ID: 2815786
Is there no way to make only specific lines read only, using edit box? ,using richedit ?
0
 
LVL 4

Accepted Solution

by:
saurabh_dasgupta earned 72 total points
ID: 2828767
I got some ideas !!

It will be better to utilise the services of 2 controls simulataneously to get the above effects.
Use a simple borderless edit control window and a simple list box control.

The idea is, fake an impression of a DOS like window, by dynamically positioning the edit control within the list control, such that every time the user writes some text in the edit control and presses enter,

1)the text from the edit control  gets added to the list control

2)the contents of the edit control are cleared

3)The edit control is moved by some distance downwards, this distance will be determined by the height of the font with which the list control will be displaying the text.

4)Whenever the user scrolls the list control, the edit control must be dynamically scrolled along with it.(as in  DOS)

You will have to derive from the CListBox and handle several messages like WM_HSCROLL , WM_VSCROLL .

In the edit control you can provide features like DOS keys, by handling the arrow keys. Special attention is to be given to the handling of the enter key press.

I do not have code that will demonstrate the above idea, but I think a little tinkering with the above should lead to success.

Good luck !
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

756 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