用最简单的方法实现QQ魔法表情效果!

效果图。

--------------------------------------------------------------------------------------------

最先想到的方法是Form的TransparentKey属性。只需把Flaxh ocx拉到窗体,
ocx控件背景颜色、窗休背景颜色和TransparentKey都设置相同的颜色值就可以实现透明了。
什么?实现不了?
嘿嘿,把系统颜色改成16位色吧

于是找到了另一种方法........

完美方案:
在Form上放个WebBrowser,在WebBrowser中显示Flash,把WebBrowser Docuemt背景(默认是白色)和TransparentKey一致,
Form的FormBorderStyle高为none。
搞定,效果如上图。

贴上代码。

无常作品: msn : wuchangx@hotmail.com     QQ: 3263262

ContractedBlock.gif ExpandedBlockStart.gif Form2.Designer.cs
 1None.gifusing System.Windows.Forms;
 2None.gifnamespace abs.Agent
 3ExpandedBlockStart.gifContractedBlock.gifdot.gif{
 4InBlock.gif    partial class Form2
 5ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 6ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
 7InBlock.gif        /// 必需的设计器变量。
 8ExpandedSubBlockEnd.gif        /// </summary>

 9InBlock.gif        private System.ComponentModel.IContainer components = null;
10InBlock.gif
11ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
12InBlock.gif        /// 清理所有正在使用的资源。
13InBlock.gif        /// </summary>
14ExpandedSubBlockEnd.gif        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>

15InBlock.gif        protected override void Dispose(bool disposing)
16ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
17InBlock.gif            if (disposing && (components != null))
18ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
19InBlock.gif                components.Dispose();
20ExpandedSubBlockEnd.gif            }

21InBlock.gif            base.Dispose(disposing);
22ExpandedSubBlockEnd.gif        }

23InBlock.gif
24ContractedSubBlock.gifExpandedSubBlockStart.gif        Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
25InBlock.gif
26ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
27InBlock.gif        /// 设计器支持所需的方法 - 不要
28InBlock.gif        /// 使用代码编辑器修改此方法的内容。
29ExpandedSubBlockEnd.gif        /// </summary>

30InBlock.gif        private void InitializeComponent()
31ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
32InBlock.gif            this.webBrowser1 = new System.Windows.Forms.WebBrowser();
33InBlock.gif            this.SuspendLayout();
34InBlock.gif            // 
35InBlock.gif            // webBrowser1
36InBlock.gif            // 
37InBlock.gif            this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
38InBlock.gif            this.webBrowser1.Location = new System.Drawing.Point(00);
39InBlock.gif            this.webBrowser1.MinimumSize = new System.Drawing.Size(2020);
40InBlock.gif            this.webBrowser1.Name = "webBrowser1";
41InBlock.gif            this.webBrowser1.ScrollBarsEnabled = false;
42InBlock.gif            this.webBrowser1.Size = new System.Drawing.Size(505302);
43InBlock.gif            this.webBrowser1.TabIndex = 0;
44InBlock.gif            // 
45InBlock.gif            // Form2
46InBlock.gif            // 
47InBlock.gif            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
48InBlock.gif            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
49InBlock.gif            this.ClientSize = new System.Drawing.Size(505302);
50InBlock.gif            this.Controls.Add(this.webBrowser1);
51InBlock.gif            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
52InBlock.gif            this.Name = "Form2";
53InBlock.gif            this.Text = "Form2";
54InBlock.gif            this.TopMost = true;
55InBlock.gif            this.TransparencyKey = System.Drawing.Color.White;
56InBlock.gif            this.Load += new System.EventHandler(this.Form2_Load);
57InBlock.gif            this.ResumeLayout(false);
58InBlock.gif
59ExpandedSubBlockEnd.gif        }

60InBlock.gif
61ExpandedSubBlockEnd.gif        #endregion

62InBlock.gif
63InBlock.gif        private  WebBrowser webBrowser1;
64ExpandedSubBlockEnd.gif    }

65ExpandedBlockEnd.gif}

 

ContractedBlock.gif ExpandedBlockStart.gif Form2.cs
 1None.gifusing System;
 2None.gifusing System.Collections.Generic;
 3None.gifusing System.ComponentModel;
 4None.gifusing System.Data;
 5None.gifusing System.Drawing;
 6None.gifusing System.Text;
 7None.gifusing System.Windows.Forms;
 8None.gif
 9None.gifnamespace abs.Agent
10ExpandedBlockStart.gifContractedBlock.gifdot.gif{
11InBlock.gif    public partial class Form2 : Form
12ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
13InBlock.gif        public Form2()
14ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
15InBlock.gif            InitializeComponent();
16ExpandedSubBlockEnd.gif        }

17InBlock.gif
18InBlock.gif        private void Form2_Load(object sender, EventArgs e)
19ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
20InBlock.gif            webBrowser1.Navigate("about:blank");
21InBlock.gif            while (webBrowser1.IsBusy)
22ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
23InBlock.gif                Application.DoEvents();
24ExpandedSubBlockEnd.gif            }

25InBlock.gif            string file = @"file:///C|/1020110241.swf";
26ExpandedSubBlockStart.gifContractedSubBlock.gif            webBrowser1.Document.Write(string.Format("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"222\" height=\"186\"> <param name=\"wmode\" value=\"transparent\"><param name=\"movie\" value=\"dot.gif{0}\"> <param name=\"quality\" value=\"high\"></object>",file));
27ExpandedSubBlockEnd.gif        }

28ExpandedSubBlockEnd.gif    }

29ExpandedBlockEnd.gif}


file:///C|/1020110241.swf是QQ宠物中的动画,类似的动画在QQ安装目录里可找到很多。
首发于博客园:http://wuchang.cnblogs.com/archive/2006/07/17/453332.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值