Outlook 2000 custom image on button (Copy + Paste problem)

  • Thread starter Thread starter yinjentam
  • Start date Start date
Y

yinjentam

Hi all,

Based on the following thread,

http://groups.google.com/groups?hl=...204171144.223f368%40posting.google.com&rnum=6

Ken Slovak gave us a very good example in Visual Basic how to save the
clipboard data and restore it later after the copy+paste button image.
However, I need a C++ example of how to do that, especially the
clipboard formats in C++ are different from those in the VB example.

This is what I have attempted thus far:

-----

// Check the number of different data formats currently on the
clipboard
if (::CountClipboardFormats() == 0)
return;

HWND hwnd = ::GetClipboardOwner();
// Something wrong when opening the clipboard
if (! ::OpenClipboard(hwnd))
return;

// Start enumerating the data formats currently available on the
clipboard.
UINT uFormat = ::EnumClipboardFormats(0);
LPTSTR lpFormatName;
TCHAR szFormatName[256];

while (uFormat)
{
if (::GetClipboardFormatName(uFormat, szFormatName,
sizeof(szFormatName)))
{
lpFormatName = szFormatName;
}

uFormat = ::EnumClipboardFormats(uFormat);
}

Unfortunately I don't really know how to go on from here. How do I
actually store the clipboard data and restore it later??
Thanks for all your help!!
Jenny
 
Do you have access to the MSDN library? If so just enter Clipboard as a
search term. There's tons of information there about the formats, adding
custom formats and so on. If you don't have local access to the MSDN library
then look it up online at www.msdn.microsoft.com
 
Thanks for your reply!

I did manage to find a C++ example (only snippets though and not as
thorough as yours :-) ) from another newsgroup and I managed to save
something on the clipboard so as to restore it later on. However, I'm
still not quite sure whether I did it correctly. My code is

Any help is truly appreciated!!
Jenny

p.s.

///////////

HWND hwnd = ::GetClipboardOwner();
if (! ::OpenClipboard(hwnd)) return;

UINT uFormat = ::EnumClipboardFormats(0);
int nFormats = 0;

while (uFormat) {
if (::IsClipboardFormatAvailable(uFormat)) {
// m_clipboardFormats is an array
m_clipboardFormats[nFormats] = uFormat;

HANDLE source = ::GetClipboardData(uFormat);
SIZE_T size = ::GlobalSize(source);
HGLOBAL destination = ::GlobalAlloc(GMEM_MOVEABLE, size);

if (destination != NULL) {
// Copy the source to destination
LPVOID data = ::GlobalLock(destination);
::CopyMemory(data, source, size);
::GlobalUnlock(destination);

// m_clipboardData is an array
m_clipboardData[nFormats] = destination;

}
else
m_clipboardData[nFormats] = NULL;

nFormats++;
}

uFormat = ::EnumClipboardFormats(uFormat);
}

::CloseClipboard();


....

// now restore the clipboard contents

int nFormats = m_clipboardFormats.GetSize();

HWND hwnd = ::GetClipboardOwner();
::OpenClipboard(hwnd);
::EmptyClipboard();

for (int i = 0; i < nFormats; i++)
{
::SetClipboardData(m_clipboardFormats, (HANDLE)
m_clipboardData);
}

::CloseClipboard();

///////////


Ken Slovak - said:
Do you have access to the MSDN library? If so just enter Clipboard as a
search term. There's tons of information there about the formats, adding
custom formats and so on. If you don't have local access to the MSDN library
then look it up online at www.msdn.microsoft.com




Hi all,

Based on the following thread,

http://groups.google.com/groups?hl=...204171144.223f368%40posting.google.com&rnum=6

Ken Slovak gave us a very good example in Visual Basic how to save the
clipboard data and restore it later after the copy+paste button image.
However, I need a C++ example of how to do that, especially the
clipboard formats in C++ are different from those in the VB example.

This is what I have attempted thus far:

-----

// Check the number of different data formats currently on the
clipboard
if (::CountClipboardFormats() == 0)
return;

HWND hwnd = ::GetClipboardOwner();
// Something wrong when opening the clipboard
if (! ::OpenClipboard(hwnd))
return;

// Start enumerating the data formats currently available on the
clipboard.
UINT uFormat = ::EnumClipboardFormats(0);
LPTSTR lpFormatName;
TCHAR szFormatName[256];

while (uFormat)
{
if (::GetClipboardFormatName(uFormat, szFormatName,
sizeof(szFormatName)))
{
lpFormatName = szFormatName;
}

uFormat = ::EnumClipboardFormats(uFormat);
}

Unfortunately I don't really know how to go on from here. How do I
actually store the clipboard data and restore it later??
Thanks for all your help!!
Jenny
 
Sorry, that I couldn't tell you. I don't do C++ coding. I'm sure there are
complete examples either in the MS KB or that can be found from googling
however.
 
Back
Top