为什么 Windres 会报告我的 GROUPBOX 语句的语法错误?

发布于 2024-10-14 12:25:45 字数 1093 浏览 2 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

还如梦归 2024-10-21 12:25:45

如果切换到 DIALOGEX 语句后同一行仍然存在相同的语法错误(正如@YeenFei 指出的那样),我唯一能想到的是 IDC_STATIC没有定义。

尝试将其更改为

GROUPBOX "About this program...",-1,7,7,225,52

如果这解决了问题,那是因为标识符未定义。

我搜索了 Platform SDK 标头(6.1 和 7.1),但没有找到。我认为这可能是 MFC 特定的标识符——一些快速谷歌搜索建议 MFC 在“afxres.h”中定义它(如果尚未定义)。

即使您没有显式定义 IDOKIDCANCEL,它们也能正常工作,因为它们是在 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 that IDC_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 and IDCANCEL work even though you didn't explicitly define them because they are defined in the Platform SDK (in "winuser.h").

夏尔 2024-10-21 12:25:45

我认为这几乎是不言自明的

只能在DIALOGEX中使用
声明

I think it is pretty much self-explanatory from

can use only in a DIALOGEX
statement

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文