1
votes

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);
2
gT->DrawString(numTo100, %sfo, Drawing::Brushes::Indigo, 2, 2); is working but I dislike unneccessary floats and I must admit I wasn't aware of non-static methods for text rendering.John

2 Answers

2
votes

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

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.