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. how to copy the bitmap data to clipboard?

how to copy the bitmap data to clipboard?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomgraphicstutorial
6 Posts 3 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.
  • R Offline
    R Offline
    Rockone
    wrote on last edited by
    #1

    at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.

    S H 2 Replies Last reply
    0
    • R Rockone

      at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Check out the SetClipboardData function. To but a bitmap on the clipboard use CF_BITMAP, CF_DIB, CF_DIBV5 or CF_DIBV5 or to put a file use CF_HDROP.

      Steve

      R 1 Reply Last reply
      0
      • S Stephen Hewitt

        Check out the SetClipboardData function. To but a bitmap on the clipboard use CF_BITMAP, CF_DIB, CF_DIBV5 or CF_DIBV5 or to put a file use CF_HDROP.

        Steve

        R Offline
        R Offline
        Rockone
        wrote on last edited by
        #3

        Thank you. yes, i already try this function and COleDataSource::SetClipboard(). but they are not work. and below is my code. if ( OpenClipboard() ) { EmptyClipboard(); SetClipboardData(CF_BITMAP, m_hDrawingSurface); CloseClipboard(); } code using ole COleDataSource* pDataSource = new COleDataSource; TRY { // Create a shared file and associate a CArchive with it CSharedFile file; CArchive ar(&file,CArchive::store); BITMAPFILEHEADER bmfh; int nBitsOffset = sizeof(BITMAPFILEHEADER) + m_bmpInfoHeader.biSize; LONG lImageSize = m_bmpInfoHeader.biSizeImage; LONG lFileSize = nBitsOffset + lImageSize; bmfh.bfType = 'B'+('M'<<8); bmfh.bfOffBits = nBitsOffset; bmfh.bfSize = lFileSize; bmfh.bfReserved1 = bmfh.bfReserved2 = 0; //Write the bitmap file header ar.Write(&bmfh, sizeof(BITMAPFILEHEADER)); //And then the bitmap info header ar.Write(&m_bmpInfoHeader, sizeof(BITMAPINFOHEADER)); ar.Write(m_pDrawingSurfaceBits, lImageSize); ar.Close(); // specify HGLOBAL handle to text data pDataSource->CacheGlobalData(CF_DIB, file.Detach()); pDataSource->SetClipboard(); } CATCH_ALL(e) { delete pDataSource; THROW_LAST(); } END_CATCH_ALL

        1 Reply Last reply
        0
        • R Rockone

          at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.

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

          See here[^] and here[^] if they are helpfuls


          WhiteSky


          R 1 Reply Last reply
          0
          • H Hamid Taebi

            See here[^] and here[^] if they are helpfuls


            WhiteSky


            R Offline
            R Offline
            Rockone
            wrote on last edited by
            #5

            thank you very much, this one is work. http://www.codeproject.com/clipboard/clipnutshell.asp

            H 1 Reply Last reply
            0
            • R Rockone

              thank you very much, this one is work. http://www.codeproject.com/clipboard/clipnutshell.asp

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

              you're welcome I gald you find your answer;)


              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