错误 C2665,无法在 System::Windows::Forms::TextRenderer::DrawText 的 2 个重载之间解析

发布于 2024-12-02 03:55:57 字数 827 浏览 2 评论 0原文

Windows::Forms::TextRenderer::DrawText(gT, numTo100, sfo, 矩形(2, 2, 12, 12), SystemColors::ControlText);

给出了错误

1>错误 C2665:'System::Windows::Forms::TextRenderer::DrawText':8 个重载中没有一个可以转换所有参数类型

1>可以是 'void System::Windows::Forms::TextRenderer::DrawText(System::Drawing::IDeviceContext ^,System::String ^,System::Drawing::Font ^,System::Drawing::Point,系统::绘图::颜色)'

1> 或 'void System::Windows::Forms::TextRenderer::DrawText(System::Drawing::IDeviceContext ^,System::String ^,System::Drawing::Font ^,System::Drawing ::矩形,系统::绘图::颜色)'

如果我丢失了该行,我不会收到任何错误。我已经用 Point 尝试过其他方式,并且在我的其他项目中运行良好。任何想法将不胜感激,谢谢。

编辑 以下是相关的前几行,FWIW..

    System::Drawing::Font sfo(FontFamily::GenericSansSerif, 8.0F, FontStyle::Bold);

Windows::Forms::TextRenderer::DrawText(gT, numTo100, sfo, Rectangle(2, 2, 12, 12), SystemColors::ControlText);

is giving the error

1>error C2665: 'System::Windows::Forms::TextRenderer::DrawText' : none of the 8 overloads could convert all the argument types

1> could be 'void System::Windows::Forms::TextRenderer::DrawText(System::Drawing::IDeviceContext ^,System::String ^,System::Drawing::Font ^,System::Drawing::Point,System::Drawing::Color)'

1>or 'void System::Windows::Forms::TextRenderer::DrawText(System::Drawing::IDeviceContext ^,System::String ^,System::Drawing::Font ^,System::Drawing::Rectangle,System::Drawing::Color)'

If I lose the line I get no errors. I've tried it the other way with Point and it was working fine in my other project. Any ideas would be appreciated, thanks.

EDIT
Here are the pertinent preceeding lines, FWIW..

    System::Drawing::Font sfo(FontFamily::GenericSansSerif, 8.0F, FontStyle::Bold);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

爱你是孤单的心事 2024-12-09 03:55:57

您已经使用堆栈语义创建了 Font 对象,因此为了将其传递给需要跟踪句柄 (Font^) 的函数,您需要使用一元 operator%,就像使用一元 operator& 从 C++ 中的对象值获取对象指针一样:

Windows::Forms::TextRenderer::DrawText(
    gT,
    numTo100,
    %sfo,
    Rectangle(2, 2, 12, 12),
    SystemColors::ControlText
);

You've created your Font object using stack semantics, so in order to pass it to a function wanting a tracking handle (Font^), you need to use unary operator%, much as you would use unary operator& to get an object pointer from an object value in C++:

Windows::Forms::TextRenderer::DrawText(
    gT,
    numTo100,
    %sfo,
    Rectangle(2, 2, 12, 12),
    SystemColors::ControlText
);
深海里的那抹蓝 2024-12-09 03:55:57

您确定 Rectangle 类参数是好的吗?

Windows::Forms::TextRenderer::DrawText(gT, numTo100, sfo, System::Drawing::Rectangle(2, 2, 12, 12), SystemColors::ControlText); 

当某些参数被隐式转换但可以通过多种方式找到目标类型时,通常会发生这种情况。

Are you sure the Rectangle class parameter is the good one ?

Windows::Forms::TextRenderer::DrawText(gT, numTo100, sfo, System::Drawing::Rectangle(2, 2, 12, 12), SystemColors::ControlText); 

This usually happens when some arguments are implicitly cast but many ways are the target type are found.

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