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

    摘要: 我想监视一个服务的登陆帐户类型,如果发现不是localsystem就将其改回来,使用changeserviceconfig可以将帐户名改为其他帐户,但是无法改为.\system, 总是提示帐户名或密码不正确。 请高手指点 ......
    摘要: 在公司调试好了服务器,装的是redhat es3。其中vsftp启动,测试都没有问题。但是放到机房在机房测试还是好的,但是回到公司就连不上了。报错如下: 在本地连接正常的时候: 正在连接到 102 已连接到 192.168.0.102 端口 21 220 (vsftpd 1.2.0) user ele 331 please specify the password. pass (hidde......


我这样写的代码。为啥在屏幕画出的框来闪。各位高人隔日指个招啊。

using   System;  
  using   System.Drawing;  
  using   System.Drawing.Drawing2D;  
  using   System.Collections;  
  using   System.ComponentModel;  
  using   System.Windows.Forms;  
  using   System.Data;  
  using   System.Threading;  
   
  namespace   AppS  
  {  
  ///   <summary>  
  ///   Form1   的摘要说明。  
  ///   </summary>  
  public   class   Form1   :   System.Windows.Forms.Form  
  {  
  private   System.Windows.Forms.PictureBox   pictureBox1;  
  ///   <summary>  
  ///   必需的设计器变量。  
  ///   </summary>  
  private   System.ComponentModel.Container   components   =   null;  
  public   Thread   thDraw;  
  public   bool   BOOL=false;  
  //false是不用画  
  public   Point   Lt,Rb;  
   
  public   Form1()  
  {  
  //  
  //   Windows   窗体设计器支持所必需的  
  //  
  InitializeComponent();  
   
  //  
  //   TODO:   在   InitializeComponent   调用后添加任何构造函数代码  
  //  
  }  
   
  ///   <summary>  
  ///   清理所有正在使用的资源。  
  ///   </summary>  
  protected   override   void   Dispose(   bool   disposing   )  
  {  
  if(   disposing   )  
  {  
  if   (components   !=   null)    
  {  
  components.Dispose();  
  }  
  }  
  base.Dispose(   disposing   );  
  }  
   
  #region   Windows   窗体设计器生成的代码  
  ///   <summary>  
  ///   设计器支持所需的方法   -   不要使用代码编辑器修改  
  ///   此方法的内容。  
  ///   </summary>  
  private   void   InitializeComponent()  
  {  
  System.Resources.ResourceManager   resources   =   new   System.Resources.ResourceManager(typeof(Form1));  
  this.pictureBox1   =   new   System.Windows.Forms.PictureBox();  
  this.SuspendLayout();  
  //    
  //   pictureBox1  
  //    
  this.pictureBox1.Dock   =   System.Windows.Forms.DockStyle.Fill;  
  this.pictureBox1.Image   =   ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));  
  this.pictureBox1.Location   =   new   System.Drawing.Point(0,   0);  
  this.pictureBox1.Name   =   "pictureBox1";  
  this.pictureBox1.Size   =   new   System.Drawing.Size(480,   389);  
  this.pictureBox1.TabIndex   =   0;  
  this.pictureBox1.TabStop   =   false;  
  this.pictureBox1.MouseUp   +=   new   System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);  
  this.pictureBox1.MouseDown   +=   new   System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);  
  //    
  //   Form1  
  //    
  this.AutoScaleBaseSize   =   new   System.Drawing.Size(6,   14);  
  this.ClientSize   =   new   System.Drawing.Size(480,   389);  
  this.Controls.Add(this.pictureBox1);  
  this.Name   =   "Form1";  
  this.Text   =   "画图";  
  this.Load   +=   new   System.EventHandler(this.Form1_Load);  
  this.ResumeLayout(false);  
   
  }  
  #endregion  
   
  ///   <summary>  
  ///   应用程序的主入口点。  
  ///   </summary>  
  [STAThread]  
  static   void   Main()    
  {  
  Application.Run(new   Form1());  
  }  
   
  private   void   pictureBox1_MouseDown(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=true;  
  Lt.X=Cursor.Position.X;  
  Lt.Y=Cursor.Position.Y;  
  Lt=PointToClient(Lt);  
  thDraw=new   Thread(new   ThreadStart(DrawRect));  
  thDraw.Start();  
  }  
   
  private   void   pictureBox1_MouseUp(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=false;  
  thDraw.Abort();  
  }  
  private   void   DrawRect()  
  {  
  while(BOOL)  
  {  
  Graphics   G=this.pictureBox1.CreateGraphics();  
  Rb.X=Cursor.Position.X;  
  Rb.Y=Cursor.Position.Y;  
  Rb=PointToClient(Rb);  
  G.DrawRectangle(new   Pen(Color.Red,1.0f),Lt.X,Lt.Y,Rb.X-Lt.X,Rb.Y-Lt.Y);  
  G.Dispose();  
  this.pictureBox1.Invalidate();  
  }  
  }  
   
  private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
  this.GetStyle(ControlStyles.DoubleBuffer);  
  }  
  }  
  }  
 

NO.1   作者: pupo

画图尽量在OnPaint里面写

NO.2   作者: 3tzjq

注释掉this.pictureBox1.Invalidate();试试!  
  不行就更改代码:  
  private   void   DrawRect(Graphics   g)  
  {  
  while(BOOL)  
  {  
  //Graphics   G=this.pictureBox1.CreateGraphics();  
  Rb.X=Cursor.Position.X;  
  Rb.Y=Cursor.Position.Y;  
  Rb=PointToClient(Rb);  
  g.DrawRectangle(new   Pen(Color.Red,1.0f),Lt.X,Lt.Y,Rb.X-Lt.X,Rb.Y-Lt.Y);  
  //G.Dispose();  
  //this.pictureBox1.Invalidate();  
  }  
  }  
   
  private   void   pictureBox1_Paint(....)  
  {  
      DrawRect(e.Graphics);  
  }  
   
  你应该在PictrueBox.Paint事件里画,然后:  
  private   void   pictureBox1_MouseDown(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=true;  
  Lt.X=Cursor.Position.X;  
  Lt.Y=Cursor.Position.Y;  
  Lt=PointToClient(Lt);  
  thDraw=new   Thread(new   ThreadStart(DrawRect));  
  thDraw.Start();  
                                                        pictureBox1.Refresh();  
  }  
  private   void   pictureBox1_MouseUp(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=false;  
  pictureBox1.Refresh();  
  }

NO.3   作者: jinjazz

this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true);

NO.4   作者: lovewindy

没看你的代码,看代码太烦了,  
  但从你的话中:"我这个是时实的画框的。OnPaint里面就画一次。自然闪不了了啊。"  
  可能是你没弄好二级缓存吧,显存速度跟不上CPU处理速度  
  一个front,一个back,这些都是DirectX中的常识  
   
  也不知道是不是这个问题,仅供参考

NO.5   作者: JasonHeung

有两种方法:不能调用Invalidate()方法。  
  一是直接画,同时也自己擦除原来的图。  
  二是先画到一个BitMap中,在画到屏幕上。

NO.6   作者: ybzsu

bool   BOOL=false  
  private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
  this.GetStyle(ControlStyles.DoubleBuffer);  
  }  
  private   void   pictureBox1_MouseDown(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=true;  
  Lt.X=Cursor.Position.X;  
  Lt.Y=Cursor.Position.Y;  
  Lt=PointToClient(Lt);  
  }  
  private   void   pictureBox1_MouseMove(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  this.pictureBox1.Invalidate();  
  this.pictureBox1.Update();  
  if(BOOL)  
  {  
  Graphics   G=this.pictureBox1.CreateGraphics();  
  Rb.X=Cursor.Position.X;  
  Rb.Y=Cursor.Position.Y;  
  Rb=PointToClient(Rb);  
  G.DrawRectangle(new   Pen(Color.Red,1.0f),Lt.X,Lt.Y,Rb.X-Lt.X,Rb.Y-Lt.Y);  
  G.Dispose();  
   
  }  
  }  
   
  private   void   pictureBox1_MouseUp(object   sender,   System.Windows.Forms.MouseEventArgs   e)  
  {  
  BOOL=!BOOL;  
  }  
   
 

NO.7   作者: tslkfyh

你可以用DIRECTDRAW来实现,兄弟我不知你开个线程的目的是什么,这样就能在后台画?GDI绘图是要先得到句柄的独占权才能会制的,你的那个线程和系统本身的重绘是有冲突的。你的线程在绘图时引起了系统的重绘,把你画的给抹了,后你画,又抹掉,就这样重复,能不闪?

NO.8   作者: xxxxxxxxx

我怎么擦始终擦不干净前一图,带有一些小点。


    摘要: 我现在有1000多个姓名,每一个都是中文的,现在我想把这些中文姓名都转化成汉语拼音的形式。 不知道大家有没有高见! ......
» 本期热门文章:

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