我遇到了一个奇怪的问题.我正在VC++ 2008中创建一个Win32应用程序,使得一个类可以封装大部分工作,以便在调用时轻松重复MessageBox.消息框`已创建(我认为),但除非我按下Alt键,否则不会显示!
究竟发生了什么:
我运行程序
按Enter键
主窗口失去焦点
当我点击主窗口时发出哔声,好像有一个模态MessageBox
要么按Escape ...要么获得焦点要么按Alt键,然后按下Alt键出现MessageBox(即菜单会掉落)!!!!!!
PS它工作正常,但突然发生了这种情况.我没有发现任何差异 - 我甚至做了一个新项目!
这应该是主程序:
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
MSG msg;
CWnd cMainWindow(TEXT("DentoMan"), TEXT("Bejkoman")); // pass The class name and window name to the constructor
cMainWindow.CreateDef(); //Create the Window
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
Run Code Online (Sandbox Code Playgroud)
虽然这是类文件
CWnd::CWnd() {
};
CWnd::CWnd(LPTSTR lpszClassName, LPTSTR lpszWindowName) {
CWnd::lpszClassName = lpszClassName;
CWnd::lpszWindowName = lpszWindowName;
};
CWnd::~CWnd() {
};
// Create the …Run Code Online (Sandbox Code Playgroud)