FIX: Clipboard Assistant - Paste Fails or Causes Hard Break (148687)
The information in this article applies to:
- Microsoft Visual C++ 4.0
- Microsoft Visual C++ 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
This article was previously published under Q148687 SYMPTOMS
Code generated by the Clipboard Assistant for a Custom Clipboard
Format may cause the following problems: - Copying to the clipboard fails to replace what was previously placed on
the clipboard.
- An access violation occurs with a message similar to the following:
Exception: access violation (0xc0000005),
Address: 0x5f82cf37
- An unexpected memory overwrite occurs after several clipboard
operations.
- On the Checked build of Windows NT, a Cut, Copy, or Paste operation
causes a hard-coded breakpoint to be encountered and a trace message
similar to the following to be generated:
BASE: GlobalFree called with a locked object.
CAUSE
The first three problems can occur because of the OnEditPaste function
generated by the Clipboard Assistant. The code is not correct because it
frees the HGLOBAL that it retrieves from the clipboard when doing a paste
operation. This memory should not be freed because the Clipboard will free
it when necessary. The code also fails to call CloseClipboard for all
possible calls to OpenClipboard.
The fourth problem is caused by a separate bug in the CSharedFile::Detach()
function. For more details on this problem, please see the following
article in the Microsoft Knowledge Base:
148455 CSharedFile::Detach() Does Not Call GlobalUnlock() RESOLUTION
The sample code in this article shows new versions of the OnEditCopy,
OnEditCut, and OnEditPaste functions. You should use this code to replace
the versions previously generated by the Clipboard Assistant.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem has been fixed in Visual C++
version 5.0.
Modification Type: | Major | Last Reviewed: | 12/2/2003 |
---|
Keywords: | kbbug kbcode kbfix kbide kbProgramming KB148687 |
---|
|