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. copy to clipboard

copy to clipboard

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

    my application consists of a treecontrol in which i have displayed system files and folders in a tree control similar to the left hand side of Windows Explorer. i am able to copy the folder from the treecontrol and paste it on the explorer where ever we need.Also copy and paste operations are occuring with in the tree control.Now i have added unicode support to my application.The copy to clipboard function is failing.when i copy the folder from explorer i am able to paste it in the treecontrol.But when i tried viceversa i am getting an error message like "the file name you specified is not valid or too long.specify a different file name".how can i make the folder copy from the treecontrol.The code i used is , CDropFiles DropFiles; if(!PrepareFileBuff(DropFiles)) { return; } if (OpenClipboard()) { BeginWaitCursor(); ::EmptyClipboard(); HGLOBAL hMem = ::GlobalAlloc(GMEM_ZEROINIT|GMEM_MOVEABLE|GMEM_DDESHARE, DropFiles.GetBuffSize()); memcpy( (LPTSTR)::GlobalLock(hMem), DropFiles.GetBuffer() ,DropFiles.GetBuffSize() ); ::SetClipboardData (CF_HDROP, hMem ); ::CloseClipboard(); EndWaitCursor(); }

    R 1 Reply Last reply
    0
    • R radhika28

      my application consists of a treecontrol in which i have displayed system files and folders in a tree control similar to the left hand side of Windows Explorer. i am able to copy the folder from the treecontrol and paste it on the explorer where ever we need.Also copy and paste operations are occuring with in the tree control.Now i have added unicode support to my application.The copy to clipboard function is failing.when i copy the folder from explorer i am able to paste it in the treecontrol.But when i tried viceversa i am getting an error message like "the file name you specified is not valid or too long.specify a different file name".how can i make the folder copy from the treecontrol.The code i used is , CDropFiles DropFiles; if(!PrepareFileBuff(DropFiles)) { return; } if (OpenClipboard()) { BeginWaitCursor(); ::EmptyClipboard(); HGLOBAL hMem = ::GlobalAlloc(GMEM_ZEROINIT|GMEM_MOVEABLE|GMEM_DDESHARE, DropFiles.GetBuffSize()); memcpy( (LPTSTR)::GlobalLock(hMem), DropFiles.GetBuffer() ,DropFiles.GetBuffSize() ); ::SetClipboardData (CF_HDROP, hMem ); ::CloseClipboard(); EndWaitCursor(); }

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      radhika28 wrote:

      memcpy( (LPTSTR)::GlobalLock(hMem), DropFiles.GetBuffer() ,DropFiles.GetBuffSize() );

      Try using wmemcpy instead.


      Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

      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