【发布时间】:2016-07-01 08:12:48
【问题描述】:
代码如下:
#include <windows.h>
#include <windowsx.h>
// the WindowProc callback function prototype
LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
// win32 entry point
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
///*
// window handler
HWND hwnd;
// struct for window information
WNDCLASSEX wc;
// clear out the window class for use
ZeroMemory(&wc, sizeof(WNDCLASSEX));
// setting wc struct with window values/properties
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = "TestWindow";
wc.lpfnWndProc = WindowProc;
// register window before creation/use
RegisterClassEx(&wc);
// creating the window class
hwnd = CreateWindowEx(NULL, "TestWindow", "First Win32 Program", WS_OVERLAPPEDWINDOW, 100, 100, 1000, 1000, NULL, NULL, hInstance, NULL);
// show the window
ShowWindow(hwnd, nCmdShow);//*/
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){
return 0;
}
这是编译器/调试/运行时控制台输出:
'wintest.exe' (Win32): Loaded
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'wintest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
The program '[3484] wintest.exe' has exited with code 0 (0x0).
这是一个非常基本的简单程序,它所做的只是假设从左上角开始弹出一个大小为 1000x1000 的 win32 窗口。
【问题讨论】:
-
...在尝试显示窗口后,您立即退出。 See here for how to loop.
-
您不应将字符集的默认设置从 Unicode 更改为 MBCS。如果您不使用 Unicode,那么您将不必要地浪费资源来实现功能有限的应用程序。
-
任何您发现的创建窗口的示例程序都将包含一个消息循环。您是如何设法忽略这一点的?
-
找不到或打开 PDB 文件 Visual Studio 找不到调试信息。看到这个link你的代码还有其他问题——下面提到——但这不是这个错误。
标签: c++ winapi visual-studio-2013 window