[RESOLVED] error on a code
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Thread: [RESOLVED] error on a code

Threaded View

  1. #16
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,328

    Re: error on a code

    Will set EmptyText to all spaces for the required length. As EmptyText is to use with TextOut you don't need a terminating NULL as you specify with TextOut the number of chars to display.
    Code:
    size_t tlen = p->Text.length();
    char *EmptyText = new char[tlen];
    memset(EmptyText, ' ', tlen);
    However, this is not your problem. The problem you have is that you are writing onto a DC and therefore using the font selected into that DC. On the Console this DC font is NOT the font that the console uses to display console characters (change ' ' in your code to '@' and see what happens!). So if you persist in using gui functions for the console window then you have a whole lot of more work to do. Use the console supplied functions. They are far easier to use.

    The other problem you have is that you assume that each subsequent use of TextOut clears from the screen that which was there before. It doesn't. It writes on top of what was there. So outputing a space over a letter does nothing. Because you haven't selected a correct font to use you only think that TextOut is working properly and the problem is with your EmptyText string. The real problem is with trying to use gui TextOut in the same way as you would output to a console. It doesn't work that way I'm afraid. Once you have your font selected, try outputting a string of A with O as the space character.
    Last edited by 2kaud; October 31st, 2013 at 06:18 PM.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center