当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: 如何得到另一个运行程序的msflexgrid中的数据? ......
    摘要: 现在我的sql server数据库中的内容太多了,想要把它们都刻到光盘里,请问我的delphi代码该怎么编写才能达到目的呢,只求您一个小例子就可以,请高手指教!!谢谢! ......


画图问题,请给个最优解吧

为了实现在窗口内绘制以鼠标为中心的十字线,鼠标移动时十字线也移动,类似截图软件或者股票软件里面定位的东东.  
   
  自己试着写了一个,但是效率不是很高,cpu占用率很高,而且动鼠标的时候明显感觉有延迟.谁能给个最优解或是说说思路是怎样的?

NO.1   作者: weisunding

我用两个Label实现快速画线,CPU基本无占用,楼主在你窗体加入下列代码试试  
   
                  Label   lblHR;  
                  Label   lblVT;  
   
                  private   void   Form1_Load(object   sender,   EventArgs   e)  
                  {  
                          lblHR   =   new   Label();  
                          lblVT   =   new   Label();  
   
                          this.Controls.Add(lblHR);  
                          this.Controls.Add(lblVT);  
   
                          lblHR.Text   =   "";  
                          lblHR.AutoSize   =   false;  
                          lblHR.Width   =   this.Width;  
                          lblHR.Height   =   1;  
                          lblHR.BackColor   =   Color.Black;  
                          lblHR.Left   =   0;  
                          lblHR.Anchor   =   AnchorStyles.Left   |   AnchorStyles.Right;  
                          lblHR.BringToFront();  
   
                          lblVT.Text   =   "";  
                          lblVT.AutoSize   =   false;  
                          lblVT.Height   =   this.Height;  
                          lblVT.Width   =   1;  
                          lblVT.BackColor   =   Color.Black;  
                          lblVT.   =   0;  
                          lblVT.Anchor   =   AnchorStyles.   |   AnchorStyles.Bottom;  
                          lblVT.BringToFront();  
   
                           
                  }  
   
                  private   void   Form1_MouseMove(object   sender,   MouseEventArgs   e)  
                  {  
                          lblHR.   =   e.Y;  
                          lblVT.Left   =   e.X;  
                  }

NO.2   作者: pupo

private   Point   currentPoint   =   new   Point(0,0);  
  private   Pen   pen   =   new   Pen(Color.Black);  
   
  private   void   Form1_MouseMove(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  if   (e.X   !=   currentPoint.X   ||   e.Y   !=   currentPoint.Y)  
  {  
  currentPoint   =   new   Point(e.X,e.Y);  
  this.Invalidate(true);  
  }  
  }  
   
  protected   override   void   OnPaint(PaintEventArgs   e)  
  {  
  base.OnPaint(e);  
  e.Graphics.DrawLine(pen,   0,   currentPoint.Y,   this.Width,   currentPoint.Y);  
  e.Graphics.DrawLine(pen,   currentPoint.X   ,   0,   currentPoint.X,   this.Height);  
                  }  
   
  private   void   Form1_Closed(object   sender,   System.EventArgs   e)  
  {  
  pen.Dispose();  
  }


 ·关于setitem    »显示摘要«
    摘要: 我想让在datawindow里检测用户的输入,当用户输入非法时,把用户输入的值改成默认的值。例如输入日期,当用户输入2005.9.32时,提示日期非法,然后把日期设成当天的。我在datawindow的itemchanged事件中添加如下代码: if not isdate(left(data,4)+"/"+mid(data,5,2)+"/"+right......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE