Hello everyone,
I work with vs2013 + OpenGL.
The program is a MFC dialog project. In the main dialog, a custom control and a copy button are laid. When this program is executed, a graph is drawn with OpenGL in the custom control. When the copy button is clicked, the graph is copied into the clipbord in bmp format.
In the past, my computer was 32-bit with the OS of win7, and this program can run successfully. However, when the same program runs on the new computer with 64-bit and win10, the function of copy cannot work.
Following is the main code, in which CGraphCtrl and CUsingGlut32Dlg are the classes corresponding to the custom control and main dialog respectively.
void CGraphCtrl::OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
dc.SelectStockObject(NULL_BRUSH);
dc.Rectangle(&rc);
dc.MoveTo(0, 0);
dc.LineTo(rc.right, rc.bottom);
dc.MoveTo(rc.right, 0);
dc.LineTo(0, rc.bottom);
if (!wglMakeCurrent(m_hDC, m_hRC))
{
CString msg= _T("wglMakeCurrent err");
AfxMessageBox(msg);
}
DrawGraph(); SwapBuffers(m_hDC);
wglMakeCurrent(m_hDC, NULL);
}
void CGraphCtrl::CopyBmpToClipBoard(HBITMAP hBitmap)
{
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP, hBitmap);
CloseClipboard();
}
void CUsingGlut32Dlg::OnBnClickedButtonCopy()
{
HBITMAP hBitmap = m_GraphCtrl.GetBmpHandle();
m_GraphCtrl.CopyBmpToClipBoard(hBitmap);
}
The HGLRC of OpenGL is created with PFD_DOUBLEBUFFER, which means the OpenGL graph is drawn with double buffers.
When this program run on the 32-bit computer with win7, the OpenGL graph can be copied successfully, but will fail on the 64-bit computer with win10.
What I have tried:
the OpenGL graph can be copied sussfully on 32-bit computer with OS of win7