-
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 单击StringGrid列进行排序
Delphi 单击StringGrid列进行排序,StringGrid行的任意列单击,就会重新排序一次,排序规则可以自己定义,这种排序功能可有效提升StringGrid显示数据的易用性,增强其功能,提升用户体验,本例子源代码相当简单,对学习者也有很好的帮助作用。参见以下代码:
begin
if Button = mbRight then Exit;
TStringGrid(Sender).MouseToCell(X, Y, vCol, vRow);
if (vRow < 0) or (vRow >= TStringGrid(Sender).FixedRows) then Exit;
StringGridRowSort(TStringGrid(Sender), vCol, vOldCol = vCol);
if vOldCol = vCol then
vOldCol := - vOldCol
else
vOldCol := vCol;
end;
- 2022-05-29 23:30:47下载
- 积分:1
-
Delphi 限制窗口最大化显示
Delphi 限制窗口最大化显示,当用户单击最大化按钮后,窗口稍微变大了一点,但并没有最大化,有时候,我们需要限制,不让窗口最大化,在编写实现此功能时,定义了WMGetMinMaxInfo,以下代码在函数中定义,用户操作按钮,激活函数:
with Message.MinMaxInfo^ do
begin
ptMaxSize.X := 400; //最大化时宽度
ptMaxSize.Y := 300; //最大化时高度
ptMaxPosition.X := 120; //最大化时左上角横坐标
ptMaxPosition.Y := 120; //最大化时左上角纵坐标
end;
Message.Result := 0; //通知Windows改变了minmaxinfo
- 2022-01-24 18:38:10下载
- 积分:1
-
Delphi 7.0 After提取字符串中指定子字符串后的字符串
Delphi 7.0 提取字符串中指定子字符串后的字符串,这个平时在字符处理时候使用几率也挺高的,获取指定字符串后面的字符串,比如获取扩展名等也可以用此方法,本例中要用到After函数,测试时,当单击按钮时,执行以下代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit3.Text := After(Edit2.Text,Edit1.Text);
end;
end.
- 2022-03-28 10:50:27下载
- 积分:1
-
Delphi 获取全球标准时间
Delphi 通过网络获取全球标准时间,我们知道在Windows中有三个全球标准时间服务器,若你的电脑设置为自动更新时间,则系统自动会从这三台时间服务器中更新时间,你的电脑就不用自己校对时间了。本程序就是演示,用Delphi编写代码,去连接全球时间服务器,校对时间并更新系统时间的例子,你可通过本源码了解一下时间更新的问题。
- 2023-02-03 13:05:04下载
- 积分: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 Canvas.Brush为窗体绘制渐变背景
Delphi 为窗体绘制渐变背景,这里使用了Delphi中的Canvas.Brush.Color来实现窗口背景的渐变色,不错吧?如示例图的左右渐变效果,实现的代码:
for i:=0 to self.Width-1 do
begin
c1:=GetRValue(StartColor)+Trunc(i*(GetRValue(EndColor)-GetRValue(StartColor))/(self.Width-1));
c2:=GetGValue(StartColor)+Trunc(i*(GetGValue(EndColor)-GetGValue(StartColor))/(self.Width-1));
c3:=GetBValue(StartColor)+Trunc(i*(GetBValue(EndColor)-GetBValue(StartColor))/(self.Width-1));
Canvas.Brush.Color:=RGB(c1,c2,c3);
//每次画矩形的画刷颜色
Dct:=Rect(i,0,i+1,self.Height);
//每次刷绘的矩形区域
Canvas.FillRect(Dct);
//填充颜色
end;
- 2022-05-24 21:26:59下载
- 积分:1
-
Delphi 变速齿轮# 让时间变快减慢
Delphi 变速齿轮# 让时间变快减慢,其实这个似乎是做不到的,只是模拟一下,代码及描述如下:
procedure Speed(count:word); stdcall;
const ExceptionUsed = $03; { 中断号也可以用其它的中断号}
var
IDT : array [0..5] of byte; { 保存中断描述符表}
lpOldGate : dword; {存放旧向量}
begin
asm
push ebx
sidt IDT {读入中断描述符表}
mov ebx, dword ptr [IDT+2]{IDT表基地址}
add ebx, 8*ExceptionUsed {计算中断在中断描述符表中的位置}
cli {关中断}
mov dx, word ptr [ebx+6] {取6,7字节 另外4字节用于门属性和选择子 }
shl edx, 16d {左移16位}
mov dx, word ptr [ebx] {取1,2字节 }
mov [lpOldGate], edx {保存旧的中断门}
mov eax, offset @@Ring0Code {修改向量,指向Ring0级代码段}
mov word ptr [ebx], ax {低16位,保存到1,2字}
shr eax, 16d
mov word ptr [ebx+6], ax {高16位,保存到6,7位}
int ExceptionUsed {发生中断}
mov ebx, dword ptr [IDT+2] {重新定位到中断描述符表中}
add ebx, 8*ExceptionUsed
mov edx, [lpOldGate]
mov word ptr [ebx], dx
- 2023-02-13 04:55:03下载
- 积分:1
-
Delphi 利用API绘制弧形
Delphi 利用API绘制弧形,
begin
ArcRect := ClientRect;
Canvas.Pen.Width:=2;
for i:=1 to 10 do
begin
Arc(Canvas.Handle,ArcRect.Left,ArcRect.Top,ArcRect.Right,
ArcRect.Bottom,ArcRect.Right,(ArcRect.Bottom-ArcRect.Top) div 2,
ArcRect.Left,(ArcRect.Bottom-ArcRect.Top) div 2);
InflateRect(ArcRect,-2,-2);
Canvas.Pen.Color := PaletteIndex(i+10);
end;
- 2022-03-21 03:44:09下载
- 积分:1
-
Delphi 屏蔽键盘 sleep和wake up键
如何屏蔽sleep和wake up键,一个是待机键,一个是唤醒键,屏蔽可有效避免误操作,不过本代码过于简单,屏蔽效果有待测试,核心代码如下:
procedure TForm1.WMPowerBroadcast(var message: TMessage);
begin
message.Result := BROADCAST_QUERY_DENY;
end;
- 2022-06-30 14:51:25下载
- 积分:1