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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetWindowText Error

SetWindowText Error

Scheduled Pinned Locked Moved C / C++ / MFC
help
16 Posts 5 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.
  • C Cedric Moonen

    The function SetWindowText expect a char array, not a long. So use sprintf to convert this value into a char array:

    char szBuff[50];
    sprintf(szBuff,"%l",n);
    status->m_TOTAL_WORDS.SetWindowText(szBuff);


    Cédric Moonen Software developer
    Charting control

    V Offline
    V Offline
    VinayCool
    wrote on last edited by
    #4

    Hi Cedric Moonen, Thanks for the reply, I used the code as u have said error has gone, but the value is nt displayed in the dialog, what will be the cause ?? I used F5 and checked the n value its getting the the value correctly 72986 but its nt displaying. IDC_TOTAL_WORDS with member of type CEdit m_TOTAL_WORDS

    1 Reply Last reply
    0
    • H Hamid Taebi

      TCHAR buffer[50]; long a=20; _ltoa(a,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);_**


      **_

      whitesky


      V Offline
      V Offline
      VinayCool
      wrote on last edited by
      #5

      Hi WhiteSky, Thanks a lot its working ......:) TCHAR buffer[50]; long n=INDX.total_words; _ltoa(n,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);

      1 Reply Last reply
      0
      • H Hamid Taebi

        TCHAR buffer[50]; long a=20; _ltoa(a,buffer,10); status->m_TOTAL_WORDS.SetWindowText(buffer);_**


        **_

        whitesky


        V Offline
        V Offline
        VinayCool
        wrote on last edited by
        #6

        Hi WhiteSky, Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1);

        H E 2 Replies Last reply
        0
        • V VinayCool

          Hi WhiteSky, Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1);

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

          very simple _ltoa(f,buffer,10); to itoa(f,buffer,10);_**


          **_

          whitesky


          V 1 Reply Last reply
          0
          • V VinayCool

            Hi WhiteSky, Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1);

            E Offline
            E Offline
            Eytukan
            wrote on last edited by
            #8

            vinaycool wrote:

            Can u please also tell me how to change it int to char ??

            _ltoa


            --[V]--

            [My Current Status]

            H L 2 Replies Last reply
            0
            • E Eytukan

              vinaycool wrote:

              Can u please also tell me how to change it int to char ??

              _ltoa


              --[V]--

              [My Current Status]

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

              Hi VuNic _ltoa or itoa_**


              **_

              whitesky


              E 1 Reply Last reply
              0
              • E Eytukan

                vinaycool wrote:

                Can u please also tell me how to change it int to char ??

                _ltoa


                --[V]--

                [My Current Status]

                L Offline
                L Offline
                Laxman Auti
                wrote on last edited by
                #10

                _ltoa - Convert a long integer to a string. _itoa - Convert an integer to a string Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

                E 1 Reply Last reply
                0
                • H Hamid Taebi

                  very simple _ltoa(f,buffer,10); to itoa(f,buffer,10);_**


                  **_

                  whitesky


                  V Offline
                  V Offline
                  VinayCool
                  wrote on last edited by
                  #11

                  Yes its working thanks a lot.

                  1 Reply Last reply
                  0
                  • H Hamid Taebi

                    Hi VuNic _ltoa or itoa_**


                    **_

                    whitesky


                    E Offline
                    E Offline
                    Eytukan
                    wrote on last edited by
                    #12

                    Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1); Oops, I misunderstood his question. I thought he was asking about the line that does the conversion.


                    --[V]--

                    [My Current Status]

                    H 1 Reply Last reply
                    0
                    • L Laxman Auti

                      _ltoa - Convert a long integer to a string. _itoa - Convert an integer to a string Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

                      E Offline
                      E Offline
                      Eytukan
                      wrote on last edited by
                      #13

                      pleast look at my reply to whitesky. And Btw, you can still use ltoa for converting ints to chars. int is not something totally different from long. but Only the size ;)


                      --[V]--

                      [My Current Status]

                      L 1 Reply Last reply
                      0
                      • E Eytukan

                        pleast look at my reply to whitesky. And Btw, you can still use ltoa for converting ints to chars. int is not something totally different from long. but Only the size ;)


                        --[V]--

                        [My Current Status]

                        L Offline
                        L Offline
                        Laxman Auti
                        wrote on last edited by
                        #14

                        Due to the differences in size of long and int C++ provides the seperate functions :) Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

                        E 1 Reply Last reply
                        0
                        • L Laxman Auti

                          Due to the differences in size of long and int C++ provides the seperate functions :) Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

                          E Offline
                          E Offline
                          Eytukan
                          wrote on last edited by
                          #15

                          ;P :-D


                          --[V]--

                          [My Current Status]

                          1 Reply Last reply
                          0
                          • E Eytukan

                            Can u please also tell me how to change it int to char ?? TCHAR buffer1[50]; int f=INDX.getTotalFiles(); _ltoa(f,buffer,10); status->m_TOTAL_FILES.SetWindowText(buffer1); Oops, I misunderstood his question. I thought he was asking about the line that does the conversion.


                            --[V]--

                            [My Current Status]

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

                            yes:)_**


                            **_

                            whitesky


                            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