CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    327

    help with CString

    I copied code which creates a masked edit control. To return the time in a string rather than a COleDateTime object, the author says to use

    CString string = m_editCtrl.GetTimeStr();

    When I then try the following code,

    CClientDC cDC(this);
    cDC.TextOut(10,10, string);

    my program crashes at TextOut statement. What am I doing wrong? How can I convert this CString into just a char string that I can then print?

    Any response any one can give me will be greatly appreciated.


  2. #2
    Join Date
    Apr 1999
    Location
    Albuquerque, New Mexico, USA
    Posts
    16

    Re: help with CString

    Not sure why your code isn't working. You may want to try using MessageBox(string) to take a look at the string before you use TextOut(). To convert a CString to a char string, I do the following:

    char buff[80];
    sprintf(buff,string);

    Hope this helps. Best of luck.

    - Mark Robison


  3. #3
    Guest

    Re: help with CString

    What is the nature of the crash? Do you get an error message?

    The m_editCtrl seems like something that would be on a dialog. CDC::TextOut()
    is something you would ordinarily use in a user draw window. Normally you
    would not be making a CClientDC using "this" from a dialog, but from the window
    you are actually going to draw in.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured