Disable Enter

This is a discussion on Disable Enter within the C++ Programming forums, part of the General Programming Boards category; I want to make a notepad type console application, and in order to format, you would need to not let ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    8

    Post Disable Enter

    I want to make a notepad type console application, and in order to format, you would need to not let Enter submit the string. Is there a way to disable enter and finnish editing the string after a different key press such as Alt+8?

    Thanks.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,581
    You will have to use the windows.h library.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Well, you can have a EOF designator and just parse the entered string for that designator. If it isn't there, then just accept more input and append it to the previous input.

    That way you don't have to use platform specific code. And unless you are on a really old computer, parsing even 20 lines should take... oh 0.0 secs

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8
    umm.... how do you do that

  5. #5
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Ummm... google.

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    You can also do it with conio.h, though it isn't standard. Take the character in unbuffered and print them out as they come in (as if they were coming in as buffered input)... when you take in an ENTER, just do nothing. When you take in an F8, process it as a flush command.

    Here is a little example program I wrote that shows how conio.h's getch function works with extended characters. It's old and I've posted it before but it might help you out. If you don't have conio.h (You can't compile the code), then just ignore this.
    Attached Files Attached Files
    Last edited by SlyMaelstrom; 09-29-2006 at 05:20 PM.
    Sent from my iPad®

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 11:06 AM
  2. Assignment output help
    By Taka in forum C Programming
    Replies: 13
    Last Post: 09-24-2006, 12:40 AM
  3. endless loop for scanf - plz help
    By owi_just in forum C Programming
    Replies: 18
    Last Post: 03-20-2005, 01:41 PM
  4. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  5. hi need help with credit limit program
    By vaio256 in forum C++ Programming
    Replies: 4
    Last Post: 04-01-2003, 12:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21