Solved

OleUIPasteSpecial - list box is empty

Posted on 2003-11-30
4
335 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

705 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

17 Experts available now in Live!

Get 1:1 Help Now