b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

cformview_cformview窗口创建_base class undefined

电脑杂谈  发布时间:2017-02-17 16:51:23  来源:网络整理
cformviewcformview

本代码可以在CFormView中,根据事先画好的控件位置创建CScrollView

也可以在CDialog中创建CScrollView、CFormView等

注:

若以下代码放在CMainRightView::OnCreate(LPCREATESTRUCT lpCreateStruct)内,则GetDlgItem()函数将调用失败,因为此时控件都还未被创建!

voidCMainRightView::OnInitialUpdate()

...{

CFormView::OnInitialUpdate();

//TODO:Addyourspecializedcodehereand/orcallthebaseclass

//获得目标位置控件

UINTTargetCtrlID=IDC_STATIC_SCROLLVIEW;

CWnd*pWnd=this->GetDlgItem(TargetCtrlID);

CRectRectTargetCtrl;

pWnd->GetWindowRect(RectTargetCtrl);

pWnd->DestroyWindow();

this->ScreenToClient(RectTargetCtrl);

//在目标位置动态创建CScrollView

CEMapView*pEMapView=(CEMapView*)RUNTIME_CLASS(CEMapView)->CreateObject();

pEMapView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW,RectTargetCtrl,this,TargetCtrlID);

//使用CreateView创建的视图不能自动调用OnInitialUpdate函数,需要人工调用OnInitialUpdate函数或者发送WM_INITIALUPDATE消息

pEMapView->OnInitialUpdate();

//SetScrollSizes()必须被调用,否则运行时会出ASSERT错误,当然,也可以在目标View内的OnInitialUpdate()中调用

pEMapView->SetScrollSizes(MM_TEXT,CSize(RectTargetCtrl.Width()-10,RectTargetCtrl.Height()-10));

//使用CreateView创建的视图不会自动显示并且激活,需要人工操作

pEMapView->ShowWindow(SW_SHOW);

}

注:如果需要在CDialog中创建CScrollView、CFormView,则需要overload、override这些View中以下的4个方法,否则会出ASSERT错误

intCFormViewPrint::OnMouseActivate(CWnd*pDesktopWnd,UINTnHitTest,UINTmessage)

{

//TODO:Addyourmessagehandlercodehereand/orcalldefault

returnCWnd::OnMouseActivate(pDesktopWnd,nHitTest,message);

}

voidCFormViewPrint::OnDestroy()

{

CWnd::OnDestroy();

//TODO:Addyourmessagehandlercodehere

}

voidCFormViewPrint::PostNcDestroy()

{

//TODO:Addyourspecializedcodehereand/orcallthebaseclass

CWnd::PostNcDestroy();

}

voidCFormViewPrint::OnActivateFrame(UINTnState,CFrameWnd*pDeactivateFrame)

{

//TODO:Addyourspecializedcodehereand/orcallthebaseclass

CWnd::OnActivateFrame(nState,pDeactivateFrame);

}

原因可参考

View和Control的区别(如何在对话框上使用CView类)

%20C++/205707715.html


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-32966-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...