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. How to display series of numbers ?

How to display series of numbers ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
13 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.
  • S Offline
    S Offline
    Surivevoli
    wrote on last edited by
    #1

    :confused:I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut(); Please help me ! Thanks ! Lgx -- modified at 19:05 Friday 7th April, 2006

    RaviBeeR H T 3 Replies Last reply
    0
    • S Surivevoli

      :confused:I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut(); Please help me ! Thanks ! Lgx -- modified at 19:05 Friday 7th April, 2006

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      To display the series on the same line, simply construct the string and use TextOut() to display it, as in:

      CString strNumbers;
      for (int nNum=1; (nNum <= 50); nNum++) {
      CString strNum;
      strNum.Format ("%d ", nNum);
      strNumbers += strNum;
      }
      VERIFY (pDC->TextOut (10, 10, strNumbers));

      /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      S 1 Reply Last reply
      0
      • S Surivevoli

        :confused:I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut(); Please help me ! Thanks ! Lgx -- modified at 19:05 Friday 7th April, 2006

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        Hi Surivevoli, CString Str; int i=0; while(i<50) { Str.Format("%d",i); dc.SetBkMode(0); dc.TextOut(X,50,Str,Str.GetLength()); X+=20; i++; }

        S 1 Reply Last reply
        0
        • S Surivevoli

          :confused:I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut(); Please help me ! Thanks ! Lgx -- modified at 19:05 Friday 7th April, 2006

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Surivevoli wrote:

          I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut();Please help me !Thanks !

          use wsprintf to add number in string and you can easily display that using the TextOut, but IMHO you should use CDC::ExtTextOut for same!

          S 1 Reply Last reply
          0
          • H Hamid Taebi

            Hi Surivevoli, CString Str; int i=0; while(i<50) { Str.Format("%d",i); dc.SetBkMode(0); dc.TextOut(X,50,Str,Str.GetLength()); X+=20; i++; }

            S Offline
            S Offline
            Surivevoli
            wrote on last edited by
            #5

            Thank you ! dc.SetBkMode(0)is uderstanded as dc.SetBkMode(TRANSPARENT)??? if before i draw a rectangle filled Red color {i use CBrush ...}, i try release that command{dc.SetBkMode} and use TextOut() to draw number text on the rectangle, but i see nothing changed if i want display formated "01","02","03",... Can you help me ? Lgx -- modified at 6:34 Saturday 8th April, 2006

            H 2 Replies Last reply
            0
            • T ThatsAlok

              Surivevoli wrote:

              I want to display series of numbers from 1 to 50 (that handled by variable i) use CPaintDC.TextOut();Please help me !Thanks !

              use wsprintf to add number in string and you can easily display that using the TextOut, but IMHO you should use CDC::ExtTextOut for same!

              S Offline
              S Offline
              Surivevoli
              wrote on last edited by
              #6

              what's difference between TextOut() and ExtTextOut() ??? why should you ExtTextOut()??

              1 Reply Last reply
              0
              • RaviBeeR RaviBee

                To display the series on the same line, simply construct the string and use TextOut() to display it, as in:

                CString strNumbers;
                for (int nNum=1; (nNum <= 50); nNum++) {
                CString strNum;
                strNum.Format ("%d ", nNum);
                strNumbers += strNum;
                }
                VERIFY (pDC->TextOut (10, 10, strNumbers));

                /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                S Offline
                S Offline
                Surivevoli
                wrote on last edited by
                #7

                i don't understand final code : VERIFY (pDC->TextOut (10, 10, strNumbers); what's it mean ? Lgx

                T RaviBeeR 2 Replies Last reply
                0
                • S Surivevoli

                  Thank you ! dc.SetBkMode(0)is uderstanded as dc.SetBkMode(TRANSPARENT)??? if before i draw a rectangle filled Red color {i use CBrush ...}, i try release that command{dc.SetBkMode} and use TextOut() to draw number text on the rectangle, but i see nothing changed if i want display formated "01","02","03",... Can you help me ? Lgx -- modified at 6:34 Saturday 8th April, 2006

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  Surivevoli, CString Str; int i=0; while(i<50) { Str.Format("0%d",i); dc.SetBkMode(0); dc.TextOut(X,50,Str,Str.GetLength()); X+=32; i++; } -- modified at 7:13 Saturday 8th April, 2006

                  1 Reply Last reply
                  0
                  • S Surivevoli

                    i don't understand final code : VERIFY (pDC->TextOut (10, 10, strNumbers); what's it mean ? Lgx

                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #9

                    Surivevoli wrote:

                    VERIFY (pDC->TextOut (10, 10, strNumbers);

                    VERIFY means to verify that your statement is properly fired or not.. try you local copy of msdn for these keywords

                    1 Reply Last reply
                    0
                    • S Surivevoli

                      Thank you ! dc.SetBkMode(0)is uderstanded as dc.SetBkMode(TRANSPARENT)??? if before i draw a rectangle filled Red color {i use CBrush ...}, i try release that command{dc.SetBkMode} and use TextOut() to draw number text on the rectangle, but i see nothing changed if i want display formated "01","02","03",... Can you help me ? Lgx -- modified at 6:34 Saturday 8th April, 2006

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      //Now test this code then again test without SetBkMode CPaintDC dc(this); CString Str; int i=0; dc.FillRect(CRect(0,50,800,80),&CBrush(RGB(120,120,200))); while(i<50) { Str.Format("''0%d''",i); dc.SetBkMode(0); dc.SetTextColor(RGB(255,255,255));//White dc.TextOut(X,55,Str,Str.GetLength()); X+=40; i++; }

                      S 1 Reply Last reply
                      0
                      • S Surivevoli

                        i don't understand final code : VERIFY (pDC->TextOut (10, 10, strNumbers); what's it mean ? Lgx

                        RaviBeeR Offline
                        RaviBeeR Offline
                        RaviBee
                        wrote on last edited by
                        #11

                        See this[^] link for information on the VERIFY and ASSERT macros. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

                        1 Reply Last reply
                        0
                        • H Hamid Taebi

                          //Now test this code then again test without SetBkMode CPaintDC dc(this); CString Str; int i=0; dc.FillRect(CRect(0,50,800,80),&CBrush(RGB(120,120,200))); while(i<50) { Str.Format("''0%d''",i); dc.SetBkMode(0); dc.SetTextColor(RGB(255,255,255));//White dc.TextOut(X,55,Str,Str.GetLength()); X+=40; i++; }

                          S Offline
                          S Offline
                          Surivevoli
                          wrote on last edited by
                          #12

                          thank you very much ! what is the difference between CPaintDC and CClientDC ? for you, what class should i use ? for example : i want draw a bitmap at coordinate of mouse when it is pressed Left

                          H 1 Reply Last reply
                          0
                          • S Surivevoli

                            thank you very much ! what is the difference between CPaintDC and CClientDC ? for you, what class should i use ? for example : i want draw a bitmap at coordinate of mouse when it is pressed Left

                            H Offline
                            H Offline
                            Hamid Taebi
                            wrote on last edited by
                            #13

                            Hi Surivevoli, maybe it is some helpful to you for lbutton http://www.codeproject.com/bitmap/DeskShoot.asp[^] for difference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cpaintdc.asp[^] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cclientdc.asp[^]

                            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