【发布时间】:2015-06-08 18:55:35
【问题描述】:
我有一堂课:
include<afxwin.h>
include<Winuser.h>
include<Windows.h>
HWND hwndOwner;
class CChildView :public CDialog
{
DECLARE_DYNAMIC(CChildView)
public:
CChildView();
~CChildView();
afx_msg void OnPaint();
afx_msg void OnLevelProf();
afx_msg void OnLevelAmat();
afx_msg void OnLevelBeg();
afx_msg void OnStepC();
void new_game();
virtual BOOL InitInstance();
//void CloseWindow();
BOOL PreCreateWindow(CREATESTRUCT& cs);
int end_analyze();
void ii();
unsigned long calculate(int id, int x, int y);
afx_msg void OnNewGame();
//void Invalidate();
afx_msg void OnX1010();
afx_msg void OnX1919();
afx_msg void OnX3030();
afx_msg void OnX5050();
afx_msg void OnX100100();
//MessageBoxW();
void resize_window();
afx_msg void OnLButtonDown(UINT, CPoint xy);
//void GetWindowRect(RECT);
//int MessageBoxW();
void OnStepH();
void set_chеcked_menu(unsigned int old_id, unsigned int new_id);
DECLARE_MESSAGE_MAP()
};
我应该如何在我的应用程序中实现 InitInstance 方法而不是在 AfxWinMAin() 中捕获 NUllReferenceExeption?这就是我现在所拥有的:
CChildView obj;
BOOL CChildView::InitInstance()
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
obj.Create(L"dsa", nullptr);
return FALSE;
}
为此我做了一个oj
【问题讨论】:
-
旁注:INIT'COMMON'CONTROL'SEX(对不起)
-
可能是
INITCOMMONCONTROLSEX InitCtrls = {}(用零初始化,但它是一个蓝色的镜头) -
我对你想要做什么感到困惑。 InitInstance 是 CWinApp 的子方法,不是,CDialog.
-
@rrirower:
InitInstance是CWinThread 的成员。
标签: c++ visual-c++ mfc dialog