CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Posts
    12

    Question DrawText with integer value

    Hi,

    I am tring to draw text to the window to show the current year in a simulation.

    int iyear;

    Code:
    CRect crect(10,250,150,300);
    CString string = "Year : ";
    
    pDC->DrawText(string,crect, DT_LEFT);
    I would like to display the value of iyear after "Year: " either by adding it onto 'string' or by some other way.

    thanks.

  2. #2
    Join Date
    Oct 2002
    Location
    Italy
    Posts
    324

    Re: DrawText with integer value

    int iyear = 2005;
    CRect crect(10,250,150,300);
    CString string;
    string.Format("Year : %d", iyear);

    pDC->DrawText(string,crect, DT_LEFT);
    Regards,
    Marco Era
    www.marcoera.com

    Latest post on my blog: Back to the Amiga's times

  3. #3
    Join Date
    Mar 2005
    Posts
    12

    Re: DrawText with integer value

    nice and simple

    thanks for quick reply.

  4. #4
    Join Date
    Mar 2005
    Posts
    12

    Re: DrawText with integer value

    Hi,

    I have just tried it with a population value that rises and falls. The trouble is if the population is above 100 so 3 figures. If it then falls bellow 100 down to 2 figure the 3rd figure is still displayed.

    so if value is 101 then drops to 91 it is displaying 911.

    Is there a way around this problem?

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