C++/VB - Clipboard internals
Asked By Colin Peters
28-Jan-10 03:20 PM
Hi,
Hopefully this is the right newsgroup.
Can someone recommend any documentation that explains what process is
responsible for administering the clipboard.
When I put a richedit control on a form and call paste, an extra thread
is created (marked "rpc"). This thread seems to disappear after a few
minutes, and I do not understand why.
Apologies if this all sounds a bit vague.
SetClipboardData
(1)
OneNote
(1)
Boyne
(1)
Sharedmemory
(1)
Configurable
(1)
Overlain
(1)
Richedit
(1)
IIRC
(1)
Jonathan de Boyne Pollard replied to Colin Peters
Possibly. Given that you use the singular "process", what that
documentation will tell you will not be what you are expecting. (-:
Colin Peters replied to Jonathan de Boyne Pollard
Well, what I was after was some kind of description about what happens
when you call the API to put something on or off the clipboard. I assume
there is some mechanism at play to ensure that when two processes try to
copy at the same time (because the amount of data is large) that they
are somehow coordinated. Its really this kind of detail I am after.
I am not even sure I am on the right newsgroup.
Pavel A. replied to Colin Peters
Some apps handle copy&paste in quite non trivial ways.
Example: copy from IE and paste into OneNote and notepad.
Notepad instantly pastes the plain text.
By contrast, onenote takes a *lot* of time to complete the paste, it
apparently talks to the browser.
--pa
Colin Peters replied to Pavel A.
Indeed, the procedure can be complex. But who holds on to the data in
between? You can copy from notepad, close notepad then start another app
and paste. So the clipboard contents are persisted system wide. This is
what I want to find out about.
Leo Davidson replied to Colin Peters
Apps that set the clipboard can either copy the data into shared
memory, so that it is owned by the system and the app is free to exit,
or they can just put a flag into the clipboard which effectively says
Apps which do the latter often have a user-configurable option to
populate the clipboard with the actual data on exit, or clear the
clipboard on exit. (Assuming it is still the same thing in the
clipboard, of course.)
The "call me back" method is obviously a lot more complex so it is
usually only done when providing that data takes significant time/
memory and it is likely that the only thing requesting the data, if
anyone at all, will be the same app that put it there (allowing it to
short-circuit most of that work).
m replied to Colin Peters
IIRC the interactions are complex and the semantics date back to the pre-NT
shared memory & cooperative multi-tasking environment and are overlain with
COM in many cases. For more details look at SetClipboardData in MSDN.
There are several system defied formats, but applications frequently
register other 'custom' formats using RegisterClipboadFormat.
Pavel A. replied to m
Another interesting example: Copy a large file from a VMware virtual
machine,
and paste it on the host (or v.v.). Obviously, it will not be copied via the
clipboard.
--pa

SetClipboardData fails, but GetLastError does not report any error C++ / VB Again not MFC. I have all works fine. Sometimes however sending the data to the clipboard fails. MSDN states for SetClipboardData: | If the function fails, the return value is NULL. | To get extended error information, call GetLastError. For large bitmaps SetClipboardData returns NULL, however GetLastError returns 0, which means NO ERROR. I wonder if this is trying again and informing the user about the reduction. But I have no idea why SetClipboardData fails without GetLastError reporting some kind of "out of memory" error. Code goes here: void BITMAPINFOHEADER)); memcpy(lpClipboardCopy, &bitmapInfo.bmiHeader, sizeof(BITMAPINFOHEADER)); memcpy(lpBitmapBitsOffset, pBitmapBits, bitmapInfo.bmiHeader.biSizeImage); EmptyClipboard(); if (SetClipboardData(CF_DIB, hClipboardCopy) ! = NULL) { bSuccess = TRUE; if (nReduceResCount > 0) { / / inform the user about lower resolution here return bSuccess; } VC MFC Discussions CreateCompatibleDC (1) ReleaseDC (1) DeleteDC (1) GetDC (1) Bytes (1) SetClipboardData (1) SelectObject (1) DeleteObject (1) Yes, the documentation lies. I have hit this problem before com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm keywords: SetClipboardData, fails, , but, GetLastError, does, not, report, any, error description: Again not MFC. I have window
know about it: struct BasePolicy { typedef int slaptype; typedef float whiptype; }; template<typename Pol1> struct Configurable : virtual BasePolicy, Pol1 { typename Configurable::whiptype whipkind; }; Say that the user modifies "whiptype" as follows struct DoubleWhipper : virtual BasePolicy { typedef double whiptype; }; / / ill-formed in C++11, well-formed in C++03 Configurable<DoubleWhipper> c; In C++03 "Configurable::whiptype" is a dependent type and looked up at instantiation time and will find DoubleWhipper::whiptype unambiguously using the dominance rule. But in C++11, "Configurable::whiptype" is a non- dependent type, but will be looked up twice to check consistency In the definition of Configurable, and when it is instantiated. The program will be ill-formed if both lookups are
Going Bananas C++ / VB Jonathan de Boyne Pollard Think again! - -- -- -- Original Message - -- -- -- - Subject: Re: Propblem with TerminateProcess Date: Fri, 05 Feb 2010 19:43:36 +0000 From: Jonathan de Boyne Pollard Organization: Wacks Wicks Works Newsgroups: microsoft.public.win32.programmer.kernel Someone did. M. "m chocolate-covered banana, too. - - HLS - - HLS Win32 Kernel Discussions TerminateProcess (1) Propblem (1) Bananas (1) Boyne (1) Wicks (1) Wacks (1) Chocolate (1) HLS (1) think. keywords: Going, Bananas description: Jonathan de Boyne Pollard Think again! - -- -- -- Original Message - -- -- -- - Subject: Re: Propblem with TerminateProcess Date: Fri, 05 Feb 2010
cut it for C++. I have tried artistic style (astyle) and IMHO it is not configurable enough and does not do enough. What do other people use? Has anyone tried the easy to apply. But could you please explain what you mean by "it is not configurable enough"? What exactly are you missing from the over 60 options it supports? - - Regards, Sven cut it for C++. I have tried artistic style (astyle) and IMHO it is not configurable enough and does not do
Clue about Usenet Date: Thu, 11 Feb 2010 17:07:19 +0000 From: Jonathan de Boyne Pollard Organization: Wacks Wicks Works Newsgroups: microsoft.public.win32.programmer.kernel Followup-To: news.newusers 1990s. - - HLS Win32 Kernel Discussions Allbery (1) Connor (1) Usefor (1) Banana (1) Wacks (1) Boyne (1) Wicks (1) Alan (1) http-equiv = "Content-Type"> software, in fact. But I do