ホーム » 2013 » 7月 » 25

日別アーカイブ: 2013/07/25

2013年7月
 123456
78910111213
14151617181920
21222324252627
28293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 77,344 アクセス



C2146

次の様なコードで,C2146 , C2065


  private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
    Size cr = this->ClientSize ;
    Point lt = Point(cr.Width/3*1,cr.Height/3*1) ;
    Point rb = Point(cr.Width/3*2,cr.Height/3*2) ;
    array<Point>^ pts = gcnew array<Point>(5) ;
    {
      pts->SetValue(gcnew Point(lt.X,lt.Y),0) ;
      pts->SetValue(gcnew Point(lt.X,rb.Y),1) ;
      pts->SetValue(gcnew Point(rb.X,rb.Y),2) ;
      pts->SetValue(gcnew Point(rb.X,lt.Y),3) ;
      pts->SetValue(gcnew Point(lt.X,lt.Y),4) ;
      }
    e->Graphics->DrawLines(gcnew Pen(Color::Red),pts) ;
    }
  private: System::Void Form1_SizeChanged(System::Object^ sender, System::EventArgs^ e) {
    this->Invalidate() ;
    }


—— ビルド開始: プロジェクト: DrwLines, 構成: Debug Win32 ——
コンパイルしています…
DrwLines.cpp
c:\…\drwlines\Form1.h(75) : error C2146: 構文エラー : ‘;’ が、識別子 ‘cr’ の前に必要です。
c:\…\drwlines\Form1.h(75) : error C2065: ‘cr’ : 定義されていない識別子です。
c:\…\drwlines\Form1.h(76) : error C2228: ‘.Width’ の左側はクラス、構造体、共用体でなければなりません
型は ”unknown-type” です。
c:\…\drwlines\Form1.h(76) : error C2228: ‘.Height’ の左側はクラス、構造体、共用体でなければなりません
型は ”unknown-type” です。
c:\…\drwlines\Form1.h(77) : error C2228: ‘.Width’ の左側はクラス、構造体、共用体でなければなりません
型は ”unknown-type” です。
c:\…\drwlines\Form1.h(77) : error C2228: ‘.Height’ の左側はクラス、構造体、共用体でなければなりません
型は ”unknown-type” です。
ビルドログは “file://c:\…\DrwLines\Debug\BuildLog.htm” に保存されました。
DrwLines – エラー 6、警告 0
========== ビルド: 0 正常終了、1 失敗、2 更新、0 スキップ ==========


Drawing::Size とすることにより通る様になるが,イマイチどの様に書くべきかが理解できてない.
DrawLines についても,よくわかってない.array<Point>^ の array って何?
ここの説明がわかりやすい.


pts->SetValue(gcnew Point(lt.X,lt.Y),0) ; の gcnew はいらない?
関数の引数の const ~ & はどこへ?


printf や CString::Format の “%10.3f” の様な形式
  String::Format で “{0,10:F3}”


C:\…\HelpPnt.hxx(72) : error C3083: ‘Drawing’: ‘::’ の左側のシンボルには、型を指定しなければなりません
C:\…\HelpPnt.hxx(72) : error C2039: ‘Point’ : ‘System’ のメンバではありません。
C:\…\HelpPnt.hxx(72) : error C2065: ‘Point’ : 定義されていない識別子です。
#using <System.Drawing.dll> を追加

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.