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. Frustrated with conversion

Frustrated with conversion

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
8 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
    Stick
    wrote on last edited by
    #1

    Hi, I'm pulling my hair out trying to do something simple. Thanks to the complicated and cryptic function signatures of MS with all that _in _out stuff I can't figure out how to do the following: int pageNumber = 1; int numPages = 2; wstring wstr2Display; // I want to make this: L"1/2" wstr2Display = ToString(pageNumber) + L"/" + ToString(numPages); Seems I also can't directly 'add' the L"/". Can someone share with me how to do this? Thanks

    C R 2 Replies Last reply
    0
    • S Stick

      Hi, I'm pulling my hair out trying to do something simple. Thanks to the complicated and cryptic function signatures of MS with all that _in _out stuff I can't figure out how to do the following: int pageNumber = 1; int numPages = 2; wstring wstr2Display; // I want to make this: L"1/2" wstr2Display = ToString(pageNumber) + L"/" + ToString(numPages); Seems I also can't directly 'add' the L"/". Can someone share with me how to do this? Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      erm... I'm not sure where Microsoft comes into this ? Is this mananged C++, or is ToString your own function ? What is ToString returning ?

      Christian Graus - C++ MVP

      S 1 Reply Last reply
      0
      • C Christian Graus

        erm... I'm not sure where Microsoft comes into this ? Is this mananged C++, or is ToString your own function ? What is ToString returning ?

        Christian Graus - C++ MVP

        S Offline
        S Offline
        Stick
        wrote on last edited by
        #3

        MS only came into it because I can't read the cryptic help with all the extra stuff in the function signatures. ToString() is just a 'dummy' function to allow me to write the line to show what I'm trying to do. Actually, turns out what I really need is just to be able to concatenate and int + WCHAR + int into a WCHAR*. Then I can use that WCHAR* to call GdiPlus::Drawstring() So, in short, how do I convert an int to a WCHAR* representation?

        PJ ArendsP C 2 Replies Last reply
        0
        • S Stick

          MS only came into it because I can't read the cryptic help with all the extra stuff in the function signatures. ToString() is just a 'dummy' function to allow me to write the line to show what I'm trying to do. Actually, turns out what I really need is just to be able to concatenate and int + WCHAR + int into a WCHAR*. Then I can use that WCHAR* to call GdiPlus::Drawstring() So, in short, how do I convert an int to a WCHAR* representation?

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          itoa() and the like, printf() and the like, ostringstream::operator <<() and the like.


          You may be right
          I may be crazy
          -- Billy Joel --

          Within you lies the power for good, use it!!!

          Within you lies the power for good; Use it!

          1 Reply Last reply
          0
          • S Stick

            MS only came into it because I can't read the cryptic help with all the extra stuff in the function signatures. ToString() is just a 'dummy' function to allow me to write the line to show what I'm trying to do. Actually, turns out what I really need is just to be able to concatenate and int + WCHAR + int into a WCHAR*. Then I can use that WCHAR* to call GdiPlus::Drawstring() So, in short, how do I convert an int to a WCHAR* representation?

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Like PJ said, your core problem is that you can add a wchar * to a wstring, you can't add three wchar* to each other.  Your best bet IMO is an ostringstream, but itoa will do just fine ( well,itow if such a thing exists, or itot, perhaps ?)

            Christian Graus - C++ MVP

            1 Reply Last reply
            0
            • S Stick

              Hi, I'm pulling my hair out trying to do something simple. Thanks to the complicated and cryptic function signatures of MS with all that _in _out stuff I can't figure out how to do the following: int pageNumber = 1; int numPages = 2; wstring wstr2Display; // I want to make this: L"1/2" wstr2Display = ToString(pageNumber) + L"/" + ToString(numPages); Seems I also can't directly 'add' the L"/". Can someone share with me how to do this? Thanks

              R Offline
              R Offline
              Raj Prathap
              wrote on last edited by
              #6

              wstr2Display = ToString(pageNumber) + wstrin(L"/") + ToString(numPages); try this!! -- Reddy

              C S 2 Replies Last reply
              0
              • R Raj Prathap

                wstr2Display = ToString(pageNumber) + wstrin(L"/") + ToString(numPages); try this!! -- Reddy

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                That would work if you put a g on the end of wstring :-) And if ToString returns a wstring as well.

                Christian Graus - C++ MVP

                1 Reply Last reply
                0
                • R Raj Prathap

                  wstr2Display = ToString(pageNumber) + wstrin(L"/") + ToString(numPages); try this!! -- Reddy

                  S Offline
                  S Offline
                  Stick
                  wrote on last edited by
                  #8

                  Oy.... Ok, I've confused you guys. That ToString() function doesn't exist yet. This is what I'm trying to do: WCHAR text[] = L"3/4"; swprintf_s(text, 4, L"%c/%c", m_CurrentPage, m_NumPages); to change text to L"1/2".

                  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