-
Delphi 与Java TCPIP通信的范例
这个Delphi例子我觉得值得看,用Java写了TCPIP通信的服务端,用Delphi写了客户端,两者在不同的语言环境下运行,并建立TCPIP通信,服务端的运行效果如示例截图所示。为了不发生消息乱码的现象,两者程序编码采用UTF8格式,用UTF-8格式发送出去,收到的UTF-8数据转成ANSI,这一部分的参考请参见util_utf8.pas文件,消息发送、服务器建立连接部分,请参见Unit1.pas文件。
- 2022-08-23 01:44:09下载
- 积分:1
-
Delphi 使同类的组件进行同样的操作
Delphi 使同类的组件进行同样的操作的一个实例,类似于将WEB表单统一清空的功能,点击按钮后,所有文本框组件的内容被清空,作用在相同的组件实例上,代码:
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ClearText : Integer;
begin
For ClearText := 0 to Form1.ComponentCount -1 do
begin
//判断如果窗体中包含文本框组件,则将所有文本框组件的内容清空
if Form1.Components[ClearText] is TEdit then
begin
TEdit(Components[ClearText]).Clear;
end;
end;
end;
- 2022-05-23 05:25:03下载
- 积分:1
-
Delphi 键盘钩子 封锁 windows 热键
Delphi 键盘钩子 封锁 windows 热键,封锁范围,可参见以下代码:
keycost := LPKBDLLHOOKSTRUCT(lParam);
if (keycost.vkCode=91) then//封锁win键
exit;
if (keycost.vkCode=VK_ESCAPE) and (GetAsyncKeyState(VK_CONTROL)0) then
exit; //封锁 ALT+TAB
if (keycost.vkCode=115) and ((keycost.flags and LLKHF_ALTDOWN)>0) then
exit; //封锁 ALT+F4
if (keycost.vkCode=VK_ESCAPE) and ((keycost.flags and LLKHF_ALTDOWN)>0) then
exit; //封锁 ALT+ESC
if (keycost.vkCode=VK_SPACE) and (GetAsyncKeyState(VK_CONTROL)
- 2023-03-30 06:05:03下载
- 积分:1
-
Delphi 演示0~N位数的任意组合
Delphi 数列的排列组合一例,演示0~N位数的任意组合,组合的数字在0~5之间,需要输入1~6整数,排列结果会显示在文本框组件中。要点代码如下:
ssList := TStringList.Create;
try
if (nBase < 1) then
begin
end
else
begin
if (sList.Count = 0) then
begin
for nIdx := 0 to num-1 do
ssList.Add(a[nIdx]);
end
else
begin
for nIdx := 0 to num-1 do
for nSidx := 0 to sList.Count-1 do
if (Pos(a[nIdx], sList.Strings[nSidx]) = 0) then
ssList.Add(a[nIdx]+sList.Strings[nSidx]);
end;
Combine(nBase-1, ssList);
end;
if ssList.Count > 0 then
begin
sList.Clear;
sList.Text := ssList.Text;sslist.Count
end;
finally
ssList.Free;
end;
- 2022-04-29 16:59:03下载
- 积分:1
-
Delphi 简单获取Windows时间的例子
简单获取Windows时间-Delphi源代码,改时间的小程序,在Windows自带的时间管理中也可完成系统时间的修改,这个只是一个帮助了解Windows与Delphi编程的例子,如何通过Delphi的程序来修改Windows时间,大致就是这样实现的。可参见以下源码:
procedure TForm1.Button1Click(Sender: TObject);
var
Dtimer : TSystemTime;
hh,Ghh : Integer;
begin
hh := StrToInt(Trim(Edit4.Text));
if hh < 8 then
Ghh := 16 + hh
else
Ghh := hh - 8;
with Dtimer do
begin
wYear:=StrToInt(Edit1.Text);
wMonth:=StrToInt(Edit2.Text);
wDay:=StrToInt(Edit3.Text);
wHour:=Ghh;
wMinute:=StrToInt(Edit5.Text);
wSecond:=StrToInt(Edit6.Text);
end;
SetSystemTime(Dtimer);
end;
- 2022-07-09 18:55:23下载
- 积分:1
-
Delphi 控制Canvas上的直线点跟随鼠标移动
Delphi 怎样让Canvas上直线的一个端点跟着鼠标跑,控制Canvas上的直线点跟随鼠标移动,其实这就是画线的基本方法,直线的一端确定后,另一端需要鼠标移动来指定端点,本程序的功能就是让线段的另一头跟随鼠标移动,以确定线段的最终位置。
- 2022-02-25 18:56:03下载
- 积分:1
-
Delphi 绘制艺术图案
Delphi 绘制标准的艺术图案,是比较有规则的几何图案,如示例截图所示的样式 。
self.ClientHeight:=200;
self.ClientWidth:=200;
r:=self.ClientWidth/2;
Sect:=20;
for i:=0 to Sect-1 do
begin
x[i]:=Trunc(r*Cos(i*2*PI/Sect)+self.ClientWidth/2);
y[i]:=Trunc(r*Sin(i*2*PI/Sect)+self.ClientHeight /2);
end;
- 2022-01-28 10:36:40下载
- 积分:1
-
Delphi 不使用标题栏移动窗体
Delphi 不使用标题栏移动窗体,意思是说,平时大家拖动Windows窗口的时候,都是鼠标放在窗口的标题栏上,按住鼠标左键拖动窗体,但本源码实现的功能是,不以标题栏为操作目标,那是怎么实现的窗口拖动呢?请下载参见本源码。
- 2022-10-18 04:15:03下载
- 积分:1
-
Delphi 实现图像热点功能
Delphi 实现图像热点功能,实现一张图片上不同形状区域的热点,定义椭圆形、四边形、三角形的区域变量的热点,相关代码如下:
var
thepoint:array [1..8] of tpoint;//存储多边形顶点坐标
count:integer;
pointnum:array [1..2] of integer;
begin
//四边形顶点坐标,首末点封闭
thepoint[1]:=point(135,99);
thepoint[2]:=point(105,183);
thepoint[3]:=point(129,201);
thepoint[4]:=point(188,92);
thepoint[5]:=point(135,99);
count:=5;//四边形顶点数目,首末点为一点
fourE_rgn:=CreatePolygonRgn(thepoint,count,WINDING);//生成四边形区域
elli_rgn:=CreateEllipticRgn(64,221,231,263);// 生成椭圆形区域
//第一个三角形顶点坐标
thepoint[1]:=point(118,67);
thepoint[2]:=point(32,28);
thepoint[3]:=point(17,90);
thepoint[4]:=point(118,67);
//第二个三角形顶点坐标
thepoint[5]:=point(155,44);
thepoint[6]:=point(202,91);
thepoint[7]:=point(277,44);
thepoint[8]:=point(155,44);
pointnum[1]:=4;//第一个三角形顶点数目
pointnum[2]:=4;//第二个三角形顶点数目
count:=2;//三角形数目
//生成由两个三角形构成的三角形区域
tri_rgn:=CreatePolyPolygonRgn(thepoint,pointnum,count,WINDING);
end;
- 2022-01-26 08:02:50下载
- 积分:1
-
Delphi API笔刷制作源码
Delphi API笔刷制作实例的源码,这个笔刷只不过比较简单,点击按钮后自动生成,而且是有规则的网格线,或许通过这个简单的笔刷,你可以学习到用Delphi制作笔刷的入门技巧,相关的代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
LogBrush:TLogBrush;
begin
LogBrush.lbStyle:=BS_HATCHED;
LogBrush.lbColor:=clRed;
LogBrush.lbHatch:=HS_DIAGCROSS;
Canvas.Brush.Handle := CreateBrushIndirect(LogBrush);
Canvas.FillRect(ClientRect);
end;
- 2022-03-30 01:57:49下载
- 积分:1