Thread: Underlining a word in DOS?

  1. #1
    Registered User renurv's Avatar
    Join Date
    May 2005
    Posts
    8

    Thumbs up Underlining a word in DOS?

    Is this possible? Thanks in advance!

  2. #2
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Why would you want to?

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Out of curiosity, why did you feel the need to ask why?

    When you say "in DOS", you probably mean "in a console application". It's not really DOS, it's just a DOS-like environment simulated by Windows. Linux has a console environment too. Adrianxw wrote a really good tutorial on console programming, and if this is possible, it's more than likely covered there. Do a board search and see if you can find it - it's recommended quite often.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It's not possible to do in the same character cell unless you redefine the ASCII characters with new bitmaps. That would require an interrupt and since console doesn't support them - the answer is....you cannot do this in console. The best you can do is draw a line under the word on the next line and use double spacing so the next line does not overwrite it.

    The only way I know you might be able to get away with this in another screen mode is to go poking around in video memory. However text mode does not allow pixel writes, only cell writes so if the cell bitmap does not have an underline, you are SOL.
    Text mode is not written per pixel, it's written per cell so B800:0000 corresponds to the first letter, and B800:0002 corresponds to the first color ((background << 4)+foreground).

    Windows probably won't even give a pointer to the memory.
    Last edited by VirtualAce; 01-02-2006 at 09:37 PM.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    you are SOL.
    Seriously out of luck?

    Windows' console does not make use of the graphics card's text mode. It is, in fact, impossible to have areas of the screen in text mode and others in pixel mode. So even if you could obtain a pointer to the character buffer, modifying it wouldn't have any effect.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    the console window is just another window -- it has a HWND associated with it. So if you get the HWND you should be able to change its default font. If you learn how to change fonts in standard Windows you should be able to do that in a console window too.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Which may allow you to underline all the text - but surely not a selected word.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by CornedBee
    Which may allow you to underline all the text - but surely not a selected word.
    Of course you can. Just how do you think MS-Word or any other word processor does it (use more than one font). Do it in command window the same way. I haven't actually tried it, but I assume it will work.
    Last edited by Ancient Dragon; 01-02-2006 at 10:05 PM.

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Windows' console does not make use of the graphics card's text mode. It is, in fact, impossible to have areas of the screen in text mode and others in pixel mode.
    I thought that's what I said. Text mode is not graphics mode. The card doesn't even allow access to pixels, it has nothing to do with Windows.

    Text mode is not written per pixel, it's written per cell so B800:0000 corresponds to the first letter, and B800:0002 corresponds to the first color ((background << 4)+foreground).

    Windows probably won't even give a pointer to the memory.

  10. #10
    Registered User
    Join Date
    Jan 2006
    Posts
    4
    You can save the text in a file, and run a normal Windows program to open the file and display the text, or easier: convert it to a Windows program

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 06:44 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM