Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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



0
GGRUNDY
Asked:
GGRUNDY
  • 2
1 Solution
 
jkrCommented:
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
 
GGRUNDYAuthor Commented:
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
 
AlexFMCommented:
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
 
GGRUNDYAuthor Commented:
 vPasteEntry[0].fmtetc.ptd=NULL;
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now