1

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

エラーを出している

1>エラーC2665:'System :: Windows :: Forms :: TextRenderer :: DrawText':8つのオーバーロードのいずれもすべての引数タイプを変換できませんでした

1>は'voidSystem :: Windows :: Forms :: TextRenderer :: DrawText(System :: Drawing :: IDeviceContext ^、System :: String ^、System :: Drawing :: Font ^、System :: Drawing :: Point、System :: Drawing :: Color) '

1>または'voidSystem :: Windows :: Forms :: TextRenderer :: DrawText(System :: Drawing :: IDeviceContext ^、System :: String ^、System :: Drawing :: Font ^、System :: Drawing :: Rectangle 、System :: Drawing :: Color) '

行を失ってもエラーは発生しません。Pointで別の方法で試しましたが、他のプロジェクトでは正常に機能していました。どんなアイデアでもありがたいです、ありがとう。

編集 ここに関連する前の行、FWIWがあります。

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

2 に答える 2

2

スタックセマンティクスを使用してオブジェクトを作成Fontしたので、トラッキングハンドル(Font^)が必要な関数にオブジェクトを渡すには、単項を使用してC ++のオブジェクト値からオブジェクトポインタを取得するのoperator%と同じように、単項を使用する必要があります。operator&

Windows::Forms::TextRenderer::DrawText(
    gT,
    numTo100,
    %sfo,
    Rectangle(2, 2, 12, 12),
    SystemColors::ControlText
);
于 2011-08-29T22:58:32.513 に答える
0

Rectangleクラスパラメータが適切なものであると確信していますか?

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

これは通常、一部の引数が暗黙的にキャストされているが、ターゲットタイプが見つかる多くの方法で発生します。

于 2011-08-29T22:56:32.613 に答える