首頁>Club>
5
回覆列表
  • 1 # 睦鄰就惡露a

    用PaintBox的屬性Canvas中的畫線函式就行了,假如PaintBox的Name為pb1,建立一個bool全域性變數或者單元的變數,代表是否需要畫線,具體步驟如下1.建立全域性變數:bool g_fDraw = 0;2.在PaintBox的滑鼠按下事件中設定g_fDraw為1,並設定滑鼠位置3.在PaintBox的滑鼠釋放事件中設定g_fDraw為04.在PaintBox的滑鼠移動事件中畫直線。bool g_fDraw = 0 ;void __fastcall TForm1::pb1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y){ g_fDraw = 1; pb1->Canvas->MoveTo(X, Y);}//---------------------------------------------------------------------------void __fastcall TForm1::pb1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y){ if(g_fDraw == 1) { pb1->Canvas->LineTo(X, Y); }}//---------------------------------------------------------------------------void __fastcall TForm1::pb1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y){ g_fDraw = 0;}//---------------------------------------------------------------------------

  • 中秋節和大豐收的關聯?
  • 有關神話故事的歇後語有哪些?