错误 C2665,无法在 System::Windows::Forms::TextRenderer::DrawText 的 2 个重载之间解析
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已经使用堆栈语义创建了
Font
对象,因此为了将其传递给需要跟踪句柄 (Font^
) 的函数,您需要使用一元operator%
,就像使用一元operator&
从 C++ 中的对象值获取对象指针一样: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 unaryoperator%
, much as you would use unaryoperator&
to get an object pointer from an object value in C++:您确定 Rectangle 类参数是好的吗?
当某些参数被隐式转换但可以通过多种方式找到目标类型时,通常会发生这种情况。
Are you sure the Rectangle class parameter is the good one ?
This usually happens when some arguments are implicitly cast but many ways are the target type are found.