为什么Windres在我的GROUPBOX语句上报告语法错误? [英] Why does Windres report a syntax error on my GROUPBOX statement?
问题描述
我正在使用C ++中的Win32 API进行实验,尤其是编写资源文件。现在,我的整个项目工作正好,菜单和标题和一切。但是,当我将一个模态对话框的代码添加到.rc文件时:
IDD_ABOUT对话框DISCARDABLE 0,0,239 ,66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CaptionMy About Box
FONT 8,MS Sans Serif
BEGIN
DEFPUSHBUTTON& OK,IDOK,174,18,50,14
PUSHBUTTON& Cancel,IDCANCEL,174,35,50,14
GROUPBOX关于此程序...,IDC_STATIC,7,7,225,52
CTEXT使用对话框\r\\\
\r\\\
by的Forger,IDC_STATIC,16,18,144,33
END
Windres退出时出现以下错误:
windres:resource.rc:40:syntax错误
第40行代表:
GROUPBOX关于此程序...,IDC_STATIC,7,7,225,52
根据 MSDN ,
GROUPBOX语句只能在DIALOGEX语句中使用,它定义控件窗口的文本,标识符,尺寸和属性。
GROUPBOX text,id,x,y,width,height [,style [,extended-style]]
他们的例子:
GROUPBOX选项,101,10,10,100 ,100
我做错了什么?
IDC_STATIC
未定义。 尝试将其更改为
GROUPBOX关于本程序..., - 1,7,7,225,52
如果这解决了问题,那是因为未定义标识符。
通过Platform SDK头(6.1和7.1)搜索,没有找到它。我认为这可能是一个MFC特定的标识符 - 一些快速谷歌表明MFC定义它在afxres.h如果它还没有定义。
IDOK
和IDCANCEL
工作,即使您没有明确定义它们,因为它们是在Platform SDK(在winuser h)。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?
解决方案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
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. 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").这篇关于为什么Windres在我的GROUPBOX语句上报告语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!