Have been going round in circles on this one for a couple of days.
How can I copy the contents of a window created with AddGdipGraphCtx to the clipboard?
I use this code to create it
HWND_GraphicHeader=pwindow.AddGdipGraphCtx (hWndForm,%IDC_Header,"",leftmargin,topHead,fullwidth,singleheight,%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ws_Border)
And GDIPlus to draw into it. This is all working fine.
I can save it to a file with this (not elegant, but easy to tidy up):
Local strFileName As wStringZ *256
Local EncoderClsid As Guid
Local pImage,hbitmap,hdcsource As Dword
EncoderClsid = Guid$(GdiPlusGetEncoderClsid("image/png"))
strFileName="d:\ggg.png"
hdcsource=GraphCtx_GetDc(HWND_GraphicHeader)
hBitmap = GetCurrentObject(hdcsource, %OBJ_BITMAP)
' Create a GDI+ type bitmap
GDIpCreateBitmapFromHBITMAP hBitmap, ByVal %Null, pImage
a& = GdipSaveImageToFile (pImage, strFileName , EncoderClsid, ByVal %Null)
But I cannot get it to the clipboard.
Some of the things I have tried shown below.
hBitmap=GraphCtx_GethBmp(HWND_GraphicHeader) 'this looks like the obvious way
AfxClearClipboard
AfxSetClipboardData( %CF_BITMAP, hBitmap)
Doesn't work
hdcsource=GraphCtx_GetDc(HWND_GraphicHeader)
hBitmap = GetCurrentObject(hdcsource, %OBJ_BITMAP)
AfxClearClipboard
AfxSetClipboardData( %CF_BITMAP ,hBitmap )
Doesn't work
hdcsource=GraphCtx_GetDc(HWND_GraphicHeader)
hBitmap = GetCurrentObject(hdcsource, %OBJ_BITMAP)
hcompatible=CreateCompatibleDC(%Null)
GDIpCreateBitmapFromHBITMAP hBitmap, ByVal %Null, pImage
hcompatiblebmp=CreateCompatibleBitmap(hcompatible,500,200)
SelectObject(hcompatiblebmp, pImage)
AfxClearClipboard
AfxSetClipboardData( %CF_BITMAP ,hcompatiblebmp)
Doesn't work
I'm probably missing the obvious, any suggestions welcome.
Thanks,
Ian.