[英]Why does Windres report a syntax error on my GROUPBOX statement?
I'm experimenting with the Win32 API in C++, specifically with writing resource files. 我正在用C ++实验Win32 API,特别是编写资源文件。 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:
但是,当我将此模式对话框的代码添加到.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 exits with the following error: Windres退出时出现以下错误:
windres: resource.rc:40: syntax error
Line 40 refers to: 第40行指的是:
GROUPBOX "About this program...",IDC_STATIC,7,7,225,52
The GROUPBOX statement, which you can use only in a DIALOGEX statement, defines the text, identifier, dimensions, and attributes of a control window.
GROUPBOX语句只能在DIALOGEX语句中使用,它定义控件窗口的文本,标识符,维度和属性。
GROUPBOX text, id, x, y, width, height [, style [, extended-style]]
GROUPBOX文本,id,x,y,width,height [,style [,extended-style]]
Their example: 他们的例子:
GROUPBOX "Options", 101, 10, 10, 100, 100
What am I doing wrong? 我究竟做错了什么?
I think it is pretty much self-explanatory from 我认为这几乎是不言自明的
can use only in a DIALOGEX statement
只能在DIALOGEX语句中使用
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 that IDC_STATIC
is not defined. 如果在切换到
DIALOGEX
语句之后仍然在同一行上有相同的语法错误(如@YeenFei指出的那样),我唯一能想到的是IDC_STATIC
未定义。
Try changing it to 尝试将其更改为
GROUPBOX "About this program...",-1,7,7,225,52
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. 我搜索了Platform SDK标头(6.1和7.1)并没有找到它。 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.
我认为这可能是一个特定于MFC的标识符 - 一些快速的Google搜索建议MFC在“afxres.h”中定义它,如果它尚未定义。
IDOK
and IDCANCEL
work even though you didn't explicitly define them because they are defined in the Platform SDK (in "winuser.h"). IDOK
和IDCANCEL
即使没有明确定义它们也可以工作,因为它们是在Platform SDK中定义的(在“winuser.h”中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.