How to display an image with CSplitterWnd

  • Thread starter Thread starter linganmm
  • Start date Start date
L

linganmm

Guest
Hi, I have a project with split window CSplitterWnd.

The Client area is splitted into 2x2 sub areas:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
if (!m_wndSplitter.CreateStatic(this, 2, 2))
return false;
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CmyView1), CSize(300, 300), pContext);
m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CmyView2), CSize(300, 300), pContext);
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CmyView3), CSize(300, 100), pContext);
m_wndSplitter.CreateView(1, 1, RUNTIME_CLASS(CmyView4), CSize(300, 100), pContext);

return true;
}

I need to display an image in one of them, for example, the first one, and CmyView1 is subclass of CView, in which I call SetDIBitsToDevice to show the image:

void CmyView1::OnDraw(CDC* pDC)
{

SetDIBitsToDevice(pDC->GetSafeHdc(), dwidth, 0, dwidth,
dheight, 0, 0, 0, dheight, imagedata, bmi,
DIB_RGB_COLORS);
}

However, nothing is displayed although Invalidate and UpdateWindow from CMainFrame are called.

Same codes work in another project without CSplitterWnd.

And the following codes can draw a circle so I think pDC is ok:

void CmyView2::OnDraw(CDC* pDC)
{

CPen pen(PS_SOLID, 1, RGB(0, 0, 255));
CPen* pOldPen = pDC->SelectObject(&pen);
pDC->Ellipse(100, 100, 300, 300);
}

But why SetDIBitsToDevice does not work?

May it be related to CSplitterWnd? How to display an image with CSplitterWnd?

Thanks in advance!

Continue reading...
 
Back
Top