-
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 键盘钩子 封锁 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
-
Delphi7 向XML中添加RTTI信息
Delphi7.0 向XML中添加RTTI信息,这个例子挺简单,希望大家喜欢,面向Delphi新手的,高手请绕道哦,下面是本例Delphi向XML中添加RTTI信息的关键性代码:
procedure TForm1.ComponentToDOM(iNode: IXmlNode; Comp: TPersistent);
var
nProps, i: Integer;
PropList: PPropList;
Value: Variant;
newNode: IXmlNode;
begin
nProps := GetTypeData (Comp.ClassInfo)^.PropCount;
GetMem (PropList, nProps * SizeOf(Pointer));
try
GetPropInfos (Comp.ClassInfo, PropList);
for i := 0 to nProps - 1 do
begin
Value := GetPropValue (Comp, PropList [i].Name);
NewNode := iNode.AddChild(PropList [i].Name);
NewNode.Text := Value;
if (PropList [i].PropType^.Kind = tkClass) and (Value 0) then
if TObject (Integer(Value)) is TComponent then
NewNode.Text := TComponent (Integer(Value)).Name
else
ComponentToDOM (newNode, TObject (Integer(Value)) as TPersistent);
end;
finally
FreeMem (PropList);
end;
end;
- 2022-01-26 03:00:57下载
- 积分:1
-
Delphi 让组件拖动窗体 按钮拖动窗口移动
Delphi 让组件拖动窗体 按钮拖动窗口移动,如图所示的窗口中,用户只需按住按钮,即可将整个窗口在屏幕上随意拖动,实现了如何用组件来移动窗体的功能。下面是相关代码:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=MBLeft then
begin
releasecapture;
PerForm(WM_SYSCOMMAND,$F012,0);
end;
end;
- 2023-03-07 20:25:03下载
- 积分:1
-
Delphi 如何使程序不出现在任务栏上
Delphi 如何使程序不出现在任务栏上,常规情况下,运行的程序都会在任务栏有一个图标窗口,方便用户操作,不出现在任务栏上也可以,不过不太符合常规,有点隐藏程序的嫌疑,以下代码是实现此功能的:
procedure TForm1.FormCreate(Sender: TObject);
begin
with Application do
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE) and not WS_EX_APPWINDOW or WS_EX_TOOLWINDOW);
SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
end;
- 2023-03-26 04:55:03下载
- 积分:1
-
Delphi 修改网络设置DNS地址
Delphi 修改网络设置DNS地址,这个修改DNS程序是通过修改注册表的方法来修改。修改前先获取到系统安装的网卡信息,由用户指定待修改的新DNS地址,输入地址框,单击“修改”按钮即可完成修改。因此通过本程序,你可以了解许多注册表方面的操作技巧,以及网络设置相关知识。
- 2022-02-14 09:59:16下载
- 积分:1
-
Delphi 在图片中写入文字
在图片中写入文字(写入文字后按回车键),Delphi 图片合成 效果,图片与字符的合并,在图片中写入文字,就像PhotoShop中完成的效果,有兴趣的参考源码吧。
- 2023-03-24 10:00:04下载
- 积分: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 计算1到10之间的奇数和【源码】
Delphi 推荐到奇数,并计算1到10之间的奇数求和,这是个简单的数学问题,数学水平高,写出这种小程序并不难,趁机把代码帖出来吧:
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
j:=0;
For i := 1 to 10 do
begin
if i mod 2 =0 then
Continue;
j := j+i;
Edit1.text := IntToStr(j);
end;
end;
- 2023-02-23 03:45:04下载
- 积分:1
-
Delphi 枚举线程示例
枚举线程的Delphi实例代码,Delphi 枚举线程的例子应该很多了,这一个比较简单的那种,可以为学习Delphi的新手朋友提供一些参考思路,运行界面效果如下图所示。源代码编译于Delphi7.0环境。
- 2022-08-16 10:03:07下载
- 积分:1