| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 906 人关注过本帖
标题:"QQ魔法表情"模拟器(2)---代码之2
只看楼主 加入收藏
zero_one
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2005-2-12
收藏
 问题点数:0 回复次数:5 
"QQ魔法表情"模拟器(2)---代码之2

第二个窗口代码 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Data; using System.IO;

namespace QQ_Magic { /// <summary> /// Form2 的摘要说明。 /// </summary> public class Form2 : System.Windows.Forms.Form {

private System.ComponentModel.IContainer components; private AxSHDocVw.AxWebBrowser webbrw; private System.Windows.Forms.TextBox textBox2; private string flashpath;

public Form2(string path) { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); flashpath=path;

// // TOD 在 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(Form2)); this.webbrw = new AxSHDocVw.AxWebBrowser(); this.textBox2 = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.webbrw)).BeginInit(); this.SuspendLayout(); // // webbrw // this.webbrw.Enabled = true; this.webbrw.Location = new System.Drawing.Point(12, 14); this.webbrw.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("webbrw.OcxState"))); this.webbrw.Size = new System.Drawing.Size(256, 196); this.webbrw.TabIndex = 0; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(278, 198); this.textBox2.Multiline = true; this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(178, 136); this.textBox2.TabIndex = 4; this.textBox2.Text = ""; this.textBox2.Visible = false; // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(476, 386); this.Controls.Add(this.textBox2); this.Controls.Add(this.webbrw); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Form2"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load); ((System.ComponentModel.ISupportInitialize)(this.webbrw)).EndInit(); this.ResumeLayout(false);

} #endregion // //以下是调用API函数;在调用API函数时,在引明System.Runtime.InteropServices这个名字空间, //程序开头处已经引用了。 // [DllImport("gdi32.dll", EntryPoint="BitBlt")] //这句是必要的 public static extern int BitBlt ( IntPtr hDestDC,//IntPtr我查过MSDN中说是转换句柄的。在BitBlt这个API函数中这个成员是一个int类,如果用int类型好像出错。 int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop );

private void Form2_Load(object sender, System.EventArgs e) {

//获得当前屏幕的大小 Rectangle rect = new Rectangle() ; rect = Screen.GetWorkingArea (this) ; //创建一个以当前屏幕为模板的图象 Graphics g1 = this.CreateGraphics() ; //创建以屏幕大小为标准的位图 Image MyImage = new Bitmap (this.Width,this.Height , g1 ) ; Graphics g2 = Graphics.FromImage ( MyImage ) ; //得到屏幕的DC IntPtr dc1 = g1.GetHdc() ; //得到Bitmap的DC IntPtr dc2 = g2.GetHdc() ; //调用此API函数,实现屏幕捕获 BitBlt ( dc2 , 0 , 0 ,this.Width,this.Height, dc1 ,0 ,0 , 13369376 ) ; //释放掉屏幕的DC g1.ReleaseHdc ( dc1 ) ; //释放掉Bitmap的DC g2.ReleaseHdc ( dc2 ) ; //以JPG文件格式来保存 MyImage.Save ( @Application.StartupPath+"\\bg.jpg" , ImageFormat.Jpeg ); //MessageBox.Show ( "当前屏幕已经保存为C盘的capture.jpg文件!" ) ; this.show_flash();//调用show_flash方法

//以下是设置webbr(WEBBorwer)控件 webbrw.Top=-2; webbrw.Left=-2; webbrw.Width=this.Width+20; webbrw.Height=this.Height+20 ; System.Object obj=null; webbrw.Navigate(@Application.StartupPath+"\\temp.html",ref obj,ref obj,ref obj,ref obj);

}

public void show_flash() { //读取Hhml文件 // try { //FileStream fs1=new FileStream(@Application.StartupPath+"\\temp.html",FileMode.Open,FileAccess.Read); //StreamReader fsreader=new StreamReader(fs1); StreamReader fsreader=new StreamReader(@Application.StartupPath+"\\temp.html"); textBox2.Text=fsreader.ReadToEnd(); fsreader.Close(); StreamWriter fswrite=new StreamWriter(@Application.StartupPath+"\\temp.html"); int i; //MessageBox.Show("lines:"+textBox2.Lines.Length); for(i=0;i<textBox2.Lines.Length;i++) { if(textBox2.Lines[i].IndexOf("swf")>0) { //MessageBox.Show(swfname); string temp="<param name=\"movie\" value=\"" +flashpath+ "\"/>"; fswrite.WriteLine(temp); continue; } fswrite.WriteLine(textBox2.Lines[i]); } fswrite.Close(); } catch(Exception ex) { MessageBox.Show("操作Temp.html文件出错!"+ex.Message); } }

} }

搜索更多相关主题的帖子: using System 魔法 代码 
2005-02-12 19:45
ZGQ520
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-11-10
收藏
得分:0 

楼主很强啊,有个地方我不明白
AxSHDocVw.AxWebBrowser webbrw;
这个会出错,到底是怎么回事呢
楼主告诉我好吗?
qunhuaqing@163.com
谢谢楼主咯

2006-04-30 11:38
xxxxx52
Rank: 4
等 级:贵宾
威 望:13
帖 子:689
专家分:0
注 册:2006-4-30
收藏
得分:0 
我也是这个问题啦~

好的资料下载网站http:///in.asp?id=xuelion2006 嘿嘿帮点一下拉~
2006-04-30 11:40
ZGQ520
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-11-10
收藏
得分:0 
楼主,那个问题是解决了,现在的问题是 ,
点完后出现的是一片空白的,动画没有出来
是怎么回事啊
2006-04-30 16:52
ZGQ520
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-11-10
收藏
得分:0 
楼主啊,我用过你的方法了,现在就一个问题了
就是,falsh没有出来
是不是少了什么代码呢?
2006-04-30 21:37
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
收藏
得分:0 
以下是引用ZGQ520在2006-4-30 11:38:00的发言:

楼主很强啊,有个地方我不明白
AxSHDocVw.AxWebBrowser webbrw;
这个会出错,到底是怎么回事呢
楼主告诉我好吗?
qunhuaqing@163.com
谢谢楼主咯

这个AxWebBrowser是新添加进去的控件。


<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2006-05-02 17:27
快速回复:"QQ魔法表情"模拟器(2)---代码之2
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018833 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved