大悟还俗

邮箱 key_ok@qq.com 我的收集 http://pan.baidu.com/share/home?uk=1177427271
  新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年10月21日

摘要: 以下代码旨在 脱离TXMLDocument 操作 xml。unit Unit3;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls;type TForm3 = class(TForm) XMLDocument1: TXMLDocument; Button1: TButton; Button2: TButton; Button3: TBu... 阅读全文

posted @ 2013-10-21 16:56 大悟还俗_2 阅读(844) 评论(0) 推荐(0) 编辑

摘要: unit ExEdit; interface uses System.Classes, Vcl.Controls, Winapi.Windows, Vcl.Graphics, Vcl.StdCtrls, System.SysUtils, Winapi.messages; type TBorders = class(TPersistent) private FRight: Boolean; FBottom: Boolean; FTop: Boolean; FLeft: Boolean; FPen: TPen; public constructor ... 阅读全文

posted @ 2013-10-21 16:51 大悟还俗_2 阅读(298) 评论(0) 推荐(0) 编辑

摘要: 先看看实现的效果如: 首先,我们来分析一下,这个控件的继承方式,这个根据个人需要,如果仅仅作为显示使用,不涉及到太多的消息以及事件响应消息的可以从TGraphicControl继承来实现,因为TGraphicControl就是专门用来实现仅仅显示效果的控件的,他的特性,我在前面的概述中有提到过,不明白的可以返回去查看;如果需要处理一些特殊消息以及句柄的处理的,那么请从TWinControl继承来实现。这里我选择直接从TGraphicControl来实现! 其次,这个动画效果,我们通过什么来实现!这个很容易想到TImagelist,Delphi自己带有的一组图片集合控件,通过这个图片集合,我们可 阅读全文

posted @ 2013-10-21 16:43 大悟还俗_2 阅读(282) 评论(0) 推荐(0) 编辑

摘要: 第一步,平面效果。Windows系统有几个消息专门用来处理Windows组件的边框部位,那就是WM_NCCALCSIZE和WM_NCPAINT这两个消息,从消息名字看来NC这个就代表着No Client也就是非客户区域,NCCALCSIZE也就是说明了计算非客户区和客户区的消息,而WM_NCPAINT消息,也就是非客户区域的绘制触发消息,所以就要截获这两个消息来绘制自己的边框取代Windows系统的绘制方式。在Delphi中拦截系统消息非常简单,直接在消息的处理过程后面跟一个message关键字,然后加上消息常量就可以了!不像MFC要搞消息映射那么麻烦,声明代码如下procedure WMNc 阅读全文

posted @ 2013-10-21 16:41 大悟还俗_2 阅读(517) 评论(0) 推荐(0) 编辑

摘要: 一.原理通过使用“内存映射文件”,实现内存共享二.主要操作共享内存结构: PShareMem = ^TShareMem; TShareMem = Record id:string[10]; name:string[20]; age:Integer; end; 基本变量: shareMemName:string; //共享内存名 fileHandle : THandle;//内存映射文件句柄 pUserInfoShareMem : PShareMem;//指向共享内存的指针 a)写入程序 1)创建“内存映射文件”begin //创建“内存映射文件”... 阅读全文

posted @ 2013-10-21 16:39 大悟还俗_2 阅读(400) 评论(0) 推荐(0) 编辑

摘要: unit filemap;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;const fileName = 'myTest.txt';type TForm1 = class(TForm) btnUpper: TButton; btnLower: TButton; txtContent: TMemo; Label1: TLabel; btnClose: TButton; procedu... 阅读全文

posted @ 2013-10-21 16:38 大悟还俗_2 阅读(1651) 评论(0) 推荐(0) 编辑

摘要: 一.原理 通过使用“内存映射文件”,实现内存共享 二.主要操作 共享内存结构: PShareMem = ^TShareMem; TShareMem = Record id:string[10]; name:string[20]; age:Integer; end;// 一定要注意 固定长度 基本变量 阅读全文

posted @ 2013-10-21 16:33 大悟还俗_2 阅读(2094) 评论(0) 推荐(0) 编辑

摘要: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; procedure FormCreate(Sender: TObject); private { Private ... 阅读全文

posted @ 2013-10-21 14:34 大悟还俗_2 阅读(394) 评论(0) 推荐(0) 编辑

摘要: {== D6DLLSynchronizer =================================================}{: This unit handles the D6 synchronize problem in DLLs@author Dr. Peter Below@desc Version 1.0 created 3 November 2001 Current revision 1.0 Last modified 3 November 2001Usage: Just add this unit to the DLL... 阅读全文

posted @ 2013-10-21 14:32 大悟还俗_2 阅读(578) 评论(0) 推荐(0) 编辑

摘要: unit Unit1;interfaceuses ImageHlp,Windows,Dialogs; procedure ListDLLExports(const AFileName:string);implementationprocedure ListDLLExports(const AFileName:string);type TDWordArray = array [0..$FFFFF] of DWORD;var image:TLoadedImage; pExpDir:PImageExportDirectory; iSize:Cardinal; pNameRVAs:^TDW... 阅读全文

posted @ 2013-10-21 14:30 大悟还俗_2 阅读(214) 评论(0) 推荐(0) 编辑

摘要: // ① Delphi 使用 Interlocked 系列函数var MyValue:Longint = 0; // = Integerbegin InterlockedIncrement(MyValue); // + 1 返回值通常不用 InterlockedDecrement(MyValue); // - 1 返回值通常不用 InterlockedExchangeAdd(MyValue,10); // + 10 InterlockedExchangeAdd(PLongint(@MyValue),-10); // - 10 函数 overload InterlockedExcha... 阅读全文

posted @ 2013-10-21 14:27 大悟还俗_2 阅读(387) 评论(0) 推荐(0) 编辑

摘要: unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ImgList, ExtCtrls;type TForm2 = class(TForm) ImageList1: TImageList; Panel1: TPanel; procedure FormCreate(Sender: TObject); private { Private declarations } public { Publi... 阅读全文

posted @ 2013-10-21 14:26 大悟还俗_2 阅读(330) 评论(0) 推荐(0) 编辑

摘要: procedure TForm1.Button1Click(Sender: TObject);var i1,i2:Integer; b:array [0..3] of Byte absolute i1; // b 在这里跟 i1 共用地址begin i1 := 1234; i2 := MakeLong(MakeWord(b[0],b[1]),MakeWord(b[2],b[3])); // 在内存中i1其实是反过来存储, // 普通情况表达一个数字是“高位+低位”,而内存中是“低位+高位”的表达方式 // MakeXXX 函数就是实现了这种变化 if i1 = i2 then ... 阅读全文

posted @ 2013-10-21 14:25 大悟还俗_2 阅读(353) 评论(0) 推荐(0) 编辑

摘要: 以下代码可以看到 Int64Rec Int64procedure TForm1.Button2Click(Sender: TObject);var ii1,ii2,ii3:Int64;Hi,Lo:Cardinal;temp:Int64Rec;begin ii1 := 123456; Hi := Int64Rec(ii1).Hi; Lo := Int64Rec(ii1).Lo; ii2 := MakeROP4(Lo,Hi); // 这个函数没有什么实质的意义,只是为了表达 Hi + Lo = Int64 if ii1 = ii2 then ShowMessage('确认'); . 阅读全文

posted @ 2013-10-21 14:23 大悟还俗_2 阅读(461) 评论(0) 推荐(0) 编辑

摘要: PerformEraseBackground 擦除背景的简单方法(外带ThemeServices例子) 在查这个函数的时候,顺便看到了有趣的代码。怎么使用 Themes 。unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ImgList, ExtCtrls;type TForm2 = class(TForm) ImageList1: TImageList; Panel1: TPanel; procedur... 阅读全文

posted @ 2013-10-21 14:03 大悟还俗_2 阅读(489) 评论(0) 推荐(0) 编辑

摘要: 我一直感觉 Delphi 下的Bit操作不是很好使,所以一直屏蔽着这方面的学习。不过最近收集整理了一下代码。原因是这样的。由于某个需求被分解成 在 0~n(不定) 中,有几个数字被置换成了“true”由于我自己写了一个类来管理某个Record,而这个Record是用Variant来作为参数。(类似TDataSet)。开始的时候,我想着吧,用 array of Boolean,可惜Variant 中怎么v:=VarCreateVariant([0,n],varBoolean)不会操作 v[10]:=true 这种事情。于是干脆变成了 array of Byte声明了8个array of Byte 阅读全文

posted @ 2013-10-21 14:00 大悟还俗_2 阅读(579) 评论(0) 推荐(0) 编辑

摘要: Longint = IntegerWPARAM = IntegerLPARAM = IntegerLRESULT = IntegerFARPROC = Pointerfunction MakeWord(a, b: Byte): Word;function MakeLong(a, b: Word): Longint;function MakeWParam(l, h: Word): WPARAM;function MakeLParam(l, h: Word): LPARAM;function MakeLResult(l, h: Word): LRESULT;function PointToLP.. 阅读全文

posted @ 2013-10-21 13:53 大悟还俗_2 阅读(385) 评论(0) 推荐(0) 编辑

摘要: 作为指针是相同的,解析的内容,稍微有点区别。var s:String;P:PChar;B:PByte;a:Integer;begins:='1234';P:=PChar(s);//按chr保存for a:=0 to 7 dobeginMemo1.Lines.add(P^);Inc(P);end;B:=PByte(s);//按Byte保存for a:=0 to 7 dobeginMemo1.Lines.add(IntToStr(B^)+','+Chr(B^));Inc(B);end;end; 阅读全文

posted @ 2013-10-21 13:52 大悟还俗_2 阅读(435) 评论(0) 推荐(0) 编辑

摘要: 执行控制台程序并且获得它的输出结果 procedure CheckResult(b: Boolean); begin if not b then Raise Exception.Create(SysErrorMessage(GetLastError)); end; function RunDOS(const Prog, CommandLine,Dir: String;var ExitCode:DWORD): String; var HRead,HWrite:THandl... 阅读全文

posted @ 2013-10-21 13:50 大悟还俗_2 阅读(302) 评论(0) 推荐(0) 编辑

摘要: function PauseConsole(Prompt: PAnsiChar): boolean;varhStdIn, hStdOut: THandle;dwRd, dwWr, i: Cardinal;cBuf: array [0..128] of TInputRecord;beginresult := false;hStdIn := GetStdHandle(STD_INPUT_HANDLE);hStdOut := GetStdHandle(STD_OUTPUT_HANDLE);if ((hStdIn 0) and (hStdOut 0)) thenbeginWriteFile(hSt.. 阅读全文

posted @ 2013-10-21 13:36 大悟还俗_2 阅读(687) 评论(0) 推荐(0) 编辑