终于,从System.Windows.Forms.Control继承了一下。

一个好网页,不错,聊天记录,记下。

前天发的这个随笔,里面记载了一些资源,由于真正接触.NET(Win Form?)还是比较晚,所以目前为止还是笨鸟,还是后飞 16.gif

仔细看了里面一些资源,终于做出来了第一个Control,庆祝一下吧 14.gif

None.gif using  System;
None.gif
using  System.Windows.Forms;
None.gif
using  System.ComponentModel;
None.gif
using  System.Drawing;
None.gif
using  System.Drawing.Drawing2D;
None.gif
using  System.Drawing.Design;
None.gif
None.gif
namespace  DividerPanel
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// My First Control.
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    [ToolboxItem(true)]
InBlock.gif    [ToolboxBitmap(
typeof(MyFirstControl))]
InBlock.gif    
public class MyFirstControl : System.Windows.Forms.Control
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif
InBlock.gif        
private System.Drawing.Drawing2D.GraphicsPath graphicsPath = new GraphicsPath(System.Drawing.Drawing2D.FillMode.Alternate);
InBlock.gif
InBlock.gif        
private Color backColor = Color.Black;
InBlock.gif
InBlock.gif        
public MyFirstControl()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
this.graphicsPath.AddPolygon(new Point[]dot.gif{
InBlock.gif                                                
new Point(100),
InBlock.gif                                                
new Point(1010),
InBlock.gif                                                
new Point(010),
InBlock.gif                                                
new Point(090),
InBlock.gif                                                
new Point(1090),
InBlock.gif                                                
new Point(10100),
InBlock.gif                                                
new Point(190100),
InBlock.gif                                                
new Point(19090),
InBlock.gif                                                
new Point(20090),
InBlock.gif                                                
new Point(20010),
InBlock.gif                                                
new Point(19010),
InBlock.gif                                                
new Point(1900)
ExpandedSubBlockEnd.gif                                            }
);
InBlock.gif
InBlock.gif            
this.Region = new Region(graphicsPath);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
protected override void OnPaint(PaintEventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            LinearGradientBrush b 
= new LinearGradientBrush(this.ClientRectangle,
InBlock.gif                
this.backColor, this.backColor, 0false);
InBlock.gif              
InBlock.gif            e.Graphics.FillRectangle(b, 
this.ClientRectangle);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
protected override void OnGotFocus(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
base.OnGotFocus (e);
InBlock.gif            
this.backColor = Color.Red;
InBlock.gif            
this.Invalidate();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
protected override void OnLostFocus(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
base.OnLostFocus (e);
InBlock.gif            
this.backColor = Color.Black;
InBlock.gif            
this.Invalidate();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
protected override void OnClick(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
base.OnClick (e);
InBlock.gif
InBlock.gif            
this.Focus();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/runmin/archive/2004/11/17/64698.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值