Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Drawing an Integer !!

Drawing an Integer !!

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinformsquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex H 1983
    wrote on last edited by
    #1

    hi to draw a String with GDI+ : graphics.DrawString(L"Hello", -1, &font, PointF(600,100), &solidBrush); how can i change an integer to WCHAR in parameter 1. for exmple i want to draw figures from 1 to 100. thanx

    R E 2 Replies Last reply
    0
    • A Alex H 1983

      hi to draw a String with GDI+ : graphics.DrawString(L"Hello", -1, &font, PointF(600,100), &solidBrush); how can i change an integer to WCHAR in parameter 1. for exmple i want to draw figures from 1 to 100. thanx

      R Offline
      R Offline
      roel_
      wrote on last edited by
      #2

      char tmp[4]; for(int i = 1 ; i < 100 ; i++) { sprintf(tmp, "%s", i); graphics.DrawString(tmp, -1, &font, PointF(600,100), &solidBrush); } You can also use eg std::string and boost::lexical_cast, but this is the simplest form I guess HTH

      T 1 Reply Last reply
      0
      • A Alex H 1983

        hi to draw a String with GDI+ : graphics.DrawString(L"Hello", -1, &font, PointF(600,100), &solidBrush); how can i change an integer to WCHAR in parameter 1. for exmple i want to draw figures from 1 to 100. thanx

        E Offline
        E Offline
        eXplodus
        wrote on last edited by
        #3

        looks like that u wanna use unicode CString blub; for (int i=0;i<100;i++) { blub.Format(L"%i",i); graphics.DrawString(blub, -1, &font, PointF(600,100), &solidBrush); } ...

        1 Reply Last reply
        0
        • R roel_

          char tmp[4]; for(int i = 1 ; i < 100 ; i++) { sprintf(tmp, "%s", i); graphics.DrawString(tmp, -1, &font, PointF(600,100), &solidBrush); } You can also use eg std::string and boost::lexical_cast, but this is the simplest form I guess HTH

          T Offline
          T Offline
          Ted Ferenc
          wrote on last edited by
          #4

          roel_v wrote: sprintf(tmp, "%s", i); You obviously meant:- sprintf(tmp, "%d", i);

          R 1 Reply Last reply
          0
          • T Ted Ferenc

            roel_v wrote: sprintf(tmp, "%s", i); You obviously meant:- sprintf(tmp, "%d", i);

            R Offline
            R Offline
            roel_
            wrote on last edited by
            #5

            Yes I did - shame on me :wtf:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups