DevCPP / VS windows 应用程序标头问题(菜鸟)
我正在两个 IDE 上完成 theForger 的 win32 教程:Dev C++ 和 Visual Studio 2008。我尝试在这两个 IDE 中复制结果。
对于教程的 this 页,我似乎无法在 Dev C++ 中编译(Visual工作室工作正常)。这是一个模式对话框。有问题的代码位于 WndProc
中:
case ID_HELP_ABOUT:
int ret = DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_ABOUT),hwnd,AboutDlgProc); //ERROR OCCURS HERE in Dev C++
if(ret==IDOK) { MessageBox(NULL,"Dialog exited with OK","Notice",0); }
else { MessageBox(NULL,"Dialog exited with EXIT","Notice",0); }
break;
它抛出的错误是:
Simple3\main.c In function `WndProc':
Simple3\main.c syntax error before "int"
Simple3\main.c `ret' undeclared (first use in this function)
如果我在此之前定义 int ret;
,它会编译,但会打开一个命令窗口与常规应用程序。
我假设我缺少一个标题。我使用的标头是 windows.h
和 afxres.h
。有人可以帮我吗?提前致谢。
PS - 这是一个非常简单的问题 - 在尖括号或引号中声明标题有什么区别?例如
或 "windows.h"
?
I'm working through theForger's win32 tutorial, on two IDEs: Dev C++ and Visual Studio 2008. I try to duplicate results in both.
For this page of the tutorial, I can't seem to compile in Dev C++ (Visual Studio works fine). It's a modal dialog box. The code in question is in WndProc
:
case ID_HELP_ABOUT:
int ret = DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_ABOUT),hwnd,AboutDlgProc); //ERROR OCCURS HERE in Dev C++
if(ret==IDOK) { MessageBox(NULL,"Dialog exited with OK","Notice",0); }
else { MessageBox(NULL,"Dialog exited with EXIT","Notice",0); }
break;
The error(s) it throws are:
Simple3\main.c In function `WndProc':
Simple3\main.c syntax error before "int"
Simple3\main.c `ret' undeclared (first use in this function)
If I define int ret;
before this point, it compiles, but a command window opens along with the regular app.
I assume I'm missing a header. The headers I'm using are windows.h
and afxres.h
. Could anyone help me out? Thanks in advance.
PS - real easy question while I'm at it - what's the difference between declaring headers in angle brackets or quotes? E.g. <windows.h>
or "windows.h"
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一些编译器希望在 Case 语句和 break 之间添加大括号。尝试使用它。
我想应该是这样的。
除了关于<>和“”用于声明标头,尖括号表示将在 IDE 提到的默认包含目录中搜索该文件。而当您希望在本地项目文件夹以及包含文件夹中搜索文件时,请使用“”。
Some compilers expect curly braces to be added between Case statement and break. Try using it.
I think it should work that way.
Besides regarding <> and "" for declaring headers, angular brackets indicate that the file will be searched in the default include directories mentioned with IDE. Whereas the "" are used when you want the file to be searched in the local project folder as well along with the include folder.