摘要: 在日常开发中,经常要打开一个模态窗体,在模态窗体中选择某一项,然后把这项的ID或者Name赋值给打开这个模态窗体的窗体…… 在Windows 客户端中,要实现这样的功能是非常简单的,代码也会很优美。当然,这与个人的写法有关系。 比较优美的方式有2种,一种是使用interface编写观察者模式,一种就是使用事件委托。既然在Windows平台中玩耍,那就采用更加灵活的事件委托方式来实现吧。 废话少说,我们来看实现代码吧。(红色加粗为主要中的重要代码)模态窗体的主要代码: public partial class SelectForm : Form { public event Action< 阅读全文
posted @ 2011-03-21 16:03 许明吉博客 阅读(1555) 评论(0) 推荐(0) 编辑
摘要: library Project1;uses SysUtils, Classes,Forms,windows,dialogs, Unit1 in 'Unit1.pas' {Form1};{$R *.res}function showform(formname:string):boolean;stdcall;var TheClass: TPersistentClass; aForm: TForm;begin result:=false; {如果您的Dll中有很多FORM,请在这儿注册哦 RegisterClasses([TForm1,TForm2,TForm3,...]); } R 阅读全文
posted @ 2011-03-21 15:42 许明吉博客 阅读(971) 评论(0) 推荐(0) 编辑
摘要: 第一步: 建一个 DLL 工程, 如图:然后保存, 我这里使用的名称都是默认的. 第二步: 建一个资源原文件, 如图:编辑内容如下(路径中的文件一定要存在):img1 BITMAP "c:\temp\test.bmp"然后, 取个名(后缀须是 rc, 我这里取名为 Res.rc), 保存在工程目录下. 第三步: 在 DLL 工程中添加这个资源原文件, 如图:此时, 工程源文件中会添加一句: {$R 'Res.res' 'Res.rc'}, 我们需要的源文件这样即可: library Project1;{$R 'Res.res' 阅读全文
posted @ 2011-03-21 15:37 许明吉博客 阅读(626) 评论(0) 推荐(0) 编辑
摘要: procedure TForm1.Button1Click(Sender: TObject); var Doc: IHTMLDocument2; ViewObject: IViewObject; sourceDrawRect: TRect; a, getjpg: TBitMap; i, m: integer; pdest, psour: hbitmap; jpg: tjpegimage; begin Doc := WebBrowser.Document as IHTMLDocument2; if Webbrowser.Document <> nil then try webbrow 阅读全文
posted @ 2011-03-21 11:57 许明吉博客 阅读(1558) 评论(0) 推荐(0) 编辑
摘要: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Security; namespace Print { public class Test { public 阅读全文
posted @ 2011-03-21 11:56 许明吉博客 阅读(5259) 评论(1) 推荐(0) 编辑
摘要: 包含mshtml, SHDocVw, AxSHDocVw的引用在vs2005中,这样引进mshtml在代码开头加上using mshtml;(具体方法 引用--》COM--》Microsoft HTML Object Libraryusing mshtml;)SHDocVw的引用,网上有篇文章这么做的:SHDocVw一定要在下面这个路径找:(C:\Program Files\Microsoft Visual Studio 8\Application\PreEmptive Solutions\Dotfuscator Community Edition)还有篇文章是这么来添加引用的:1 在 Vis 阅读全文
posted @ 2011-03-21 09:42 许明吉博客 阅读(11372) 评论(0) 推荐(0) 编辑
摘要: 1, 用Win32 API 或是UI Atomation 获取窗口, 窗口的类型为"Internet Explorer_Server"2。 添加引用:MSHTML, SHDocVw(Microsoft Internet Controls),Accessibility3。 导入APIAccessibleObjectFromWindow: 您可以参考pInvoke.net 获取更多有用信息。4。从窗获取 Acc: (hIENativeWindowHandle 是第一步里取得的窗口指针) object objAcc = null; Guid guidAcc = typeof( I 阅读全文
posted @ 2011-03-21 09:32 许明吉博客 阅读(3379) 评论(1) 推荐(0) 编辑
摘要: var doc: IHtmlDocument2; i: Integer; s: String;begin //iFile := WebBrowser1.Document as IPersistFile; //iFile.Save('F:\tt.mht', False); doc := WebBrowser1.Document as IHtmlDocument2; if doc.images.length = 0 then exit; Memo1.Clear; for i := 0 to doc.images.length-1 do with (doc.images.item(i 阅读全文
posted @ 2011-03-21 09:25 许明吉博客 阅读(1125) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Net;namespace WebPicture{ public partial class Form1 : Form { public Form1() { InitializeCompon 阅读全文
posted @ 2011-03-21 09:20 许明吉博客 阅读(1475) 评论(1) 推荐(0) 编辑
摘要: C#字符串函数大全将包括Len Len(string|varname) 、Trim Trim(string) 、Ltrim Ltrim(string)等多项内容,希望本文能对大家有所帮助。LenLen(string|varname)返回字符串内字符的数目,或是存储一变量所需的字节数。TrimTrim(string)将字符串前后的空格去掉 LtrimLtrim(string)将字符串前面的空格去掉 RtrimRtrim(string)将字符串后面的空格去掉 MidMid(string,start,length)从string字符串的start字符开始取得length长度的字符串,如果省略第三个参 阅读全文
posted @ 2011-03-18 12:24 许明吉博客 阅读(6206) 评论(0) 推荐(0) 编辑