-
Delphi 使用ESC键停止循环
Delphi 使用ESC键停止循环,示例演示程序,单击按钮开始循环,按下键盘ESC键,将停止循环。程序核心代码:
begin
for i:= 0 to 9999999 do
begin
Edit1.Text := IntToStr(i);
//允许应用程序在循环中可以处理消息
Application.ProcessMessages;
//用是 ESC 键放弁循环
if GetKeyState(VK_ESCAPE) and 128 = 128 then
Break;
end;
end;
- 2022-03-24 17:07:24下载
- 积分:1
-
Delphi 打印图形(图片)
Delphi 打印图形,把图片打印出来,通过这个例子,你可以学习到:
strect:Trect;//定义打印输出矩形框的大小
temhi,temwd:integer;
begin
if DIGPrint.execute then
begin
temhi:=imgpic.picture.height;
temwd:=imgpic.picture.width;
while (temhi = printer.pageheight div 2)and
//将图形放大到打印页面的1/2大小
(temwd = printer.pagewidth div 2) do
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left := (printer.pagewidth -temwd) div 2;
top := (printer.pageheight-temhi) div 2;
right := left+temwd;
bottom := top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,imgpic.picture.graphic);
enddoc;
end;
end;
- 2022-10-24 23:35:04下载
- 积分:1
-
Delphi演示UniCode编码、简体繁体互转的方法实现
Delphi演示如何实现UniCode编码、汉字的繁简互转功能,同时将字符转换为unicode码值(十六进制):
常用编码:
codepage=936 简体中文GBK
codepage=950 繁体中文BIG5
codepage=437 美国/加拿大英语
codepage=932 日文
codepage=949 韩文
codepage=866 俄文
codepage=65001 unicode UTF-8
本例子中仅使用了936、950,如果你要进行其他语言的编码转换,仅需相应改变其中的编码值即可。
- 2023-06-10 00:30:04下载
- 积分:1
-
使用Delphi 制作无闪烁的动画效果
使用Delphi 制作无闪烁的动画效果,如何实现不闪烁的动画呢?这个例子或许能找到一些答案:部分代码如下:
var
x,i: Integer;
dir,run: Boolean;
begin
b := TBitMap.Create;
b.Width := AnimWindow.Width;
b.Height := 32;
b.Canvas.Pen.Color := clBtnFace;
b.Canvas.Brush.Color := clBtnFace;
b.Canvas.Rectangle(0,0,AnimWindow.Width,32);
run := True;
dir := False;
x := 0;
while run do
for i := 0 to AnimWindow.ImageList1.Count-1 do
begin
b.Canvas.Rectangle(0,0,AnimWindow.Width,32);
AnimWindow.ImageList1.Draw(b.Canvas,x,0,i);
Synchronize(DrawAnimPic);
Sleep(AnimWindow.SpinEdit1.Value);
if (x = 0) or (x = 300) then dir := not dir;
if dir then Inc(x) else Dec(x);
end;
b.Free;
end;
- 2023-03-22 21:40:04下载
- 积分: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 键盘钩子 封锁 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 用获取路径的方法得到圆形窗体
Delphi 用获取路径的方法得到圆形窗体,制作实现一个非矩形窗口,可以说是一个不规则窗口了,圆形的窗口,标题栏、状态栏及窗口关闭等操作按钮均不邮了。圆形窗口的基本实现思路是根据路径创建不规则窗体,然后设置窗口为透明模式,部分代码如下:
dc:=self.Canvas.Handle;
BeginPath(dc);
//根据路径创建不规则窗体
SetBkMode(dc,TRANSPARENT);
//设置为透明模式
Ellipse(dc,20,20,220,220);
EndPath(dc);
region:=PathToRegion(dc);
SetWindowRgn(self.Handle,region,TRUE);
end;
- 2022-05-16 23:17:16下载
- 积分: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为程序添加esc退出程序的功能
本源码演示Delphi如何用ESC键退出程序,为程序添加esc退出程序的功能,一般情况下,关闭程序都是通过ALT+f4或者直接点击窗口右上角的叉子关闭,不过我们也可以为程序添加通过键盘按下ESC键来关闭程序,本源码就是演示了此种功能,当用户按下ESC时,窗口即关闭,程序退出。
- 2022-07-21 22:03:47下载
- 积分:1
-
Delphi7 计算汉字的笔划
Delphi7 计算汉字的笔划有几划,输入一个汉字,本程序将计算出这个字有多少笔划,最后将结果将输出一个整数。
- 2022-12-25 04:20:03下载
- 积分:1