设置屏幕分辨率的函数 - 回复 "董勇" 的问题 3 days ago Read More
{函数}
function SetScreen(x,y: Word): Boolean;
var
DevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, DevMode);
if Result then
begin
DevMode.dmFields := DM_PELSWIDTH or DM_PELSHE...
获取各种编码的识别符 3 days ago Read More
下面是常用编码的识别符, 在 Delphi(2009) 中如何获取呢?
Unicode: FF FE; BigEndianUnicode: FE FF; UTF8: EF BB BF
var
bs: TBytes;
b: Byte;
str: string;
begin
{只有 Unicode、BigEndianUnicode、UTF8 编码有识别符}
bs := TEncodi...
汉字与区位码(转换函数) 3 days ago Read More
先上转换函数:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
...
一个可以显示多边形的 TMyShape 类 - 回复 "董勇" 的问题 4 days ago Read More
测试效果图:
自定义的 MyShape 单元:
unit MyShape;
interface
uses
Windows, Classes, Graphics, Controls;
type
TMyShapeType = (stRectangle, stSquare, stRoundRect, stRoundSquare,
stEllipse, stCircle, stPolygon)...
Delphi 的内存操作函数(6): 跨进程的内存分配 7 days ago Read More
Delphi 为我们提供了三个方便的函数:
GlobalAllocPtr {简化自 API 的 GlobalAlloc}
GlobalReAllocPtr {简化自 API 的 GlobalReAlloc}
GlobalFreePtr {简化自 API 的 GlobalFree}
这些函数读写本程序以外的数据, 使用也很方便, 譬如:
p := GlobalAllocPtr(0, Len)...
Delphi 中的 IfThen 函数 - 回复 "深挖洞、广积粮" 的问题 8 days ago Read More
问题来源: http://www.cnblogs.com/del/archive/2008/11/14/1120015.html#1370413
StrUtils 单元和 Math 单元 分别有一个 IfThen 函数, 举例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphi...
Delphi 的内存操作函数(5): 复制内存 8 days ago Read More
MoveMemory、CopyMemory 的功能是一模一样的, 都是复制内存, 都是调用 Move 过程;
MoveMemory、CopyMemory 操作指针; Move 操作实体.
举例:
{例1}
var
buf1,buf2: array[0..9] of AnsiChar;
begin
buf1 := '0123456789';
buf2 := 'abcdefghij';
...
Delphi 的内存操作函数(4): 清空与填充内存 8 days ago Read More
FillMemory、ZeroMemory 一目了然的两个函数, 但其实它们都是调用了 FillChar;
清空不过就是填充空字符(#0: 编号为 0 的字符), 说来说去是一回事.
为了下面的测试, 先写一个以十六进制方式查看内存的函数:
function GetMemBytes(var p; size: Integer): string;
var
pb: PByte;
i: Int...
在 Delphi 2009 中, for in 循环都能用在什么地方? 10 days ago Read More
一、遍历 TStrings
var
List: TStrings;
s: string;
begin
List := TStringList.Create;
List.CommaText := 'aaa,bbb,ccc';
for s in List do
ShowMessage(s);
List.Free;
end;
二、遍历数组
var
Arr: array[0..2]...