(1) 基于对话框,添加custom control。
(2) 选择custom control,右键Class Wizard为控件添加控件类。
(3) 选择base class(CDialog或CWnd),定义类名,如COpenGLControl。
(4) 注册自定义控件窗口类,并在构造函数中调用注册函数。
(5) 添加控件变量并绑定控件窗口。如:
CKWOpenGL1Dlg
.h文件中:COpenGLControl m_opengl;
CKWOpenGL1Dlg.cpp
的DoDataExchange
中:DDX_Control(pDX,IDC_CUSTOM1,m_ opengl);
(6) 确定Class名,如:#define MYWNDCLASS "MyDrawPad",并修改Custom control属性的class。
(7) 不要忘记#include " COpenGLControl.h"。