Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copying a DC's content onto clipboard in OWL win 32

Posted on 1997-06-28
7
Medium Priority
?
386 Views
Last Modified: 2013-12-26
In OWL 5.0 the TDC class has some win32 features like BeginPath, EndPath, FillPath etc. There also is a TMetaFileDC class which can be used to paint on. The normal DC functions are properly put on it. I can then use the TMetaFilePict class to simply copy it to the clipboard as a windows metafile. But the win32 features are ignored (which is mentioned in the manuals also). They don't mention how to
get it to the clipboard properly though.

Thanks in Advance,

Wout de Zeeuw
0
Comment
Question by:zeeuw
[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
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:md041797
ID: 1299315
Try this:

Make a TMetaFileDC fdc and fill it.  Then open the clipboard, call SetClipboardData (CF_DSPENHMETAFILE, fdc.CloseEnh()); and close it.


0
 

Author Comment

by:zeeuw
ID: 1299316
I tried the following, which didn't work:

TMetaFileDC            dc;
TClipboard            Clipboard(*this);

      Paint(dc, true, TRect());
   Clipboard.OpenClipboard(*this);
      if (!Clipboard.SetClipboardData(CF_DSPENHMETAFILE, dc.Close()))
            MessageBox("Error", "Message", MB_OK);
   Clipboard.CloseClipboard();

The SetClipboardData function returns false, and also dc.IsEnhanced() returns false. I find this DC stuff very complicated, perhaps someone can give me a working example of how to copy to a clipboard when having the Paint function available and using win32 features.

Thanks in advance,

Wout de Zeeuw
0
 
LVL 4

Expert Comment

by:md041797
ID: 1299317
Use dc.CloseEnh, not dc.Close.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:zeeuw
ID: 1299318
Thanks for the quick reply, I tried using the CloseEnh() member function too, but it didn't work:

TMetaFileDC            dc;
TClipboard            Clipboard(*this);

      if (!dc.IsEnhanced())
         MessageBox("dc is not enhanced", "Message", MB_OK);
      Paint(dc, true, TRect());
   Clipboard.OpenClipboard(*this);
      if (!Clipboard.SetClipboardData(CF_DSPENHMETAFILE, dc.CloseEnh()))
            MessageBox("Error", "Message", MB_OK);
   Clipboard.CloseClipboard();

When executing I see that the dc is not enhanced. There is some constructor TMetaFileDC which takes another dc as an argument which would result in a win32 Metafile, but I don't know how that would work. Perhaps you see the error in my code?

Thanks for looking at it,

Wout de Zeeuw
0
 

Author Comment

by:zeeuw
ID: 1299319
Just an addition on my last note. I don't get any errors when I run this piece of code, the SetClipboardData doesn't return false or anything, but nothing appears on the clipboard. I also tried

TClientDC            cdc(*this);
TMetaFileDC            dc(cdc);
TClipboard            Clipboard(*this);

In which the dc is enhanced, but this didn't copy anything to the clipboard either. So I suspect I'm doing something stupid with the constructing of the dc's.

Wout de Zeeuw

0
 

Author Comment

by:zeeuw
ID: 1299320
Hello again,

Almost solved... the copying works now, except that the colors don't get copied properly:

TMetaFileDC            dc(CreateEnhMetaFile(0, 0, 0, "App Title\0Title\0\0"));
TClipboard            Clipboard(*this);

      if (!dc.IsEnhanced())
         MessageBox("dc is not enhanced", "Message", MB_OK);
      Paint(dc, true, TRect());
   Clipboard.EmptyClipboard();
      if (!Clipboard.SetClipboardData(CF_ENHMETAFILE, dc.CloseEnh()))
            MessageBox("Error copying to clipboard", "Message", MB_OK);

So just another define for the enhanced metafile thing. Thanks for the CloseEnh() tip, I'd still like to give you half the points for it :-)

Wout

0
 
LVL 4

Accepted Solution

by:
md041797 earned 100 total points
ID: 1299321
I don't have a clue why the colors don't work, but here's an answer if you want to give me points.

Thanks.


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

722 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