为什么 Windres 会报告我的 GROUPBOX 语句的语法错误?
我正在尝试使用 C++ 中的 Win32 API,特别是编写资源文件。现在,我的整个项目运行得很好,菜单、标题等等。但是,当我将此模式对话框的代码添加到 .rc 文件时:
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "&OK",IDOK,174,18,50,14
PUSHBUTTON "&Cancel",IDCANCEL,174,35,50,14
GROUPBOX "About this program...",IDC_STATIC,7,7,225,52
CTEXT "An example program showing how to use Dialog Boxes\r\n\r\nby theForger", IDC_STATIC,16,18,144,33
END
Windres 退出并出现以下错误:
windres: resource.rc:40: syntax error
第 40 行引用:
GROUPBOX "About this program...",IDC_STATIC,7,7,225,52
根据 MSDN,
GROUPBOX 语句只能在 DIALOGEX 语句中使用,它定义控制窗口的文本、标识符、尺寸和属性。
GROUPBOX文本,id,x,y,宽度,高度[,样式[,扩展样式]]
他们的例子:
GROUPBOX "Options", 101, 10, 10, 100, 100
我做错了什么?
I'm experimenting with the Win32 API in C++, specifically with writing resource files. Now, my entire project was working just fine, menus and titles and everything. However, when I add this code for a modal dialog box to the .rc file:
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "&OK",IDOK,174,18,50,14
PUSHBUTTON "&Cancel",IDCANCEL,174,35,50,14
GROUPBOX "About this program...",IDC_STATIC,7,7,225,52
CTEXT "An example program showing how to use Dialog Boxes\r\n\r\nby theForger", IDC_STATIC,16,18,144,33
END
Windres exits with the following error:
windres: resource.rc:40: syntax error
Line 40 refers to:
GROUPBOX "About this program...",IDC_STATIC,7,7,225,52
According to MSDN,
The GROUPBOX statement, which you can use only in a DIALOGEX statement, defines the text, identifier, dimensions, and attributes of a control window.
GROUPBOX text, id, x, y, width, height [, style [, extended-style]]
Their example:
GROUPBOX "Options", 101, 10, 10, 100, 100
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果切换到 DIALOGEX 语句后同一行仍然存在相同的语法错误(正如@YeenFei 指出的那样),我唯一能想到的是 IDC_STATIC没有定义。
尝试将其更改为
如果这解决了问题,那是因为标识符未定义。
我搜索了 Platform SDK 标头(6.1 和 7.1),但没有找到。我认为这可能是 MFC 特定的标识符——一些快速谷歌搜索建议 MFC 在“afxres.h”中定义它(如果尚未定义)。
即使您没有显式定义
IDOK
和IDCANCEL
,它们也能正常工作,因为它们是在 Platform SDK 中定义的(在“winuser.h”中)。If you still have the same syntax error on the same line after switching to a
DIALOGEX
statement (as @YeenFei pointed out), the only thing I can think of is thatIDC_STATIC
is not defined.Try changing it to
If that fixes the problem, it's because the identifier isn't defined.
I did a search through the Platform SDK headers (6.1 and 7.1) and didn't find it. I think that might be an MFC-specific identifier -- some quick Googling suggests MFC defines it in "afxres.h" if it isn't already defined.
IDOK
andIDCANCEL
work even though you didn't explicitly define them because they are defined in the Platform SDK (in "winuser.h").我认为这几乎是不言自明的
I think it is pretty much self-explanatory from