问题描述
CDC(SetPixel)函数无法在另一个类的成员函数中访问。
// OnPerformIBIT是我创建的成员函数
void CSplitterOne :: OnPerformIBIT()
{
The CDC (SetPixel) function cannot be accessible inside the member function of another class.
//OnPerformIBIT is a member function created by me
void CSplitterOne:: OnPerformIBIT()
{
CDC *myDC = GetDlgItem(IDC_PICBOX)->GetDC();
myDC->SetPixel(0, 0, RGB(0,0,0));
myDC->SetPixel(1, 1, RGB(0,0,0));
myDC->SetPixel(2, 2, RGB(0,0,0));
myDC->SetPixel(3, 3, RGB(0,0,0));
myDC->SetPixel(4, 4, RGB(0,0,0));
myDC->SetPixel(5, 5, RGB(0,0,0));
myDC->SetPixel(6, 6, RGB(0,0,0));
}
//在上面的函数中从MainFrm.cpp调用。在同一个函数中,我无法为CDC创建对象。它给出断言。我没有得到Window的句柄(hWnd)。
如果我在OnPaint()中做同样的事情就行了。请帮帮我。
// CSplitterOne是FormView类。
}
//In the above function is called from MainFrm.cpp. In the same function I cannot create the object for CDC. It give assertion. I am not get the Handle for Window (hWnd).
If I am do the same in thing in OnPaint() it works. Please Help me.
//CSplitterOne is FormView class.
推荐答案
这篇关于无法访问另一个类的成员函数内的CDC类成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!