Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Console type program

Posted on 2000-05-14
6
Medium Priority
?
204 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…

705 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