Solved

OleUIPasteSpecial - list box is empty

Posted on 2003-11-30
4
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 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