1

我有一个 CView,我一直在上面画东西就好了。然后我意识到我需要在我的 CView 中添加一些控件,如文本框和组合框。所以我试图将我的 CView 转换为没有默认构造函数的 CFormView。但是我需要此行的默认构造函数,IMPLEMENT_DYNCREATE(CMyView, CFormView)所以我创建了一个像这样的默认构造函数CMyView::CMyView():CFormView( ( UINT )666 ) { ... }。那 666 是因为我不知道我应该在那里传递哪个参数。我猜我需要传递我的 CMyView 类的 ID。我找不到最初由 Visual Studio 项目向导自动创建的 CMyView 类的 ID。我应该在哪里寻找它?当我运行程序时,我收到此错误:First-chance exception at 0x75AEC41F in myapp.exe: Microsoft C++ exception: CInvalidArgException at memory location 0x003CF134. Critical error detected c0000374 myapp.exe has triggered a breakpoint. 它停在 free.c 的第 51 行所以我的问题是:我该如何解决这个问题?我还想保留我以前在以前的 CView 中绘制的东西,现在是 CFormView。CFormView 是否能够像 CView 一样进行绘制?如果没有,我是否应该在我的 CMainFrame 中使用拆分窗格并拥有一个 CView 和一个 CFormView?我可能使用了特定于 Java swing 的术语,对此我深表歉意。我是 MFC 和 C++ 的新手。提前谢谢你,科尼留

4

2 回答 2

1

The CFormView constructor needs the ID of the form's dialog template to be passed in. That is the template you create in the visual editor. You can see how this works by creating a little test project with a CFormView to make your declarations look like the MFC declarations in the test project.

The CFormView can be painted like a CView (in OnDraw), but you might have undesired effects on the controls if you do any scaling or scrolling of the view.

Other alternatives for mixing controls with painted output are (1) Using CControlBar to put controls on the edge of the view or (2) Put a CStatic on the CFormView and do your painting in the CStatic.

于 2013-11-11T02:02:39.490 回答
0

退房Resources.rc

您可以尝试添加如下内容:

IDD_DIALOG1 DIALOG  0, 0, 400, 400
STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif"
BEGIN
END
于 2016-04-07T13:24:20.710 回答