【发布时间】:2013-06-08 09:30:12
【问题描述】:
正如Creating a Window (Windows)所说的:
“恭喜,您已经创建了一个窗口!现在,窗口确实 不包含任何内容或与用户互动。”
但我无法调试提到的用于创建窗口的完整代码。这是 main.cpp 来源:
#include <windows.h>
// Register the window class.
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = { };
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
// Create the window.
HWND hwnd = CreateWindowEx(
0, // Optional window styles.
CLASS_NAME, // Window class
L"Learn to Program Windows", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
if (hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nCmdShow);
我正在使用 Visual Studio Express 2012 for Windows Desktop。从 New Project 开始,选择 Visual C++、Empty Project。我什至尝试了#include <iostream> 没有和using namespace std; 希望一点点.. 不幸的是,它并没有解决问题。
调试会出现很多错误。可疑代码之一是 "wc":
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
对不起,(我想,这很简单,)因为我才刚刚开始..
【问题讨论】:
标签: c++ windows visual-studio-2010 visual-studio debugging