Solved

OleUIPasteSpecial - list box is empty

Posted on 2003-11-30
4
336 Views
Last Modified: 2013-12-03
From my reading of the documentation, thecode snippet below should display a Paste Special dialog,
and if some text is currently pasted on the clipboard then "Unformatted Text" should appear
in the list of options to select from. But the list is empty! Can anyone please tell me
what I'm overlooking.

A mini Visual Studio project is available for download - http://www.deskmates.com/dl/TestPasteSpecial1.zip

Cheers Greg

void PasteSpecial(HWND hWnd)
{
  OLEUIPASTEENTRY vPasteEntry[1];
  vPasteEntry[0].fmtetc.cfFormat = CF_TEXT;
  vPasteEntry[0].fmtetc.dwAspect = DVASPECT_CONTENT;
  vPasteEntry[0].fmtetc.lindex = -1;
  vPasteEntry[0].fmtetc.tymed = TYMED_HGLOBAL;
  vPasteEntry[0].lpstrFormatName = "Unformatted Text";
  vPasteEntry[0].lpstrResultText = "text without any formatting";
  vPasteEntry[0].dwFlags = OLEUIPASTE_PASTEONLY;
 
  unsigned int vLinkTypes[1];
 
  OLEUIPASTESPECIAL o;
  ZeroMemory(&o,sizeof(o));
  o.cbStruct = sizeof(OLEUIPASTESPECIAL);
  o.dwFlags = PSF_STAYONCLIPBOARDCHANGE;
  o.hWndOwner = hWnd;
  o.arrPasteEntries = vPasteEntry;
  o.cPasteEntries = 1;
  o.arrLinkTypes = vLinkTypes;
  o.lpfnHook = MyHook;
  ::OleUIPasteSpecial(&o);
  }



0
Comment
Question by:GGRUNDY
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9850497
What is the return value of 'OleUIPasteSpecial()'? There are more than 10(!) error codes that this API might return. Why not make life easier and check them?
0
 
LVL 3

Author Comment

by:GGRUNDY
ID: 9853158
This was a cut down example to demonstrate the problem.
The dialog returns OLEUI_CANCEL meaning the cancel button was pressed,
which one would expect given that the OK button is greyed out because
are no options to select from in the list box.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9865099
I think you need to read the COlePasteSpecialDialog MFC class source code to see why your code is not working. This dialog is working properly in MFC OCLIENT sample, you can run it under debugger and see all API calls MFC does to show this dialog.
Another way is reading the Patron sample from Inside OLE book - according to MSDN documentation it contains such dialog called using API.
It looks like these two samples are the only available sources about OleUIPasteSpecial.
0
 
LVL 3

Author Comment

by:GGRUNDY
ID: 9871999
 vPasteEntry[0].fmtetc.ptd=NULL;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now