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. Problems with data conversion

Problems with data conversion

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
3 Posts 2 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.
  • G Offline
    G Offline
    Gian
    wrote on last edited by
    #1

    Hi, i've a problem converting data from a format to another. the function VARIANT SaveToMemory(const VARIANT& Format, const VARIANT& CurSelection); returns a byte array (text data) casted like a VARIANT. I need to put this array in a CString variable. So I've used this: COleVariant varBuffer; COleVariant mode, cur; mode = (long)5; cur = (short)TRUE; varBuffer = m_txctrl.SaveToMemory(mode, cur); CString m_text = ((CByteArray &)(varBuffer.pbVal)).GetData(); But this will return an empty string. using CString m_text = (varBuffer.pbVal); return me a single byte. It's wrong my code?

    H 1 Reply Last reply
    0
    • G Gian

      Hi, i've a problem converting data from a format to another. the function VARIANT SaveToMemory(const VARIANT& Format, const VARIANT& CurSelection); returns a byte array (text data) casted like a VARIANT. I need to put this array in a CString variable. So I've used this: COleVariant varBuffer; COleVariant mode, cur; mode = (long)5; cur = (short)TRUE; varBuffer = m_txctrl.SaveToMemory(mode, cur); CString m_text = ((CByteArray &)(varBuffer.pbVal)).GetData(); But this will return an empty string. using CString m_text = (varBuffer.pbVal); return me a single byte. It's wrong my code?

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Gian wrote: returns a byte array (text data) casted like a VARIANT Where exactly is that byte array? It can't be pbVal because this one is about one single byte... (check MSDN) rechi

      G 1 Reply Last reply
      0
      • H Hans Ruck

        Gian wrote: returns a byte array (text data) casted like a VARIANT Where exactly is that byte array? It can't be pbVal because this one is about one single byte... (check MSDN) rechi

        G Offline
        G Offline
        Gian
        wrote on last edited by
        #3

        i've solved calculating the dimension of the OleVariant and using memcpy to copy data in a CByteArray. now works :)

        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