-wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
-{
- switch (dataFormat)
- {
- case wxDF_BITMAP:
- {
- BITMAP bm;
- HBITMAP hBitmap = (HBITMAP) GetClipboardData(CF_BITMAP);
- if (!hBitmap)
- return NULL;
-
- HDC hdcMem = CreateCompatibleDC(NULL);
- HDC hdcSrc = CreateCompatibleDC(NULL);
-
- HBITMAP old = (HBITMAP) ::SelectObject(hdcSrc, hBitmap);
- GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
-
- HBITMAP hNewBitmap = CreateBitmapIndirect(&bm);
-
- if (!hNewBitmap)
- {
- SelectObject(hdcSrc, old);
- DeleteDC(hdcMem);
- DeleteDC(hdcSrc);
- return NULL;
- }
-
- HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hNewBitmap);
- BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight,
- hdcSrc, 0, 0, SRCCOPY);
-
- // Select new bitmap out of memory DC
- SelectObject(hdcMem, old1);
-
- // Clean up
- SelectObject(hdcSrc, old);
- DeleteDC(hdcSrc);
- DeleteDC(hdcMem);
-
- // Create and return a new wxBitmap
- wxBitmap *wxBM = new wxBitmap;
- wxBM->SetHBITMAP((WXHBITMAP) hNewBitmap);
- wxBM->SetWidth(bm.bmWidth);
- wxBM->SetHeight(bm.bmHeight);
- wxBM->SetDepth(bm.bmPlanes);
- wxBM->SetOk(TRUE);
- return (wxObject *)wxBM;
- break;
- }
- case wxDF_METAFILE:
- case CF_SYLK:
- case CF_DIF:
- case CF_TIFF:
- case CF_PALETTE:
- case wxDF_DIB:
- {
- return FALSE;
- break;
- }
- case wxDF_OEMTEXT:
- dataFormat = wxDF_TEXT;
- case wxDF_TEXT:
- default:
- {
- HANDLE hGlobalMemory = GetClipboardData(dataFormat);
- if (!hGlobalMemory)
- return NULL;