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. Data Type conversion.

Data Type conversion.

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • V VCSharp007

    Can u tell a method to convert unsigned short* to CString ?? Thanx in advance. Rgds Sunil

    M Offline
    M Offline
    Mad__
    wrote on last edited by
    #2

    That depend on what data type pointed by unsigned short*, etc. string, wide char string number ..., and what string representation you want. ;)

    V 1 Reply Last reply
    0
    • M Mad__

      That depend on what data type pointed by unsigned short*, etc. string, wide char string number ..., and what string representation you want. ;)

      V Offline
      V Offline
      VCSharp007
      wrote on last edited by
      #3

      Can u explain??

      M 1 Reply Last reply
      0
      • V VCSharp007

        Can u explain??

        M Offline
        M Offline
        Mad__
        wrote on last edited by
        #4

        You asking "how convert pointer to string", or "how convert data ref by pointer to string" ? And if data, you mast say what kind of data ;) (unsigned short * pointer may point to Unicode string, WORD value, 16bpp raster data ;) ....)

        V 1 Reply Last reply
        0
        • V VCSharp007

          Can u tell a method to convert unsigned short* to CString ?? Thanx in advance. Rgds Sunil

          P Offline
          P Offline
          Phil J Pearson
          wrote on last edited by
          #5

          If the unsigned short * is really a BSTR or a _bstr_t then just do CString(usp). The CString constructor is overloaded to accept BSTRs


          The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).

          1 Reply Last reply
          0
          • M Mad__

            You asking "how convert pointer to string", or "how convert data ref by pointer to string" ? And if data, you mast say what kind of data ;) (unsigned short * pointer may point to Unicode string, WORD value, 16bpp raster data ;) ....)

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

            It is pointer to a Ascci string. I have to display it in a message box. So I have to convert it to CString.

            M D 2 Replies Last reply
            0
            • V VCSharp007

              It is pointer to a Ascci string. I have to display it in a message box. So I have to convert it to CString.

              M Offline
              M Offline
              Mad__
              wrote on last edited by
              #7

              simple (if there ASCII coded string ;) ) CString((char *)data)

              V 1 Reply Last reply
              0
              • M Mad__

                simple (if there ASCII coded string ;) ) CString((char *)data)

                V Offline
                V Offline
                VCSharp007
                wrote on last edited by
                #8

                I got only the first letter???

                M 1 Reply Last reply
                0
                • V VCSharp007

                  I got only the first letter???

                  M Offline
                  M Offline
                  Mad__
                  wrote on last edited by
                  #9

                  That meens, that you have not ASCII data stored by pointer. You mast know, what coding used (Unicode, MBS, BSTR, wide char), and corectly convert pointer to CString constructor.

                  V 1 Reply Last reply
                  0
                  • M Mad__

                    That meens, that you have not ASCII data stored by pointer. You mast know, what coding used (Unicode, MBS, BSTR, wide char), and corectly convert pointer to CString constructor.

                    V Offline
                    V Offline
                    VCSharp007
                    wrote on last edited by
                    #10

                    Sorry I mistook . It is pointed to BSTR.

                    M 1 Reply Last reply
                    0
                    • V VCSharp007

                      Sorry I mistook . It is pointed to BSTR.

                      M Offline
                      M Offline
                      Mad__
                      wrote on last edited by
                      #11

                      CString((BSTR)data)

                      V 1 Reply Last reply
                      0
                      • V VCSharp007

                        It is pointer to a Ascci string. I have to display it in a message box. So I have to convert it to CString.

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #12

                        Neither MessageBox() nor AfxMessageBox() requires a CString object. You might consider showing us a relevant code snippet and we could probably offer a solution.


                        "Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow

                        1 Reply Last reply
                        0
                        • M Mad__

                          CString((BSTR)data)

                          V Offline
                          V Offline
                          VCSharp007
                          wrote on last edited by
                          #13

                          It works!!!!!!! Thanx a lot..

                          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