المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ::EmptyClipboard gives an error 1418 - Thread does not have a clipboard open.



C++ Programming
11-21-2009, 05:21 AM
I have made a Word Add-in. I use the clipboard to put an icon in my Add-in button. The code is:

HBITMAP hFace =(HBITMAP)::LoadImage(g_hInst,
MAKEINTRESOURCE(IDB_OPEN_PDF),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS);

// put bitmap into Clipboard
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, (HANDLE)hFace);
::CloseClipboard();
::DeleteObject(hFace);
// set style before setting bitmap

spButton->PutStyle(Office2000::msoButtonIconAndCaption);
spButton->PasteFace();

return S_OK;

OpenClipboard opens the clipboard successfully as it returns 1 every time. The problem is that EmptyClipboard returns 0 every time. It seems that there is a problem with the clipboard. EmptyClipboard gives an error 1418 - Thread does not have a clipboard open. That is strange because I've just opened the clipboard successfully.
Has anyone run into such problem?