| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> ju ti er wei de hui tu cheng shi -c++ Borland ru men

ju ti er wei de hui tu cheng shi -c++ Borland ru men

2008-06-01 02:11:59 编辑來源:互联网 评论
 
 
 
本文为【具体而微的绘图程式-c++ Borland 入门】的拼音翻译版
  zai ben zhang zhong wo jiang wei ni shi fan ru he zai C++Builder zhong zhuan xie yi ge wan zheng de hui tu cheng shi 。 ji you zhe ge cheng shi de zhuan xie , ni hui geng jia le jie C++Builder de Canvas hui tu jing shen , er zai zhuan xie zhe ge cheng shi de tong shi , wo men ye ke jiang xiang guan de ji shu zuo yi ge zheng ti de jian yue 。 ci hui tu cheng shi de zhi xing jie guo ru xia :
具体而微的绘图程式-c++ Borland 入门

  dian ji cha kan da tu
  
  zai ci cheng shi zhong wo hui yi xun xu jian jin de fang shi yi bu yi bu di dai ling ni wan cheng zheng ge cheng shi , ji ben shang zhe ge cheng shi he C++Builder nei fu de fan li cheng shi you ji fen lei si , dan wo bi xu yao shuo ming de shi : zai C++Builder zhong suo fu de fan li cheng shi shi zhi jie you yuan xian zai Delphi nei yi Object Pascal suo zhuan xie de fan li cheng shi xiu gai er cheng , suo yi you bu fen cheng shi de xie fa da wei wei fan C++ shi wu jian dao xiang jing shen , zai mai ru C++Builder de xin shi ji zhi hou , wo men dang ran xi wang xie chu de cheng shi shi 『 xi chu ming men , xue tong chun zheng 』 de C++ shi de wu jian dao xiang cheng shi 。 er zhe jiu shi wo zai ben zhang zhong xi wang dai ling ni wan cheng de cheng shi 。
  XX-01 guan yu hua shu shi jian (Mouse Event)
  zhuan xie hui tu cheng shi , shou xian yao le jie hua shu shi jian , zai Windows zhong ding yi le xu duo de hua shu xun xi (Message), er zhe xie hua shu xun xi zai BCB zhong jiu cheng wei hua shu shi jian le , wei le yao chu li hua shu shi jian , wo men bi xu yao xuan xie hua shu shi jian chu li cheng shi :
  zai Windows zhong ding yi de hua shu xun xi lie biao
  WM_CAPTURECHANGED
  WM_LBUTTONDBLCLK
  WM_LBUTTONDOWN
  WM_LBUTTONUP
  WM_MBUTTONDBLCLK
  WM_MBUTTONDOWN
  WM_MBUTTONUP
  WM_MOUSEACTIVATE
  WM_MOUSEMOVE
  WM_NCHITTEST
  WM_NCLBUTTONDBLCLK
  WM_NCLBUTTONDOWN
  WM_NCLBUTTONUP
  WM_NCMBUTTONDBLCLK
  WM_NCMBUTTONDOWN
  WM_NCMBUTTONUP
  WM_NCMOUSEMOVE
  WM_NCRBUTTONDBLCLK
  WM_NCRBUTTONDOWN
  WM_NCRBUTTONUP
  WM_RBUTTONDBLCLK
  WM_RBUTTONDOWN
  WM_RBUTTONUP
  biao XX-01 Windows nei hua shu xiang guan Message。
  sui ran zai Windows zuo ye xi tong zhong ding yi le fei chang duo de xun xi , dan shi zai C++Builder zhong yi jing ba pang da de xun xi xi tong zuo shi du de jian hua le , bing qie bu zai yi xun xi de fang shi cun zai , er gai yi shi jian (Event) de chu li fang shi , zai ben zhang de hui tu cheng shi zhong , wo men zhi yao chu li yi xia de ji ge shi jian ji ke :
  OnMouseDown hua shu jian an xia shi jian
  OnMouseMove hua shu yi dong shi jian
  OnMouseUp hua shu jian fang kai shi jian
  OnClick ren he hua shu de dian qu
  zai ci , ni ke yi hen ming xian di fa xian , zai C++Builder de shi jian zhong bing wei jiang zuo you hua shu jian fen bie ding yi , er shi yi he bing chu li de fang shi , yin ci zai shou dao yi shang hua shu shi jian shi , ruo ni yao fen bian zuo you hua shu shi jian shi , bi xu zai shi jian chu li cheng shi zhong pan ding zuo you jian 。
  ju bei le ji ben de hua shu shi jian ren zhi hou , wo men kai shi jin xing hou xu de cheng shi tan suo ba !
  wei le rang ni shi ji le jie cheng shi de xi jie , wo xi wang jiang cheng shi zhuan xie de bu zhou xi jie jiao dai chu , zai wang xia jin xing zhi qian , wo men xian jian li yi ge xin de zhuan an dang , bing jiang qi ming ming wei DrawMain, tong shi jiang Form de Color xing zhi she wei hei se (clBlack), yi bian zhi jie zai shang mian hua tu 。
  XX-02 hua shu shi jian de chu li
  dang C++ Builder ying yong cheng shi zhen ce dao wu jian hua shu shi jian shi , ta hui jian cha ni shi fou ding yi gai wu jian xiang dui ying de hua shu shi jian chu li cheng shi , ran hou hu jiao gai han shu , jiang xiang guan shen shu chuan gei ta 。 yi OnMouseDown shi jian wei li , ta de shi jian chu li cheng shi mo ban ru xia :
  void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  }
  ta zong gong jie shou le yi xia ji ge shen shu :
  Sender yin fa gai shi jian de ruan ti yuan jian 。
  Button biao shi hua shu de an jian 。 ta de zhi ke wei mbLeft( zuo jian ),mbRight( you jian ),mbMiddle( zhong jian jian )。
  Shift yong yi biao shi shi jian fa sheng de tong shi Alt,Shift ji Ctrl san jian de zhuang tai 。
  X,Y yong yi biao shi shi jian fa sheng shi zhi zuo biao wei zhi 。
  zai da duo shu de qing kuang xia , hua shu shi jian de (X,Y) zuo biao zhi shi wo men zui wei gan ai hao de xiang mu , bu guo , you shi hou wo men ye xu yao kao Button jian lai pan ding hua shu de an jian , huo shi xu yao li yong Shift lai qu de fei fan jian de zhuang tai , er zuo yi xie e wai de cheng shi chu li 。
  XX-02-01 OnMouseDown shi jian de chu li
  shou xian wo men xian yi yi ge zui ji ben de hua xian cheng shi lai shuo ming OnMouseDown shi jian de chu li , dang shi yong zhe an xia hua shu shi , wo men xi wang jiang bi yi zhi shi jian fa sheng shi de zuo biao , yin ci wo men ke jiang cheng shi xie cheng ru xia :
  void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  Canvas->MoveTo(X,Y);
  }
  XX-02-03 OnMouseUp shi jian de chu li
  tong yang di , wo men ke yi zai wei zhe ge Form jia shang OnMouseUp de shi jian chu li han shi , zai shou dao OnMouseUp shi jian shi , you hua shu dian xia de zuo biao , hua yi tiao zhi xian zhi xian zai de zuo biao 。
  
  
  
  void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  Canvas->LineTo(X,Y);
  }
  zai xie wan le yi shang liang ge shi jian chu li han shi zhi hou , wo men jiu ke yi zai Form shang mian zuo hua le , ni ke yi yong hua shu zai Form shang mian tuo ge chu yi tiao tiao zhi xian 。 qi zhi xing jie guo da zhi ru tu XX-01:
具体而微的绘图程式-c++ Borland 入门

  tu XX-01
  XX-02-02 OnMouseMove shi jian de chu li
  zai jia shang le OnMouseDown ji OnMouseUp chu li han shi zhi hou , wo men zhi neng hua chu yi tiao tiao zhi xian , ruo shi wo men xiang yao yi hua shu hua chu bu gui ze xian duan shi , jiu bi xu zai chu li OnMouseMove shi jian , li yong OnMouseMove shi jian , wo men ke yi zhui zong dao hua shu yi dong de wei zhi , jian dan de OnMouseMove shi jian chu li han shi ru xia :
  void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,
  int Y)
  {
  Canvas->LineTo(X,Y);
  }
  ci cheng shi de yi yi ji zai yu jiang hua shu suo jing guo de mei ge dian , yi xian tiao lian jie qi lai , zai jia shang OnMouseMove shi jian chu li han shi zhi hou , ta de zhi xing jie guo hui bian cheng tu XX-02:
具体而微的绘图程式-c++ Borland 入门

  tu XX-02
  XX-02-03 hua shu de chu li de jia qiang
  qian mian de cheng shi dui yu hua shu de yi dong chu li you bu fen kao lv de bu gou zhou xiang , yin wei ta zai hua shu yi dong shi bu fen qing hong zao bai jiu jiang xian hua zai ying mu shang , zao cheng ying mu shang de xian tiao hun luan , zhe bing bu shi zheng gui de chu li fang fa , zheng que de chu li fang fa ying gai ru xia :
  (1) hua shu jian an xia shi , jiang ji lu hua shu an xia de qi biao she wei True. tong shi jiang gai dian ji lu xia lai , wei zhi yuan dian 。
  hua shu yi dong shi , pan ding hua shu an xia de qi biao shi fou she wei True, ruo wei True, ze yi dong zhi yuan dian , bing hua yi tiao you yuan dian zhi mu qian suo zai dian de xian 。 tong shi geng xin yuan dian wei zhi zhi mu qian suo zai zhi dian 。
  hua shu fang kai shi , jiang ji lu hua shu an xia de qi biao she wei False。
  yi xia jiu shi guan yu san ge hua shu shi jian de chu li cheng shi ma 。
  // hua shu an xia de shi jian chu li han shi
  // 1. jiang qi biao she wei True
  // 2. ji lu yuan dian wei zhi
  void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  m_bDraw = TRUE;
  m_nOrgX=X;
  m_nOrgY=Y;
  }
  // hua shu yi dong de shi jian chu li han shi
  // 1. pan ding qi biao shi fou wei True。 ruo shi ze jin xing yi xia dong zuo 。
  // 2. yi dong zhi yuan dian 。
  // 3. hua yi tiao you yuan dian zhi mu qian suo zai dian de xian tiao 。
  // 4. geng gai yuan dian wei zhi 。
  void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
  int X, int Y)
  {
  if (m_bDraw)
  {
  Canvas->MoveTo(m_nOrgX,m_nOrgY);
  Canvas->LineTo(X,Y);
  m_nOrgX = X;
  m_nOrgY = Y;
  }
  }
  // hua shu fang kai de shi jian chu li han shi
  // 1. pan ding qi biao shi fou wei True。 ruo shi ze jin xing yi xia dong zuo 。
  // 1. jiang qi biao she wei False。
  // 2. hua xian bing ji lu yuan dian wei zhi ( fei bi yao )。
  void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  if (m_bDraw)
  {
  m_bDraw=FALSE;
  Canvas->MoveTo(m_nOrgX,m_nOrgY);
  Canvas->LineTo(X,Y);
  m_nOrgX = X;
  m_nOrgY = Y;
  }
  }
  jiang hua shu shi jian chu li han shi zuo yi shang de xiu gai zhi hou , wo men jiu wan cheng le yi ge ji ben de tu ya cheng shi de chu xing le 。 wo jiang ci biao ge de bei jing she wei hei se , bi de zhuang tai she wei 2 dan wei kuan du de hong se bi , jiu de dao yi xia de shu chu jie guo :
具体而微的绘图程式-c++ Borland 入门

  XX-03 hui tu wu jian de ding yi
  zhi mu qian wei zhi , wo men yi jing wan cheng le yi ge jian dan de tu ya cheng shi , jie xia lai , wo xi wang jiang cheng shi kuo chong wei yi ge yi ban de hui tu cheng shi , ta bi xu ju bei ji ben de hua xian 、 hua yuan 、 hua fang deng gong neng 。 wei le yao shi zuo chu zhe xie gong neng , wo men bi xu xian ding yi wo men de hui tu wu jian 。
  XX-03-01 hui tu wu jian zhi shi CShape
  class CShape
  
  
   {
  PRotected:
  TCanvas* m_pCanvas;
  TColor m_Color;
  int m_nWidth;
  public:
  CShape(TCanvas* pCanvas) {m_pCanvas = pCanvas;}
  virtual ~CShape() {}
  virtual void OnMouseMove(int,int)=0;
  virtual void OnMouseDown(int,int)=0;
  virtual void OnMouseUp(int,int)=0;
  };
  wo men shou xian ding yi yi ge CShape lei bie , ta shi suo you hui tu wu jian zhi shi , ye yin ci ta ding yi le yi ge hui tu wu jian de ji ben xing wei 。 zai ci hui tu cheng shi zhong wo xi wang ta ke yi chu li san ge bu tong de hua shu shi jian bing jia yi chu li zhi , suo yi wo zai CShape zhong ding yi le san ge xiang dui ying de cheng yuan han shi , er qie ta men dou shi chun xu ni han shi , biao shi suo you ji xu zi CShape de lei bie dou bi xu gai xie ci san ge cheng yuan han shi 。 ( guan yu wu jian dao xiang de guan nian qing shen yue < bi yao de C++ ji chu zhang jie > huo shi xiang guan shu ji , zai ci jin zuo jian duan de jie shi )。 zhe san ge han shi ming cheng cheng ru xia :
  virtual void OnMouseMove(int,int)=0;
  virtual void OnMouseDown(int,int)=0;
  virtual void OnMouseUp(int,int)=0;
  ling wai wo men zai ding yi yi ban xing de hui tu wu jian dou hui yong dao de ji ben te xing , ru yan se ji xian tiao kuan du , zai jia shang hui tu shi suo xu yao de Canvas, ru ci jiu zu cheng le CShape de lei bie ding yi :
  TCanvas* m_pCanvas; // hui tu suo xu de Canvas
  TColor m_Color; // yan se
  int m_nWidth; // kuan du
  zhi yu CShape de jie gou han shi wei he ye she cheng virtual ne ? zhe guan xi dao ji xu wu jian de hui mie fang fa 。 ruo shi ji chu lei bie de jie gou han shi mei you ding yi cheng xu ni han shi shi , hui zao cheng te ding qing kuang xia , zi lei bie de jie gou han shi mei you bei hu jiao dao de qing xing :
  ru :
  CLine *pLine = new Line;
  CShape* pShape=pLIne;
  delete pShape;
  shang shu de li zi yin wei CLine wei CShape de zi lei bie , yin ci ke yi zhi jie jiang pShape zhi biao zhi xiang pLine, ran er zai hou mian delete pShape shi , ruo shi pShape de jie gou han shi bu wei xu ni han shi , hui zao cheng pLine de jie gou han shi bu bei hu jiao dao 。 zhe shi yi ban C++ cheng shi she ji shi hen qing yi fan de cuo wu 。
  wo men ke yi jiang yi shang de jing yan fa ze gui na cheng yi ge yuan ze , ji shi : zhi yao gai lei bie you ke neng bei ji xu , jiu bi xu jiang qi jie gou han shi she wei xu ni han shi 。 ru ci jiu you le yi xia de ding yi le :
  CShape(TCanvas* pCanvas) {m_pCanvas = pCanvas;}
  virtual ~CShape() {}
  CShape de jian gou han shi bi xu chuan ru Canvas yi bian hui tu , er jie gou han shi ze bu zuo ren he shi , zhi jiang qi ding yi wei xu ni han shi 。
  XX-03-02 CLine lei bie ding yi ji shi zuo hua zhi xian de lei bie
  class CLine : public CShape
  {
  public:
  POINT m_ptMove;
  POINT m_ptOrigin;
  public:
  CLine(TCanvas* pCanvas):CShape(pCanvas) {}
  virtual ~CLine() {}
  virtual void OnMouseMove(int,int);
  virtual void OnMouseDown(int,int);
  virtual void OnMouseUp(int,int);
  };
  wo men jiang CLine ding yi wei yi ge hua zhi xian de lei bie , er wo men xi wang zai hua zhi xian shi ke yi zai tuo yi hua shu shi jiang yuan xian de xian tiao ca qu , bing hua chu xin de xian , yin ci wo men bi xu xuan gao liang ge dian lai ji zai hua shu an xia de dian ji shang ci de dian yi bian ca qu yuan lai de xian tiao 。
  yi xia jiu shi CLine dui yu san ge hua shu shi jian de chu li han shi :
  // hua shu an xia de shi jian chu li han shi
  // 1. she ding yuan dian ji shang ge qi shi dian wei mu qian suo zai dian 。
  // 2. yi dong zhi mu qian suo zai dian 。
  void CLine::OnMouseDown(int x,int y)
  {
  m_ptOrigin.x = m_ptMove.x = x;
  m_ptOrigin.y = m_ptMove.y = y;
  m_pCanvas->MoveTo(x,y);
  }
  // hua shu yi dong shi jian chu li han shi
  // 1. jiang hua bi mo shi she wei XOR mo shi , yi bian ca qu shang yi tiao xian 。
  // 2. ca qu yuan lai de xian ( yi XOR mo shi zai hua yi ci jiu hui ca qu le )
  // 3. zai mu qian de wei zhi hua chu yi tiao xin xian 。
  // 4. geng xin zuo biao bing gai bian hua bi mo shi 。
  void CLine::OnMouseMove(int x,int y)
  {
  m_pCanvas->Pen->Mode = pmXor;
  m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y);
  m_pCanvas->LineTo(m_ptMove.x,m_ptMove.y);
  m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y);
  m_pCanvas->LineTo(x,y);
  m_ptMove.x = x;
  m_ptMove.y = y;
  m_pCanvas->Pen->Mode = pmCopy;
  }
  // hua shu fang kai shi jian chu li han shi
  // 1. hua chu yuan dian zhi mu qian dian de zhi xian 。
  void CLine::OnMouseUp(int x,int y)
  {
  
  
   m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y);
  m_pCanvas->LineTo(x,y);
  }
  zhe jiu shi hua zhi xian lei bie de ding yi ji shi zuo nei rong 。
  XX-03-03 CPolyline lei bie ding yi ji shi zuo hua sui yi xian de lei bie
  class CPolyline : public CShape
  {
  public:
  POINT m_ptOrigin;
  public:
  CPolyline(TCanvas* pCanvas):CShape(pCanvas) {}
  virtual ~CPolyline() {}
  virtual void OnMouseMove(int,int);
  virtual void OnMouseDown(int,int);
  virtual void OnMouseUp(int,int);
  };
  CPolyline lei bie qi shi he wo men qian mian suo xie de tu ya cheng shi de xing wei mo shi ji wei lei si , suo yi wo jiu jian dan dai guo hao le 。
  void CPolyline::OnMouseDown(int x,int y)
  {
  m_ptOrigin.x = x;
  m_ptOrigin.y = y;
  m_pCanvas->MoveTo(x,y);
  }
  void CPolyline::OnMouseMove(int x,int y)
  {
  m_pCanvas->LineTo(x,y);
  }
  void CPolyline::OnMouseUp(int x,int y)
  {
  m_pCanvas->LineTo(x,y);
  }
  XX-03-04 CPolygon lei bie ding yi ji shi zuo hua duo bian xing de lei bie
  class CPolygon : public CPolyline
  {
  public:
  CPolygon(TCanvas* pCanvas):CPolyline(pCanvas){}
  virtual ~CPolygon() {}
  virtual void OnMouseUp(int,int);
  };
  CPolygon shi CPolyline de zi lei bie , qi cha bie jin zai yu ta hui jiang shou yi liang dian lian jie , shi qi cheng wei yi ge duo bian xing , yin ci wo men jiu zhi jie you CPolyline ji xu er lai , zhi gai xie qi OnMouseUp cheng yuan han shi ji ke 。
  void CPolygon::OnMouseUp(int x,int y)
  {
  m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y);
  m_pCanvas->LineTo(x,y);
  }
  XX-03-05 CRectangle lei bie ding yi ji shi zuo hua ju xing de lei bie
  class CRectangle : public CShape
  {
  public:
  POINT m_ptMove;
  POINT m_ptOrigin;
  public:
  CRectangle(TCanvas* pCanvas):CShape(pCanvas) {}
  virtual ~CRectangle() {}
  virtual void OnMouseMove(int,int);
  virtual void OnMouseDown(int,int);
  virtual void OnMouseUp(int,int);
  };
  hua ju xing lei bie qi shi he hua xian lei bie you xie lei si , ta men tong yang bi xu ji zai shang ci hua shu yi dong de dian , bing ca diao yuan lai de tu xing hua chu xin de tu xing , suo yi wo zhi zhen dui qi xiang yi de bu fen jia yi shuo ming zhi :
  // hua shu yi dong shi jian chu li han shi
  // yuan li he CLine lei si , zhi bu guo gai cheng hua ju xing 。
  void CRectangle::OnMouseMove(int x,int y)
  {
  m_pCanvas->Pen->Mode = pmXor;
  m_pCanvas->Rectangle(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y);
  m_ptMove.x = x;
  m_ptMove.y = y;
  m_pCanvas->Rectangle(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y);
  m_pCanvas->Pen->Mode = pmCopy;
  }
  XX-03-06 CRoundRect lei bie ding yi ji shi zuo hua yuan ju xing de lei bie
  class CRoundRect : public CShape
  {
  public:
  POINT m_ptMove;
  POINT m_ptOrigin;
  public:
  CRoundRect(TCanvas* pCanvas):CShape(pCanvas) {}
  virtual ~CRoundRect() {}
  virtual void OnMouseMove(int,int);
  virtual void OnMouseDown(int,int);
  virtual void OnMouseUp(int,int);
  };
  CRoundRect de shi zuo ji hu he Crectangle xiang tong , zhi bu guo ta men hu jiao bu tong de API ba le ,CRoundRect shi yi Canvas->RoundRect lai hua chu tu xing de 。
  void CRoundRect::OnMouseMove(int x,int y)
  
  
   {
  m_pCanvas->Pen->Mode = pmXor;
  m_pCanvas->RoundRect(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y,4,4);
  m_ptMove.x = x;
  m_ptMove.y = y;
  m_pCanvas->RoundRect(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y,4,4);
  m_pCanvas->Pen->Mode = pmCopy;
  }
  XX-03-07 CEllipse lei bie ding yi ji shi zuo hua yuan xing de lei bie
  hua yuan xing de chu li he hua ju xing ye da zhi xiang tong , yin wei zai Windows zhong shi yi bao wei ju xing lai ding yi yi ge yuan xing , yin ci he CRoundRect xiang tong de , wo men zhi yao gai xie cheng hua yuan han shi ji ke 。 qi yu wo jiu bu duo shuo le 。
  class CEllipse : public CShape
  {
  public:
  POINT m_ptMove;
  POINT m_ptOrigin;
  public:
  CEllipse(TCanvas* pCanvas):CShape(pCanvas) {}
  virtual ~CEllipse() {}
  virtual void OnMouseMove(int,int);
  virtual void OnMouseDown(int,int);
  virtual void OnMouseUp(int,int);
  };
  XX-03-08 xiao jie
  yi shang jiu shi ci hui tu cheng shi zhong suo shi yong de ge ge wu jian de ding yi , ci nai xue tong chun zheng de C++ xie fa de cheng shi , bu xiang C++Builder guan fang de fan li shi you Delphi de fan li xiu gai er lai , bu man le Object Pascal de wei dao 。
  ruo ni dui C++ shang bu tai shu xi de hua , qing ni yi ding yao xi xi ling lue yi shang de jing shen 。 yin wei ta shi C++ shi de wu jian dao xiang cheng shi zui ji ben qie jing yao de jing shen suo zai , dang ni le jie le yi shang de jing shen , ni jiu ke wei ba wo le C++ de feng zhuang 、 ji xu 、 ji dong tai lian jie zhe san ba quan zhang de ji ben jing shen 。
  zhi yu C++ lao shou , yi shang de ding yi dou shi hen zi ran jiu ke yi jie shou de 。 ye xu you ren hui zhi yi yi shang de wu jian ding yi bing wei kao lv dao wu jian de yong xu xing (Object Persistence)。 mei cuo , bu guo zhe bing bu shi wo shu hu le , er shi zai ben zhang de cheng shi zhong tu xing de cun qu shi yi Timage lai cun qu , yin ci suo you xiang liang shi de wu jian dou yi zhuan hua cheng dian zhen tu le , zi ran bu xu kao lv dao wu jian de chu cun wen ti 。
  zai hou xu zhang jie , wo huan hui zai zhen dui wu jian de yong xu xing lai zuo yi tao lun 。 xian zai wo men xian jiu TImage de dian zhen tu cun qu fang shi wei ping tai tao lun zhi 。
  zui hou , zai wan cheng le wu jian de ding yi zhi hou , wo men zai jiang cheng shi gen ju wu jian dao xiang de fang shi zai jia yi gai xie zhi 。 yin wei wo mu qian shang wei jia ru xuan ze wu jian de fang fa , suo yi wo zhi neng yong yu she wu jian xing tai de fang shi lai zhan shi cheng shi de jie guo 。
  // biao ge jian gou han shi , she ding m_bDraw qi biao chu zhi
  __fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
  {
  m_bDraw = FALSE;
  }
  // Form de OnCreate shi jian chu li han shi 。Form jian li shi yin fa 。
  // 1. she ding bi de yan se ji kuan du 。
  // 2. chan sheng yi ge CLine hui tu wu jian 。
  // zhu : ni ke yi zi xing xiu gai CLine cheng CPolyline、CPolygon、CRect deng zhi 。
  void __fastcall TForm1::FormCreate(TObject *Sender)
  {
  Canvas->Pen->Color = clRed;
  Canvas->Pen->Width = 2;
  m_pObj = new CLine(Canvas);
  }
  // Form de OnClose shi jian chu li han shi 。Form guan bi shi yin fa 。
  // 1. sha diao hui tu wu jian 。
  void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
  {
  delete m_pObj;
  }
  // geng gai hou de OnMouseDown wu jian chu li han shi 。
  // 1. jiang m_bDraw qi biao she wei TRUE。
  // 2. hu jiao hui tu wu jian de OnMouseDown han shi 。
  void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
  TShiftState Shift, int X, int Y)
  {
  m_bDraw = TRUE;
  m_pObj->OnMouseDown(X,Y);
  }
  // geng gai hou de OnMouseMove wu jian chu li han shi 。
  // 1. pan ding m_bDraw qi biao shi fou wei TRUE。
  // 2. ruo shi ze hu jiao hui tu wu jian de OnMouseMove han shi 。
  void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
  int X, int Y)
  {
  if (m_bDraw)
  m_pObj->OnMouseMove(X,Y);
  }
  // geng gai hou de OnMouseUp wu jian chu li han shi 。
  // 1. jiang m_bDraw qi biao she wei FALSE。
  // 2. ruo shi ze hu jiao hui tu wu jian de OnMouseUp han shi 。
  void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
  
  
   TShiftState Shift, int X, int Y)
  {
  m_bDraw = FALSE;
  m_pObj->OnMouseUp(X,Y);
  }
  qiao ! zhe jiu shi geng gai hou de cheng shi , shi bu shi bian de ge wai jian jie ne ? chu ci zhi wai , ta zui da de you dian zai yu , wu lun wo men ri hou jia ru le duo shao hui tu wu jian , ni dou bu xu zai xiu gai yi shang cheng shi zhong guan yu hui tu wu jian de chu li bu fen , zhi yao zai zi xing zeng jia yi ge wu jian xuan gao ji ke 。 he yuan xian Borland gong si chan pin nei fu you Object Pascal xiu gai er lai de fan li , ta de C++ xue tong chun zheng duo le 。 er qie ruo shi ri hou ni xiang yao jiang qi xiu gai cheng wei yi ge wu jian shi de hui tu xi tong , ye zhi xu yao hen jian dan de xiu gai er yi 。
  hao ba ! rang wo men xian jian yue xian zai de cheng guo 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-04 CLine hui tu wu jian fan li 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-05 CPolyline hui tu wu jian fan li ( jiang cheng shi gai cheng new CPolyline)
  XX-04 gong ju lie (ToolBar) de shi yong
  dao mu qian wei zhi wo men yi jing jiang suo you hui tu wu jian ding yi wan cheng , yin ci li lun shang ni de cheng shi ying gai ke yi hua chu ge zhong bu tong de hui tu wu jian le 。 dan shi qian mian wo ti dao , mu qian wo men shang wei jiang hui tu wu jian de xuan ze gong neng shi zuo chu lai , yin ci wo men shi yi zhi jie xiu gai cheng shi de fang shi lai hui zhi bu tong de tu xing 。 zhe shi wei le shuo ming fang bian de quan yi zhi ji 。
  zai yi ban de hui tu cheng shi zhong dou shi yi gong ju lie de fang shi lai shi zuo chu hui tu gong neng de qie huan gong neng , ru Windows 95 nei de xiao hua jia ji shi yi dian xing li zi 。 yin ci jie xia lai wo jiu wei ni shuo ming zai C++ Builder zhong shi zuo chu gong ju lie de fang fa 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-06 xiao hua jia shi yong de gong ju lie
  zai C++ Builder zhong shi zuo gong ju lie de fang shi he qi ta de cheng shi ru Visual C++,Borland C++ bu tong 。 hou liang zhe dou shi zhi jie shi yong Windows 95 nei jian de gong ju lie xing bie lai da dao ci gong neng 。 ran er zai C++ Builder zhong yin wei you yi zhong geng wei jian dan qie zhi jie de fang shi lai zuo dao , yin ci jiu bu cai yong shang shu zuo fa ( dang ran C++ Builder ye ke yi yong Windows 95 nei jian de ToolBar xing bie , zhi shi yong fa jiao wei fu duo 。)。
  na me zai C++ Builder zhong shi ru he lai shi zuo chu gong ju lie ne ? shuo chuan le qi shi hen jian dan : na jiu shi li yong TPanel he TSpeedButton。
  CPanel shi yi ge duo gong neng de rong qi yuan jian , yin ci wo men ke yi yong ta lai zuo wei gong ju lie de ping tai , shi yong CPanel shi yin wei ta shi shao shu ji ge ke zuo wei rong qi yuan jian de yuan jian , suo yi ta hui zi dong tiao zheng zhi yu qi shang de ruan ti yuan jian de wei zhi , yin ci hen shi he zuo wei fang zhi gong ju lie de ping tai 。
  zhu : zai C++ Builder de cheng shi mo shi zhong da liang shi yong TPanel lai zuo wei rong qi yuan jian 。 ta chu le ke yi zuo wei ToolBar de ping tai wai , ling wai ru zhuang tai lie (StatusBar) ye ke yi yong ta lai wan cheng , er qie ta ye ke yi yong lai zuo wei hua mian fen ge de gong ju , lai da cheng zai MFC zhong lei si fen ge shi chuang (Splitter Window) xiao guo 。
  TSpeedButton kuai su an niu yuan jian zai gong neng shang ben lai jiu he gong ju lie you ji fen lei si , xian zai wo men ke yi jiang xiang tong shu xing de kuai su an niu yuan jian zheng he zai yi ge TPanel zhong ji ke wan cheng wo men suo yao de gong ju lie le 。
  zui hou wo zai jiang gong ju lie de zuo fa an bu jiu ban xiang shu zhi :
  (1) zai biao ge shang jia ru TPanel yuan jian 。
  she ding TPanel de Align xing zhi wei alTop。 yin wei wo men xi wang gong ju lie zhi yu biao ge shang fang , suo yi jiang ta she ding wei fu tie yu biao ge de shang fang 。 ru ci yi lai dang biao ge da xiao gai bian shi , gong ju lie de kuan du wei gen zhe gai bian , er gao du ze wei chi yuan xian de gao du 。
  jiang TSpeedButton jia ru TPanel yuan jian shang 。
  ni ke yi zai biao ge zhong jia ru duo ge shang shu de gong ju lie , ta men hui yi xu zi dong pai lie yu biao ge de shang fang , yin ci ni bu xu fei xin qu chu li zhe xie e wai de dong zuo 。
  XX-04-01 TSpeedButton yuan jian jie xi ji she ding
  ToolBar de ji ge ji ben yao su shi :
  (1) dai biao gai gong neng de tu xing 。
  (2) ke yi zhuang kuang qie huan qi zhuang tai 。
  dang shi yong zhe dian qu gai gong neng shi , bi xu zhi xing gai gong neng 。
  wo men lai kan kan TSpeedButton ru he da dao yi shang de yao qiu 。
  shou xian ,TSpeedButton ju bei Glyph xing zhi , ke yi zhi ding qi tu xing , suo yi di yi ge yao qiu bu cheng wen ti , zai lai TSpeedButton ju bei yi xia san zhong zhuang tai :
  yi ban an niu de gong neng 。
  ke yi chu neng / zhi neng 。
  ju bei qun zu te xing 。( ye jiu shi shuo tong yi qun zu de TSpeedButton hui hu xiang ying xiang , yin ci ke qing yi zuo chu hu chi de gong neng , yi hui tu cheng shi wei li , yi ci zhi neng shi yong yi zhong gong ju , yin ci dang shi yong zhe xuan qu gong ju shi , chu le bei xuan qu de gong ju zhi wai , qi ta de gong ju ying gai dou cheng fu qi zhuang tai )
  you shang ke zhi ,TSpeedButton que shi shi shi zuo ToolBar de shi dang ren xuan 。
  XX-04-02 jiang SpeedButton jia ru ToolBar
  yi zhao wo men xian qian de xu qiu , wo men xu yao yi ge ke yi qie huan hui tu gong ju de gong ju lie , yin ci wo men jiu zhao qian mian suo shuo de fang shi lai wan cheng ta 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-07 gong ju lie
  tu XX-07 jiu shi wo suo jia ru de SpeedButton, chu ci zhi wai huan you ji ge cheng xu bi xu wan cheng
  wei SpeedButton ming ming 。 qu yi ge you yi yi de ming zi 。
  yi xu yao she ding qi gao du ji wei zhi 。
  she ding tu xing 。
  she ding SpeedButton zhuang tai chu zhi 。
  she ding qun zu te xing 。
  
  
   ◎ she ding shi jian chu li han shi 。
  SpeedButton de ming ming yuan ze he yi ban bian shu de ming ming yuan ze xiang tong , jian dan ming le jiu hao 。 yi ben cheng shi wei li , wo men jiu ke yi LineButton、RectangleButton deng ming zi ming ming zhi 。 ming ming shi zhi yao gai bian SpeedButton de Name xing zhi ji ke 。
  zhi yu she ding tu xing , zhi yao xian xuan qu gai SpeedButton, ran hou zhi wu jian jian shi qi dian qu Glyph xing zhi , ran hou jiang yu xuan qu de dian zhen tu Load jin lai , ji ke wan cheng she ding tu xing de cheng xu le 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-08 Glyph tu xing zhi xuan qu 。
  she ding zhuang tai chu zhi : you yu wo men xi wang ben cheng shi zhi xing de chu shi zhi shi shi yong CLine yuan jian , yin ci wo jiang LineButton de Down shu xing wei True, qi yu ze wei False。
具体而微的绘图程式-c++ Borland 入门

  tu XX-09 xuan qu hou de zhuang tai
  she ding qun zu te xing : qun zu te xing shi SpeedButton yong yi shi zuo chu ToolBar de chong yao gong neng zhi yi 。 wo men ke yi jiang yi qun SpeedButton she wei tong yi qun zu , ru ci yi lai zai ci yi qun zu de SpeedButton jiu ju bei le hu chi te xing , ye jiu shi shuo zai ren he yi ge SpeedButton an xia shi , hui dao zhi qi ta de SpeedButton fu qi 。 ci wei shi zuo ToolBar de bi bei tiao jian , er li yong SpeedButton ke yi qing yi da cheng ci mu de 。
  she ding qun zu te xing qi shi hen jian dan , zhi yao ba gai qun zu de SpeedButton de GroupIndex xing zhi she wei xiang tong shu zi ji ke , zai ci li zhong wo men xi wang jiang suo you hui tu gong ju lie an niu she wei tong yi qun zu , yin ci wo ba gai xiang guan gong ju de GroupIndex xing zhi dou she wei 1。
  ling wai , xiang xin ni yi jing fa xian zai shang mian de gong ju lie zhong , chu le qian mian suo tan dao de hui tu gong ju zhi wai , wo huan duo jia le liang ge e wai de SpeedButton , ta men shi yong lai she ding bi ji bi shua de gong ju 。 zai ci li zhong , wo men shi yi ta lai jiao chu ling wai liang ge she ding bi ji bi shua de gong ju lie , yin ci ta bi xu ju bei suo wei Toggle On/Off de kai guan gong neng 。 ye jiu shi lei si CheckBox de gong neng 。
  SpeedButton ye ke qing yi da dao yi shang de yao qiu , zhi yao she ding gai SpeedButton de AllowAllUp shu xing wei True ji ke yi zuo dao ci gong neng 。
  zui hou wo men bi xu jiang she ding bi ji bi shua de liang ge SpeedButton,PenButton ji BrushButton de GroupIndex fen bie she wei 2、3, ru ci cai bu hui he hui tu gong ju de SpeedButton de qun zu te xing xiang gan rao 。
  XX-05 gong ju lie de shi jian chu li han shi
  wan cheng de gong ju lie de she ding zhi hou , jie zhe wo men yao she ding gong ju lie de chu li han shi , you yu ci gong ju lie shi yong lai qie huan hui tu gong ju de , yin ci wo men zhi yao chu li SpeedButton de OnClick shi jian , zai fen bie gen ju bu tong de shi jian zuo chu li ji ke 。
  zai ci li zhong ,OnClick de shi jian chu li han shi qi hen jian dan , zhi yao shan chu yuan lai shi yong de hui tu gong ju wu jian , zai chong xin qi shi yi ge xin de hui tu gong ju ji ke 。
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::LineButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CLine(Canvas);
  }
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::PolylineButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CPolyline(Canvas);
  }
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::PolygonButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CPolygon(Canvas);
  }
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::RectangleButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CRectangle(Canvas);
  }
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::EllipseButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CEllipse(Canvas);
  }
  //---------------------------------------------------------------------
  void __fastcall TGraphEx::RoundRectButtonClick(TObject *Sender)
  {
  delete m_pObj;
  m_pObj = new CRoundRect(Canvas);
  }
  //---------------------------------------------------------------------
  
  
  
  zai wan cheng le yi shang de she ding zhi hou , ci cheng shi jiu ju bei le li yong hui tu gong ju lie lai qie huan hui tu gong ju de gong neng 。
具体而微的绘图程式-c++ Borland 入门

  tu XX-10 ju bei hui tu gong ju lie de hui tu cheng shi fan li 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
zai ben zhang zhong wo jiang wei ni shi fan ru he zai C++Builder zhong zhuan xie yi ge wan zheng de hui tu cheng shi 。 ji you zhe ge cheng shi de zhuan xie , ni hui geng jia le jie C++Builder de Canvas hui tu jing shen , er zai zhuan xie zhe ge cheng shi de tong shi , wo men ye ke jiang xiang guan de ji shu zuo yi ge zheng ti de jian yue 。 ci hui tu cheng shi de zhi xing jie guo ru xia : [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423004403.gif[/img][/url] dian ji cha kan da tu     zai ci cheng shi zhong wo hui yi xun xu jian jin de fang shi yi bu yi bu di dai ling ni wan cheng zheng ge cheng shi , ji ben shang zhe ge cheng shi he C++Builder nei fu de fan li cheng shi you ji fen lei si , dan wo bi xu yao shuo ming de shi : zai C++Builder zhong suo fu de fan li cheng shi shi zhi jie you yuan xian zai Delphi nei yi Object Pascal suo zhuan xie de fan li cheng shi xiu gai er cheng , suo yi you bu fen cheng shi de xie fa da wei wei fan C++ shi wu jian dao xiang jing shen , zai mai ru C++Builder de xin shi ji zhi hou , wo men dang ran xi wang xie chu de cheng shi shi 『 xi chu ming men , xue tong chun zheng 』 de C++ shi de wu jian dao xiang cheng shi 。 er zhe jiu shi wo zai ben zhang zhong xi wang dai ling ni wan cheng de cheng shi 。   XX-01 guan yu hua shu shi jian (Mouse Event)   zhuan xie hui tu cheng shi , shou xian yao le jie hua shu shi jian , zai Windows zhong ding yi le xu duo de hua shu xun xi (Message), er zhe xie hua shu xun xi zai BCB zhong jiu cheng wei hua shu shi jian le , wei le yao chu li hua shu shi jian , wo men bi xu yao xuan xie hua shu shi jian chu li cheng shi :   zai Windows zhong ding yi de hua shu xun xi lie biao WM_CAPTURECHANGED WM_LBUTTONDBLCLK WM_LBUTTONDOWN WM_LBUTTONUP WM_MBUTTONDBLCLK WM_MBUTTONDOWN WM_MBUTTONUP WM_MOUSEACTIVATE WM_MOUSEMOVE WM_NCHITTEST WM_NCLBUTTONDBLCLK WM_NCLBUTTONDOWN WM_NCLBUTTONUP WM_NCMBUTTONDBLCLK WM_NCMBUTTONDOWN WM_NCMBUTTONUP WM_NCMOUSEMOVE WM_NCRBUTTONDBLCLK WM_NCRBUTTONDOWN WM_NCRBUTTONUP WM_RBUTTONDBLCLK WM_RBUTTONDOWN WM_RBUTTONUP biao XX-01 Windows nei hua shu xiang guan Message。   sui ran zai Windows zuo ye xi tong zhong ding yi le fei chang duo de xun xi , dan shi zai C++Builder zhong yi jing ba pang da de xun xi xi tong zuo shi du de jian hua le , bing qie bu zai yi xun xi de fang shi cun zai , er gai yi shi jian (Event) de chu li fang shi , zai ben zhang de hui tu cheng shi zhong , wo men zhi yao chu li yi xia de ji ge shi jian ji ke :   OnMouseDown hua shu jian an xia shi jian OnMouseMove hua shu yi dong shi jian OnMouseUp hua shu jian fang kai shi jian OnClick ren he hua shu de dian qu   zai ci , ni ke yi hen ming xian di fa xian , zai C++Builder de shi jian zhong bing wei jiang zuo you hua shu jian fen bie ding yi , er shi yi he bing chu li de fang shi , yin ci zai shou dao yi shang hua shu shi jian shi , ruo ni yao fen bian zuo you hua shu shi jian shi , bi xu zai shi jian chu li cheng shi zhong pan ding zuo you jian 。   ju bei le ji ben de hua shu shi jian ren zhi hou , wo men kai shi jin xing hou xu de cheng shi tan suo ba !   wei le rang ni shi ji le jie cheng shi de xi jie , wo xi wang jiang cheng shi zhuan xie de bu zhou xi jie jiao dai chu , zai wang xia jin xing zhi qian , wo men xian jian li yi ge xin de zhuan an dang , bing jiang qi ming ming wei DrawMain, tong shi jiang Form de Color xing zhi she wei hei se (clBlack), yi bian zhi jie zai shang mian hua tu 。   XX-02 hua shu shi jian de chu li   dang C++ Builder ying yong cheng shi zhen ce dao wu jian hua shu shi jian shi , ta hui jian cha ni shi fou ding yi gai wu jian xiang dui ying de hua shu shi jian chu li cheng shi , ran hou hu jiao gai han shu , jiang xiang guan shen shu chuan gei ta 。 yi OnMouseDown shi jian wei li , ta de shi jian chu li cheng shi mo ban ru xia : void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { }   ta zong gong jie shou le yi xia ji ge shen shu : Sender yin fa gai shi jian de ruan ti yuan jian 。 Button biao shi hua shu de an jian 。 ta de zhi ke wei mbLeft( zuo jian ),mbRight( you jian ),mbMiddle( zhong jian jian )。 Shift yong yi biao shi shi jian fa sheng de tong shi Alt,Shift ji Ctrl san jian de zhuang tai 。 X,Y yong yi biao shi shi jian fa sheng shi zhi zuo biao wei zhi 。   zai da duo shu de qing kuang xia , hua shu shi jian de (X,Y) zuo biao zhi shi wo men zui wei gan ai hao de xiang mu , bu guo , you shi hou wo men ye xu yao kao Button jian lai pan ding hua shu de an jian , huo shi xu yao li yong Shift lai qu de fei fan jian de zhuang tai , er zuo yi xie e wai de cheng shi chu li 。   XX-02-01 OnMouseDown shi jian de chu li   shou xian wo men xian yi yi ge zui ji ben de hua xian cheng shi lai shuo ming OnMouseDown shi jian de chu li , dang shi yong zhe an xia hua shu shi , wo men xi wang jiang bi yi zhi shi jian fa sheng shi de zuo biao , yin ci wo men ke jiang cheng shi xie cheng ru xia :   void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { Canvas->MoveTo(X,Y); } XX-02-03 OnMouseUp shi jian de chu li   tong yang di , wo men ke yi zai wei zhe ge Form jia shang OnMouseUp de shi jian chu li han shi , zai shou dao OnMouseUp shi jian shi , you hua shu dian xia de zuo biao , hua yi tiao zhi xian zhi xian zai de zuo biao 。   void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { Canvas->LineTo(X,Y); }   zai xie wan le yi shang liang ge shi jian chu li han shi zhi hou , wo men jiu ke yi zai Form shang mian zuo hua le , ni ke yi yong hua shu zai Form shang mian tuo ge chu yi tiao tiao zhi xian 。 qi zhi xing jie guo da zhi ru tu XX-01:   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423004537.gif[/img][/url] tu XX-01 XX-02-02 OnMouseMove shi jian de chu li   zai jia shang le OnMouseDown ji OnMouseUp chu li han shi zhi hou , wo men zhi neng hua chu yi tiao tiao zhi xian , ruo shi wo men xiang yao yi hua shu hua chu bu gui ze xian duan shi , jiu bi xu zai chu li OnMouseMove shi jian , li yong OnMouseMove shi jian , wo men ke yi zhui zong dao hua shu yi dong de wei zhi , jian dan de OnMouseMove shi jian chu li han shi ru xia :   void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { Canvas->LineTo(X,Y); }   ci cheng shi de yi yi ji zai yu jiang hua shu suo jing guo de mei ge dian , yi xian tiao lian jie qi lai , zai jia shang OnMouseMove shi jian chu li han shi zhi hou , ta de zhi xing jie guo hui bian cheng tu XX-02: [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423004587.gif[/img][/url] tu XX-02 XX-02-03 hua shu de chu li de jia qiang   qian mian de cheng shi dui yu hua shu de yi dong chu li you bu fen kao lv de bu gou zhou xiang , yin wei ta zai hua shu yi dong shi bu fen qing hong zao bai jiu jiang xian hua zai ying mu shang , zao cheng ying mu shang de xian tiao hun luan , zhe bing bu shi zheng gui de chu li fang fa , zheng que de chu li fang fa ying gai ru xia :   (1) hua shu jian an xia shi , jiang ji lu hua shu an xia de qi biao she wei True. tong shi jiang gai dian ji lu xia lai , wei zhi yuan dian 。 hua shu yi dong shi , pan ding hua shu an xia de qi biao shi fou she wei True, ruo wei True, ze yi dong zhi yuan dian , bing hua yi tiao you yuan dian zhi mu qian suo zai dian de xian 。 tong shi geng xin yuan dian wei zhi zhi mu qian suo zai zhi dian 。 hua shu fang kai shi , jiang ji lu hua shu an xia de qi biao she wei False。   yi xia jiu shi guan yu san ge hua shu shi jian de chu li cheng shi ma 。   // hua shu an xia de shi jian chu li han shi // 1. jiang qi biao she wei True // 2. ji lu yuan dian wei zhi void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { m_bDraw = TRUE; m_nOrgX=X; m_nOrgY=Y; }   // hua shu yi dong de shi jian chu li han shi // 1. pan ding qi biao shi fou wei True。 ruo shi ze jin xing yi xia dong zuo 。 // 2. yi dong zhi yuan dian 。 // 3. hua yi tiao you yuan dian zhi mu qian suo zai dian de xian tiao 。 // 4. geng gai yuan dian wei zhi 。   void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (m_bDraw) { Canvas->MoveTo(m_nOrgX,m_nOrgY); Canvas->LineTo(X,Y); m_nOrgX = X; m_nOrgY = Y; } }   // hua shu fang kai de shi jian chu li han shi // 1. pan ding qi biao shi fou wei True。 ruo shi ze jin xing yi xia dong zuo 。 // 1. jiang qi biao she wei False。 // 2. hua xian bing ji lu yuan dian wei zhi ( fei bi yao )。 void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (m_bDraw) { m_bDraw=FALSE; Canvas->MoveTo(m_nOrgX,m_nOrgY); Canvas->LineTo(X,Y); m_nOrgX = X; m_nOrgY = Y; } }   jiang hua shu shi jian chu li han shi zuo yi shang de xiu gai zhi hou , wo men jiu wan cheng le yi ge ji ben de tu ya cheng shi de chu xing le 。 wo jiang ci biao ge de bei jing she wei hei se , bi de zhuang tai she wei 2 dan wei kuan du de hong se bi , jiu de dao yi xia de shu chu jie guo :   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007673.gif[/img][/url]   XX-03 hui tu wu jian de ding yi   zhi mu qian wei zhi , wo men yi jing wan cheng le yi ge jian dan de tu ya cheng shi , jie xia lai , wo xi wang jiang cheng shi kuo chong wei yi ge yi ban de hui tu cheng shi , ta bi xu ju bei ji ben de hua xian 、 hua yuan 、 hua fang deng gong neng 。 wei le yao shi zuo chu zhe xie gong neng , wo men bi xu xian ding yi wo men de hui tu wu jian 。   XX-03-01 hui tu wu jian zhi shi CShape   class CShape { PRotected: TCanvas* m_pCanvas; TColor m_Color; int m_nWidth; public: CShape(TCanvas* pCanvas) {m_pCanvas = pCanvas;} virtual ~CShape() {} virtual void OnMouseMove(int,int)=0; virtual void OnMouseDown(int,int)=0; virtual void OnMouseUp(int,int)=0; };   wo men shou xian ding yi yi ge CShape lei bie , ta shi suo you hui tu wu jian zhi shi , ye yin ci ta ding yi le yi ge hui tu wu jian de ji ben xing wei 。 zai ci hui tu cheng shi zhong wo xi wang ta ke yi chu li san ge bu tong de hua shu shi jian bing jia yi chu li zhi , suo yi wo zai CShape zhong ding yi le san ge xiang dui ying de cheng yuan han shi , er qie ta men dou shi chun xu ni han shi , biao shi suo you ji xu zi CShape de lei bie dou bi xu gai xie ci san ge cheng yuan han shi 。 ( guan yu wu jian dao xiang de guan nian qing shen yue < bi yao de C++ ji chu zhang jie > huo shi xiang guan shu ji , zai ci jin zuo jian duan de jie shi )。 zhe san ge han shi ming cheng cheng ru xia :   virtual void OnMouseMove(int,int)=0; virtual void OnMouseDown(int,int)=0; virtual void OnMouseUp(int,int)=0;   ling wai wo men zai ding yi yi ban xing de hui tu wu jian dou hui yong dao de ji ben te xing , ru yan se ji xian tiao kuan du , zai jia shang hui tu shi suo xu yao de Canvas, ru ci jiu zu cheng le CShape de lei bie ding yi :   TCanvas* m_pCanvas; // hui tu suo xu de Canvas TColor m_Color; // yan se int m_nWidth; // kuan du   zhi yu CShape de jie gou han shi wei he ye she cheng virtual ne ? zhe guan xi dao ji xu wu jian de hui mie fang fa 。 ruo shi ji chu lei bie de jie gou han shi mei you ding yi cheng xu ni han shi shi , hui zao cheng te ding qing kuang xia , zi lei bie de jie gou han shi mei you bei hu jiao dao de qing xing : ru :   CLine *pLine = new Line; CShape* pShape=pLIne; delete pShape;   shang shu de li zi yin wei CLine wei CShape de zi lei bie , yin ci ke yi zhi jie jiang pShape zhi biao zhi xiang pLine, ran er zai hou mian delete pShape shi , ruo shi pShape de jie gou han shi bu wei xu ni han shi , hui zao cheng pLine de jie gou han shi bu bei hu jiao dao 。 zhe shi yi ban C++ cheng shi she ji shi hen qing yi fan de cuo wu 。   wo men ke yi jiang yi shang de jing yan fa ze gui na cheng yi ge yuan ze , ji shi : zhi yao gai lei bie you ke neng bei ji xu , jiu bi xu jiang qi jie gou han shi she wei xu ni han shi 。 ru ci jiu you le yi xia de ding yi le :   CShape(TCanvas* pCanvas) {m_pCanvas = pCanvas;} virtual ~CShape() {}   CShape de jian gou han shi bi xu chuan ru Canvas yi bian hui tu , er jie gou han shi ze bu zuo ren he shi , zhi jiang qi ding yi wei xu ni han shi 。   XX-03-02 CLine lei bie ding yi ji shi zuo hua zhi xian de lei bie   class CLine : public CShape { public: POINT m_ptMove; POINT m_ptOrigin; public: CLine(TCanvas* pCanvas):CShape(pCanvas) {} virtual ~CLine() {} virtual void OnMouseMove(int,int); virtual void OnMouseDown(int,int); virtual void OnMouseUp(int,int); };   wo men jiang CLine ding yi wei yi ge hua zhi xian de lei bie , er wo men xi wang zai hua zhi xian shi ke yi zai tuo yi hua shu shi jiang yuan xian de xian tiao ca qu , bing hua chu xin de xian , yin ci wo men bi xu xuan gao liang ge dian lai ji zai hua shu an xia de dian ji shang ci de dian yi bian ca qu yuan lai de xian tiao 。 yi xia jiu shi CLine dui yu san ge hua shu shi jian de chu li han shi :   // hua shu an xia de shi jian chu li han shi // 1. she ding yuan dian ji shang ge qi shi dian wei mu qian suo zai dian 。 // 2. yi dong zhi mu qian suo zai dian 。 void CLine::OnMouseDown(int x,int y) { m_ptOrigin.x = m_ptMove.x = x; m_ptOrigin.y = m_ptMove.y = y; m_pCanvas->MoveTo(x,y); }   // hua shu yi dong shi jian chu li han shi // 1. jiang hua bi mo shi she wei XOR mo shi , yi bian ca qu shang yi tiao xian 。 // 2. ca qu yuan lai de xian ( yi XOR mo shi zai hua yi ci jiu hui ca qu le ) // 3. zai mu qian de wei zhi hua chu yi tiao xin xian 。 // 4. geng xin zuo biao bing gai bian hua bi mo shi 。 void CLine::OnMouseMove(int x,int y) { m_pCanvas->Pen->Mode = pmXor; m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y); m_pCanvas->LineTo(m_ptMove.x,m_ptMove.y); m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y); m_pCanvas->LineTo(x,y); m_ptMove.x = x; m_ptMove.y = y; m_pCanvas->Pen->Mode = pmCopy; }   // hua shu fang kai shi jian chu li han shi // 1. hua chu yuan dian zhi mu qian dian de zhi xian 。 void CLine::OnMouseUp(int x,int y) { m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y); m_pCanvas->LineTo(x,y); }   zhe jiu shi hua zhi xian lei bie de ding yi ji shi zuo nei rong 。   XX-03-03 CPolyline lei bie ding yi ji shi zuo hua sui yi xian de lei bie   class CPolyline : public CShape { public: POINT m_ptOrigin; public: CPolyline(TCanvas* pCanvas):CShape(pCanvas) {} virtual ~CPolyline() {} virtual void OnMouseMove(int,int); virtual void OnMouseDown(int,int); virtual void OnMouseUp(int,int); };   CPolyline lei bie qi shi he wo men qian mian suo xie de tu ya cheng shi de xing wei mo shi ji wei lei si , suo yi wo jiu jian dan dai guo hao le 。 void CPolyline::OnMouseDown(int x,int y) { m_ptOrigin.x = x; m_ptOrigin.y = y; m_pCanvas->MoveTo(x,y); }   void CPolyline::OnMouseMove(int x,int y) { m_pCanvas->LineTo(x,y); }   void CPolyline::OnMouseUp(int x,int y) { m_pCanvas->LineTo(x,y); }   XX-03-04 CPolygon lei bie ding yi ji shi zuo hua duo bian xing de lei bie   class CPolygon : public CPolyline { public: CPolygon(TCanvas* pCanvas):CPolyline(pCanvas){} virtual ~CPolygon() {} virtual void OnMouseUp(int,int); };   CPolygon shi CPolyline de zi lei bie , qi cha bie jin zai yu ta hui jiang shou yi liang dian lian jie , shi qi cheng wei yi ge duo bian xing , yin ci wo men jiu zhi jie you CPolyline ji xu er lai , zhi gai xie qi OnMouseUp cheng yuan han shi ji ke 。   void CPolygon::OnMouseUp(int x,int y) { m_pCanvas->MoveTo(m_ptOrigin.x,m_ptOrigin.y); m_pCanvas->LineTo(x,y); }   XX-03-05 CRectangle lei bie ding yi ji shi zuo hua ju xing de lei bie   class CRectangle : public CShape { public: POINT m_ptMove; POINT m_ptOrigin; public: CRectangle(TCanvas* pCanvas):CShape(pCanvas) {} virtual ~CRectangle() {} virtual void OnMouseMove(int,int); virtual void OnMouseDown(int,int); virtual void OnMouseUp(int,int); };   hua ju xing lei bie qi shi he hua xian lei bie you xie lei si , ta men tong yang bi xu ji zai shang ci hua shu yi dong de dian , bing ca diao yuan lai de tu xing hua chu xin de tu xing , suo yi wo zhi zhen dui qi xiang yi de bu fen jia yi shuo ming zhi :   // hua shu yi dong shi jian chu li han shi // yuan li he CLine lei si , zhi bu guo gai cheng hua ju xing 。 void CRectangle::OnMouseMove(int x,int y) { m_pCanvas->Pen->Mode = pmXor; m_pCanvas->Rectangle(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y); m_ptMove.x = x; m_ptMove.y = y; m_pCanvas->Rectangle(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y); m_pCanvas->Pen->Mode = pmCopy; }   XX-03-06 CRoundRect lei bie ding yi ji shi zuo hua yuan ju xing de lei bie   class CRoundRect : public CShape { public: POINT m_ptMove; POINT m_ptOrigin; public: CRoundRect(TCanvas* pCanvas):CShape(pCanvas) {} virtual ~CRoundRect() {} virtual void OnMouseMove(int,int); virtual void OnMouseDown(int,int); virtual void OnMouseUp(int,int); }; CRoundRect de shi zuo ji hu he Crectangle xiang tong , zhi bu guo ta men hu jiao bu tong de API ba le ,CRoundRect shi yi Canvas->RoundRect lai hua chu tu xing de 。   void CRoundRect::OnMouseMove(int x,int y) { m_pCanvas->Pen->Mode = pmXor; m_pCanvas->RoundRect(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y,4,4); m_ptMove.x = x; m_ptMove.y = y; m_pCanvas->RoundRect(m_ptOrigin.x,m_ptOrigin.y,m_ptMove.x,m_ptMove.y,4,4); m_pCanvas->Pen->Mode = pmCopy; }   XX-03-07 CEllipse lei bie ding yi ji shi zuo hua yuan xing de lei bie   hua yuan xing de chu li he hua ju xing ye da zhi xiang tong , yin wei zai Windows zhong shi yi bao wei ju xing lai ding yi yi ge yuan xing , yin ci he CRoundRect xiang tong de , wo men zhi yao gai xie cheng hua yuan han shi ji ke 。 qi yu wo jiu bu duo shuo le 。   class CEllipse : public CShape { public: POINT m_ptMove; POINT m_ptOrigin; public: CEllipse(TCanvas* pCanvas):CShape(pCanvas) {} virtual ~CEllipse() {} virtual void OnMouseMove(int,int); virtual void OnMouseDown(int,int); virtual void OnMouseUp(int,int); };   XX-03-08 xiao jie   yi shang jiu shi ci hui tu cheng shi zhong suo shi yong de ge ge wu jian de ding yi , ci nai xue tong chun zheng de C++ xie fa de cheng shi , bu xiang C++Builder guan fang de fan li shi you Delphi de fan li xiu gai er lai , bu man le Object Pascal de wei dao 。   ruo ni dui C++ shang bu tai shu xi de hua , qing ni yi ding yao xi xi ling lue yi shang de jing shen 。 yin wei ta shi C++ shi de wu jian dao xiang cheng shi zui ji ben qie jing yao de jing shen suo zai , dang ni le jie le yi shang de jing shen , ni jiu ke wei ba wo le C++ de feng zhuang 、 ji xu 、 ji dong tai lian jie zhe san ba quan zhang de ji ben jing shen 。   zhi yu C++ lao shou , yi shang de ding yi dou shi hen zi ran jiu ke yi jie shou de 。 ye xu you ren hui zhi yi yi shang de wu jian ding yi bing wei kao lv dao wu jian de yong xu xing (Object Persistence)。 mei cuo , bu guo zhe bing bu shi wo shu hu le , er shi zai ben zhang de cheng shi zhong tu xing de cun qu shi yi Timage lai cun qu , yin ci suo you xiang liang shi de wu jian dou yi zhuan hua cheng dian zhen tu le , zi ran bu xu kao lv dao wu jian de chu cun wen ti 。   zai hou xu zhang jie , wo huan hui zai zhen dui wu jian de yong xu xing lai zuo yi tao lun 。 xian zai wo men xian jiu TImage de dian zhen tu cun qu fang shi wei ping tai tao lun zhi 。   zui hou , zai wan cheng le wu jian de ding yi zhi hou , wo men zai jiang cheng shi gen ju wu jian dao xiang de fang shi zai jia yi gai xie zhi 。 yin wei wo mu qian shang wei jia ru xuan ze wu jian de fang fa , suo yi wo zhi neng yong yu she wu jian xing tai de fang shi lai zhan shi cheng shi de jie guo 。   // biao ge jian gou han shi , she ding m_bDraw qi biao chu zhi __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { m_bDraw = FALSE; }   // Form de OnCreate shi jian chu li han shi 。Form jian li shi yin fa 。 // 1. she ding bi de yan se ji kuan du 。 // 2. chan sheng yi ge CLine hui tu wu jian 。 // zhu : ni ke yi zi xing xiu gai CLine cheng CPolyline、CPolygon、CRect deng zhi 。   void __fastcall TForm1::FormCreate(TObject *Sender) { Canvas->Pen->Color = clRed; Canvas->Pen->Width = 2; m_pObj = new CLine(Canvas); }   // Form de OnClose shi jian chu li han shi 。Form guan bi shi yin fa 。 // 1. sha diao hui tu wu jian 。   void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) { delete m_pObj; }   // geng gai hou de OnMouseDown wu jian chu li han shi 。 // 1. jiang m_bDraw qi biao she wei TRUE。 // 2. hu jiao hui tu wu jian de OnMouseDown han shi 。 void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { m_bDraw = TRUE; m_pObj->OnMouseDown(X,Y); }   // geng gai hou de OnMouseMove wu jian chu li han shi 。 // 1. pan ding m_bDraw qi biao shi fou wei TRUE。 // 2. ruo shi ze hu jiao hui tu wu jian de OnMouseMove han shi 。   void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (m_bDraw) m_pObj->OnMouseMove(X,Y); }   // geng gai hou de OnMouseUp wu jian chu li han shi 。 // 1. jiang m_bDraw qi biao she wei FALSE。 // 2. ruo shi ze hu jiao hui tu wu jian de OnMouseUp han shi 。   void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { m_bDraw = FALSE; m_pObj->OnMouseUp(X,Y); }   qiao ! zhe jiu shi geng gai hou de cheng shi , shi bu shi bian de ge wai jian jie ne ? chu ci zhi wai , ta zui da de you dian zai yu , wu lun wo men ri hou jia ru le duo shao hui tu wu jian , ni dou bu xu zai xiu gai yi shang cheng shi zhong guan yu hui tu wu jian de chu li bu fen , zhi yao zai zi xing zeng jia yi ge wu jian xuan gao ji ke 。 he yuan xian Borland gong si chan pin nei fu you Object Pascal xiu gai er lai de fan li , ta de C++ xue tong chun zheng duo le 。 er qie ruo shi ri hou ni xiang yao jiang qi xiu gai cheng wei yi ge wu jian shi de hui tu xi tong , ye zhi xu yao hen jian dan de xiu gai er yi 。   hao ba ! rang wo men xian jian yue xian zai de cheng guo 。   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007722.gif[/img][/url] tu XX-04 CLine hui tu wu jian fan li 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007756.gif[/img][/url] tu XX-05 CPolyline hui tu wu jian fan li ( jiang cheng shi gai cheng new CPolyline)   XX-04 gong ju lie (ToolBar) de shi yong   dao mu qian wei zhi wo men yi jing jiang suo you hui tu wu jian ding yi wan cheng , yin ci li lun shang ni de cheng shi ying gai ke yi hua chu ge zhong bu tong de hui tu wu jian le 。 dan shi qian mian wo ti dao , mu qian wo men shang wei jiang hui tu wu jian de xuan ze gong neng shi zuo chu lai , yin ci wo men shi yi zhi jie xiu gai cheng shi de fang shi lai hui zhi bu tong de tu xing 。 zhe shi wei le shuo ming fang bian de quan yi zhi ji 。   zai yi ban de hui tu cheng shi zhong dou shi yi gong ju lie de fang shi lai shi zuo chu hui tu gong neng de qie huan gong neng , ru Windows 95 nei de xiao hua jia ji shi yi dian xing li zi 。 yin ci jie xia lai wo jiu wei ni shuo ming zai C++ Builder zhong shi zuo chu gong ju lie de fang fa 。   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007816.gif[/img][/url] tu XX-06 xiao hua jia shi yong de gong ju lie   zai C++ Builder zhong shi zuo gong ju lie de fang shi he qi ta de cheng shi ru Visual C++,Borland C++ bu tong 。 hou liang zhe dou shi zhi jie shi yong Windows 95 nei jian de gong ju lie xing bie lai da dao ci gong neng 。 ran er zai C++ Builder zhong yin wei you yi zhong geng wei jian dan qie zhi jie de fang shi lai zuo dao , yin ci jiu bu cai yong shang shu zuo fa ( dang ran C++ Builder ye ke yi yong Windows 95 nei jian de ToolBar xing bie , zhi shi yong fa jiao wei fu duo 。)。   na me zai C++ Builder zhong shi ru he lai shi zuo chu gong ju lie ne ? shuo chuan le qi shi hen jian dan : na jiu shi li yong TPanel he TSpeedButton。   CPanel shi yi ge duo gong neng de rong qi yuan jian , yin ci wo men ke yi yong ta lai zuo wei gong ju lie de ping tai , shi yong CPanel shi yin wei ta shi shao shu ji ge ke zuo wei rong qi yuan jian de yuan jian , suo yi ta hui zi dong tiao zheng zhi yu qi shang de ruan ti yuan jian de wei zhi , yin ci hen shi he zuo wei fang zhi gong ju lie de ping tai 。   zhu : zai C++ Builder de cheng shi mo shi zhong da liang shi yong TPanel lai zuo wei rong qi yuan jian 。 ta chu le ke yi zuo wei ToolBar de ping tai wai , ling wai ru zhuang tai lie (StatusBar) ye ke yi yong ta lai wan cheng , er qie ta ye ke yi yong lai zuo wei hua mian fen ge de gong ju , lai da cheng zai MFC zhong lei si fen ge shi chuang (Splitter Window) xiao guo 。   TSpeedButton kuai su an niu yuan jian zai gong neng shang ben lai jiu he gong ju lie you ji fen lei si , xian zai wo men ke yi jiang xiang tong shu xing de kuai su an niu yuan jian zheng he zai yi ge TPanel zhong ji ke wan cheng wo men suo yao de gong ju lie le 。   zui hou wo zai jiang gong ju lie de zuo fa an bu jiu ban xiang shu zhi :   (1) zai biao ge shang jia ru TPanel yuan jian 。 she ding TPanel de Align xing zhi wei alTop。 yin wei wo men xi wang gong ju lie zhi yu biao ge shang fang , suo yi jiang ta she ding wei fu tie yu biao ge de shang fang 。 ru ci yi lai dang biao ge da xiao gai bian shi , gong ju lie de kuan du wei gen zhe gai bian , er gao du ze wei chi yuan xian de gao du 。 jiang TSpeedButton jia ru TPanel yuan jian shang 。   ni ke yi zai biao ge zhong jia ru duo ge shang shu de gong ju lie , ta men hui yi xu zi dong pai lie yu biao ge de shang fang , yin ci ni bu xu fei xin qu chu li zhe xie e wai de dong zuo 。   XX-04-01 TSpeedButton yuan jian jie xi ji she ding   ToolBar de ji ge ji ben yao su shi : (1) dai biao gai gong neng de tu xing 。 (2) ke yi zhuang kuang qie huan qi zhuang tai 。 dang shi yong zhe dian qu gai gong neng shi , bi xu zhi xing gai gong neng 。   wo men lai kan kan TSpeedButton ru he da dao yi shang de yao qiu 。   shou xian ,TSpeedButton ju bei Glyph xing zhi , ke yi zhi ding qi tu xing , suo yi di yi ge yao qiu bu cheng wen ti , zai lai TSpeedButton ju bei yi xia san zhong zhuang tai :   yi ban an niu de gong neng 。 ke yi chu neng / zhi neng 。 ju bei qun zu te xing 。( ye jiu shi shuo tong yi qun zu de TSpeedButton hui hu xiang ying xiang , yin ci ke qing yi zuo chu hu chi de gong neng , yi hui tu cheng shi wei li , yi ci zhi neng shi yong yi zhong gong ju , yin ci dang shi yong zhe xuan qu gong ju shi , chu le bei xuan qu de gong ju zhi wai , qi ta de gong ju ying gai dou cheng fu qi zhuang tai )   you shang ke zhi ,TSpeedButton que shi shi shi zuo ToolBar de shi dang ren xuan 。   XX-04-02 jiang SpeedButton jia ru ToolBar   yi zhao wo men xian qian de xu qiu , wo men xu yao yi ge ke yi qie huan hui tu gong ju de gong ju lie , yin ci wo men jiu zhao qian mian suo shuo de fang shi lai wan cheng ta 。   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007912.gif[/img][/url] tu XX-07 gong ju lie   tu XX-07 jiu shi wo suo jia ru de SpeedButton, chu ci zhi wai huan you ji ge cheng xu bi xu wan cheng wei SpeedButton ming ming 。 qu yi ge you yi yi de ming zi 。 yi xu yao she ding qi gao du ji wei zhi 。 she ding tu xing 。 she ding SpeedButton zhuang tai chu zhi 。 she ding qun zu te xing 。 ◎ she ding shi jian chu li han shi 。   SpeedButton de ming ming yuan ze he yi ban bian shu de ming ming yuan ze xiang tong , jian dan ming le jiu hao 。 yi ben cheng shi wei li , wo men jiu ke yi LineButton、RectangleButton deng ming zi ming ming zhi 。 ming ming shi zhi yao gai bian SpeedButton de Name xing zhi ji ke 。   zhi yu she ding tu xing , zhi yao xian xuan qu gai SpeedButton, ran hou zhi wu jian jian shi qi dian qu Glyph xing zhi , ran hou jiang yu xuan qu de dian zhen tu Load jin lai , ji ke wan cheng she ding tu xing de cheng xu le 。   [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007934.gif[/img][/url] tu XX-08 Glyph tu xing zhi xuan qu 。   she ding zhuang tai chu zhi : you yu wo men xi wang ben cheng shi zhi xing de chu shi zhi shi shi yong CLine yuan jian , yin ci wo jiang LineButton de Down shu xing wei True, qi yu ze wei False。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423007975.gif[/img][/url] tu XX-09 xuan qu hou de zhuang tai   she ding qun zu te xing : qun zu te xing shi SpeedButton yong yi shi zuo chu ToolBar de chong yao gong neng zhi yi 。 wo men ke yi jiang yi qun SpeedButton she wei tong yi qun zu , ru ci yi lai zai ci yi qun zu de SpeedButton jiu ju bei le hu chi te xing , ye jiu shi shuo zai ren he yi ge SpeedButton an xia shi , hui dao zhi qi ta de SpeedButton fu qi 。 ci wei shi zuo ToolBar de bi bei tiao jian , er li yong SpeedButton ke yi qing yi da cheng ci mu de 。   she ding qun zu te xing qi shi hen jian dan , zhi yao ba gai qun zu de SpeedButton de GroupIndex xing zhi she wei xiang tong shu zi ji ke , zai ci li zhong wo men xi wang jiang suo you hui tu gong ju lie an niu she wei tong yi qun zu , yin ci wo ba gai xiang guan gong ju de GroupIndex xing zhi dou she wei 1。   ling wai , xiang xin ni yi jing fa xian zai shang mian de gong ju lie zhong , chu le qian mian suo tan dao de hui tu gong ju zhi wai , wo huan duo jia le liang ge e wai de SpeedButton , ta men shi yong lai she ding bi ji bi shua de gong ju 。 zai ci li zhong , wo men shi yi ta lai jiao chu ling wai liang ge she ding bi ji bi shua de gong ju lie , yin ci ta bi xu ju bei suo wei Toggle On/Off de kai guan gong neng 。 ye jiu shi lei si CheckBox de gong neng 。   SpeedButton ye ke qing yi da dao yi shang de yao qiu , zhi yao she ding gai SpeedButton de AllowAllUp shu xing wei True ji ke yi zuo dao ci gong neng 。   zui hou wo men bi xu jiang she ding bi ji bi shua de liang ge SpeedButton,PenButton ji BrushButton de GroupIndex fen bie she wei 2、3, ru ci cai bu hui he hui tu gong ju de SpeedButton de qun zu te xing xiang gan rao 。   XX-05 gong ju lie de shi jian chu li han shi   wan cheng de gong ju lie de she ding zhi hou , jie zhe wo men yao she ding gong ju lie de chu li han shi , you yu ci gong ju lie shi yong lai qie huan hui tu gong ju de , yin ci wo men zhi yao chu li SpeedButton de OnClick shi jian , zai fen bie gen ju bu tong de shi jian zuo chu li ji ke 。   zai ci li zhong ,OnClick de shi jian chu li han shi qi hen jian dan , zhi yao shan chu yuan lai shi yong de hui tu gong ju wu jian , zai chong xin qi shi yi ge xin de hui tu gong ju ji ke 。   //--------------------------------------------------------------------- void __fastcall TGraphEx::LineButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CLine(Canvas); } //--------------------------------------------------------------------- void __fastcall TGraphEx::PolylineButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CPolyline(Canvas); } //--------------------------------------------------------------------- void __fastcall TGraphEx::PolygonButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CPolygon(Canvas); } //--------------------------------------------------------------------- void __fastcall TGraphEx::RectangleButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CRectangle(Canvas); } //--------------------------------------------------------------------- void __fastcall TGraphEx::EllipseButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CEllipse(Canvas); } //--------------------------------------------------------------------- void __fastcall TGraphEx::RoundRectButtonClick(TObject *Sender) { delete m_pObj; m_pObj = new CRoundRect(Canvas); } //---------------------------------------------------------------------   zai wan cheng le yi shang de she ding zhi hou , ci cheng shi jiu ju bei le li yong hui tu gong ju lie lai qie huan hui tu gong ju de gong neng 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785468.html][img]http://image.wangchao.net.cn/it/1323423008012.gif[/img][/url] tu XX-10 ju bei hui tu gong ju lie de hui tu cheng shi fan li 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
情人节的清纯女生(9)
情人节的清纯女生(8)
情人节的清纯女生(7)
情人节的清纯女生(6)
山东蓬莱海边组照
一探哲蚌 II
一探哲蚌 III
古长城的一角
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有