Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Console type program

Posted on 2000-05-14
6
Medium Priority
?
210 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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 216 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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…
Suggested Courses

783 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