Link to home
Start Free TrialLog in
Avatar of GGRUNDY
GGRUNDY

asked on

OleUIPasteSpecial - list box is empty

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);
  }



Avatar of jkr
jkr
Flag of Germany image

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?
Avatar of GGRUNDY
GGRUNDY

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GGRUNDY

ASKER

 vPasteEntry[0].fmtetc.ptd=NULL;