• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C#仿QQ皮肤-基窗体FunctionFormBase的实现

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

                                                     阅读全文:http://www.cckan.net/forum.php?mod=viewthread&tid=363    

 

 导读部分
-------------------------------------------------------------------------------------------------------------
C#仿QQ皮肤-实现原理系列文章导航
http://www.cckan.net/forum.php?mod=viewthread&tid=2

 

        一周要过去了,本来打算多写点的,还是时间不够啊,费话不多说,开始写代码,今天 我们要做的是一个窗体,这个窗体是基于窗体FormBase,就是我们上一节所说到的 基窗体FormBase与基用户控件FormBase1的实现 里面的FormBase窗体, 有关 FormBase的实现还请大家去看相应文章,这里不再做过多的说明。

        我们先看一下实现的效果吧,第一张图是 实现,第二张是正常使用时的样子

        

 

   下面看一下怎么实现吧,

   第一步,创建窗体

            我们右键单击文件夹选择添加窗体就行了,名称当时是“ FunctionFormBase”,然后单击确定,我们的窗体的大小不需要做任何的修改,那是因为那是继承自窗体FormBase而来的,上节我们讲过了, 他的大小是固定的,所以在这里不用再做设置;

            只要这样一行继承的语句就OK了

 

 /// <summary>
    
/// FunctionFormBase基窗体
    
/// 是构造EntryForm和SkinForm窗体的基础
    
/// </summary>
    public partial class FunctionFormBase : FormBase
    

 

    第二步,窗体的UI布局实现

            我们可以看到第一张图,就是窗体的UI布局,相信大家一看就能明白是怎么实现 的,我还是大致的说一下是怎么会事吧。窗体一共是三个Panel

     代码实现为:

代码
            // 
            
// ptbTopMiddle
            
// 
            this.ptbTopMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.ptbTopMiddle.Location = new System.Drawing.Point(100);
            
this.ptbTopMiddle.Name = "ptbTopMiddle";
            
this.ptbTopMiddle.Size = new System.Drawing.Size(66931);
            
this.ptbTopMiddle.TabIndex = 2;
            
this.ptbTopMiddle.TabStop = false;

            
// pnlBackGroup
            
// 
            this.pnlBackGroup.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            
this.pnlBackGroup.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.pnlBackGroup.Location = new System.Drawing.Point(031);
            
this.pnlBackGroup.Name = "pnlBackGroup";
            
this.pnlBackGroup.Size = new System.Drawing.Size(689444);
            
this.pnlBackGroup.TabIndex = 9;

            
// 
            
// ptbBottomMiddle
            
// 
            this.ptbBottomMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.ptbBottomMiddle.Location = new System.Drawing.Point(100);
            
this.ptbBottomMiddle.Name = "ptbBottomMiddle";
            
this.ptbBottomMiddle.Size = new System.Drawing.Size(66937);
            
this.ptbBottomMiddle.TabIndex = 3;

 

 

 在ptbTopMiddle左面是一个lblText  右面是两个CommandButton,这个控件是 我自己写的实现方法后面会提到这里不做详细说明,在ptbTopMiddle的两端分别是两个Panel,用来实现窗体的边角,和低部的ptbBottomMiddle 形式是一样的,下面我给出这些控件的初始代码

 

代码
            // 
            
// pnlRight
            
// 
            this.pnlRight.Controls.Add(this.ptbRight);
            
this.pnlRight.Dock = System.Windows.Forms.DockStyle.Right;
            
this.pnlRight.Location = new System.Drawing.Point(68731);
            
this.pnlRight.Name = "pnlRight";
            
this.pnlRight.Size = new System.Drawing.Size(2444);
            
this.pnlRight.TabIndex = 7;
            
// 
            
// ptbRight
            
// 
            this.ptbRight.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.ptbRight.Location = new System.Drawing.Point(00);
            
this.ptbRight.Name = "ptbRight";
            
this.ptbRight.Size = new System.Drawing.Size(2444);
            
this.ptbRight.TabIndex = 0;
            
this.ptbRight.TabStop = false;
            
// 
            
// pnlLeft
            
// 
            this.pnlLeft.Controls.Add(this.ptbLeft);
            
this.pnlLeft.Dock = System.Windows.Forms.DockStyle.Left;
            
this.pnlLeft.Location = new System.Drawing.Point(031);
            
this.pnlLeft.Name = "pnlLeft";
            
this.pnlLeft.Size = new System.Drawing.Size(2444);
            
this.pnlLeft.TabIndex = 6;
            
// 
            
// ptbLeft
            
// 
            this.ptbLeft.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.ptbLeft.Location = new System.Drawing.Point(00);
            
this.ptbLeft.Name = "ptbLeft";
            
this.ptbLeft.Size = new System.Drawing.Size(2444);
            
this.ptbLeft.TabIndex = 0;
            
this.ptbLeft.TabStop = false;
            
// 
            
// ptbBottomRight
            
// 
            this.ptbBottomRight.Dock = System.Windows.Forms.DockStyle.Right;
            
this.ptbBottomRight.Location = new System.Drawing.Point(6790);
            
this.ptbBottomRight.Name = "ptbBottomRight";
            
this.ptbBottomRight.Size = new System.Drawing.Size(1037);
            
this.ptbBottomRight.TabIndex = 2;
            
this.ptbBottomRight.TabStop = false;
            
// 
            
// ptbBottomLeft
            
// 
            this.ptbBottomLeft.Dock = System.Windows.Forms.DockStyle.Left;
            
this.ptbBottomLeft.Location = new System.Drawing.Point(00);
            
this.ptbBottomLeft.Name = "ptbBottomLeft";
            
this.ptbBottomLeft.Size = new System.Drawing.Size(1037);
            
this.ptbBottomLeft.TabIndex = 0;
            
this.ptbBottomLeft.TabStop = false;
            
this.pnlBackGroup.TabIndex = 9;
            
// 
            
// lblText
            
// 
            this.lblText.BackColor = System.Drawing.Color.Transparent;
            
this.lblText.Font = new System.Drawing.Font("宋体"10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            
this.lblText.Location = new System.Drawing.Point(273);
            
this.lblText.Name = "lblText";
            
this.lblText.Size = new System.Drawing.Size(27324);
            
this.lblText.TabIndex = 5;
            
this.lblText.Text = "Text";
            
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            
this.lblText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
            
this.lblText.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp);            // 
            
// lblText
            
// 
            this.lblText.BackColor = System.Drawing.Color.Transparent;
            
this.lblText.Font = new System.Drawing.Font("宋体"10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            
this.lblText.Location = new System.Drawing.Point(273);
            
this.lblText.Name = "lblText";
            
this.lblText.Size = new System.Drawing.Size(27324);
            
this.lblText.TabIndex = 5;
            
this.lblText.Text = "Text";
            
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            
this.lblText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
            
this.lblText.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp);
            
// 
            
// pnlCaption
            
// 
            this.pnlCaption.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            
this.pnlCaption.Controls.Add(this.lblText);
            
this.pnlCaption.Controls.Add(this.btnMin);
            
this.pnlCaption.Controls.Add(this.btnClose);
            
this.pnlCaption.Controls.Add(this.ptbTopMiddle);
            
this.pnlCaption.Controls.Add(this.ptbTopRight);
            
this.pnlCaption.Controls.Add(this.ptbTopLeft);
            
this.pnlCaption.Dock = System.Windows.Forms.DockStyle.Top;
            
this.pnlCaption.Location = new System.Drawing.Point(00);
            
this.pnlCaption.Name = "pnlCaption";
            
this.pnlCaption.Size = new System.Drawing.Size(68931);
            
this.pnlCaption.TabIndex = 5;
            
// 
            
// btnMin
            
// 
            this.btnMin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            
this.btnMin.BackColor = System.Drawing.Color.Transparent;
            
this.btnMin.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
            
this.btnMin.Location = new System.Drawing.Point(6100);
            
this.btnMin.MouseDownImage = null;
            
this.btnMin.MouseMoveImage = null;
            
this.btnMin.Name = "btnMin";
            
this.btnMin.NormalImage = null;
            
this.btnMin.Size = new System.Drawing.Size(3122);
            
this.btnMin.TabIndex = 4;
            
this.btnMin.ToolTip = "关闭";
            
this.btnMin.Click += new System.EventHandler(this.btnMin_Click);
            
// 
            
// btnClose
            
// 
            this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            
this.btnClose.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
            
this.btnClose.Location = new System.Drawing.Point(6420);
            
this.btnClose.MouseDownImage = null;
            
this.btnClose.MouseMoveImage = null;
            
this.btnClose.Name = "btnClose";
            
this.btnClose.NormalImage = null;
            
this.btnClose.Size = new System.Drawing.Size(3722);
            
this.btnClose.TabIndex = 4;
            
this.btnClose.ToolTip = "关闭";
            
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            
// 
            
// ptbTopMiddle
            
// 
            this.ptbTopMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
            
this.ptbTopMiddle.Location = new System.Drawing.Point(100);
            
this.ptbTopMiddle.Name = "ptbTopMiddle";
            
this.ptbTopMiddle.Size = new System.Drawing.Size(66931);
            
this.ptbTopMiddle.TabIndex = 2;
            
this.ptbTopMiddle.TabStop = false;
            
this.ptbTopMiddle.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
            
this.ptbTopMiddle.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp);
            
// 
            
// ptbTopRight
            
// 
            this.ptbTopRight.Dock = System.Windows.Forms.DockStyle.Right;
            
this.ptbTopRight.Location = new System.Drawing.Point(6790);
            
this.ptbTopRight.Name = "ptbTopRight";
            
this.ptbTopRight.Size = new System.Drawing.Size(1031);
            
this.ptbTopRight.TabIndex = 1;
            
this.ptbTopRight.TabStop = false;
            
// 
            
// ptbTopL

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# 线程手册 第七章 网络和线程发布时间:2022-07-10
下一篇:
C#编码规范发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap