HBITMAP CopyBitmap(HBITMAP hbitmap)
{
BITMAP bmInfo;
HDC hdc = ::GetDC(m_hWnd);
HDC hdcsrc = CreateCompatibleDC(hdc);
HDC hdcdst = CreateCompatibleDC(hdc);
::GetObject(hbitmap,sizeof(bmInfo),&bmInfo);
HBITMAP hbmret = CreateCompatibleBitmap(hdc, bmInfo.bmWidth, bmInfo.bmHeight);
HBITMAP hbmsrc = (HBITMAP)SelectObject(hdcsrc, hbitmap);
HBITMAP hbmdst = (HBITMAP)SelectObject(hdcdst, hbmret);
BitBlt(hdcdst,0,0,bmInfo.bmWidth,bmInfo.bmHeight,hdcsrc,0,0,SRCCOPY);
SelectObject(hdcdst, hbmdst);
SelectObject(hdcsrc, hbmsrc);
DeleteDC(hdcdst);
DeleteDC(hdcsrc);
ReleaseDC(m_hWnd,hdc);
return hbmret;
}