Displaying Text using TextOut() ...

This is a discussion on Displaying Text using TextOut() ... within the Windows Programming forums, part of the Platform Specific Boards category; 1. I'm displaying text on the frame using the function textout .... Code: TextOut(hDC, rc.left, rc.top, txt, (int)_tcslen(txt)); The text ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Displaying Text using TextOut() ...

    1. I'm displaying text on the frame using the function textout ....
    Code:
    TextOut(hDC, rc.left, rc.top, txt, (int)_tcslen(txt));
    The text is boxed in a rectangle with white background.. How do i display text without this rectangle?

    2. Question on reading text/number from Edit Control..

    ... How do i read in text or numerical data from an edit box? what functions do i use.. A code snippet would help!

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    GetDlgItemInt

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    1. I'm displaying text on the frame using the function textout ....
    Code:
    TextOut(hDC, rc.left, rc.top, txt, (int)_tcslen(txt));
    The text is boxed in a rectangle with white background.. How do i display text without this rectangle?
    You need to use a drawing mode that doesn't draw new background - perhaps the NULL-brush that I told you about before will help [sorry, I don't KNOW as I haven't actually written code that draws text on a non-white background].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Anddos View Post
    GetDlgItemInt
    What if it's a float, or long... Anywayz, thnx

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    What if it's a float, or long... Anywayz, thnx
    Seeing as long and int are the same size (in 32- and 64-bit versions of Windows, and I doubt you are interested in backwards compatibility with Windows 3.1 as that would probably cripple your application quite a bit), long is not really a problem.

    Floating point (float or double) and 64-bit integers, you'd have to get the text out and then use a standard function (such as strtod() or sscanf()) to get the conversion done.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    you'd have to get the text out
    not sure what you mean? you mean read in text! Sure! will try that, thanx

    --
    Mats[/QUOTE]

    you'd have to get the text out

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by matsp View Post
    You need to use a drawing mode that doesn't draw new background - perhaps the NULL-brush that I told you about before will help [sorry, I don't KNOW as I haven't actually written code that draws text on a non-white background].

    --
    Mats
    Here's my solution..

    Code:
    COLORREF g_rgbBackground = RGB(0xD3,0xD3,0xD3); // Set to grey
    SetBkColor(hDC, g_rgbBackground);

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by csonx_p View Post
    Here's my solution..

    Code:
    COLORREF g_rgbBackground = RGB(0xD3,0xD3,0xD3); // Set to grey
    SetBkColor(hDC, g_rgbBackground);
    Yes, that would work for a solid background. It's a bit more trouble if the background is (for example) an image of unknown colour [e.g. a photo of my family] that we'd draw the text over.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    WM_GETTEXT and then put it in to a buffer with sprintf , wsprintf....

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by Anddos View Post
    WM_GETTEXT and then put it in to a buffer with sprintf , wsprintf....
    What function do you recommend Anddos for getting the text before i convert using sprintf()?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying Text and Variables to a window
    By StevejLuke in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2002, 02:36 PM
  2. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM
  3. Problems displaying content of a text file
    By melissa in forum C++ Programming
    Replies: 5
    Last Post: 11-12-2001, 06:13 PM
  4. displaying text with DirectX
    By MechanicX in forum Game Programming
    Replies: 4
    Last Post: 09-24-2001, 07:28 PM

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