开发者

error C2665, can't resolve between 2 overloads for System::Windows::Forms::TextRenderer::DrawText

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 S开发者_开发百科ystem::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);


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
);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜