-
Delphi7利用鼠标绘制矩形焦点的源码
本源代码主要演示Delphi7利用鼠标绘制矩形焦点,画出虚线框矩形,按住鼠标左键抖动矩形区域,即可显示虚线矩形框,可应用于需要拖动选择对象时作为选区使用,在Delphi中,这个功能使用Canvas实现:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if IsDraw then
begin
if Count >1 then
DrawFocusRect(Canvas.Handle,FocuRect);
FocuRect.Right := X;
FocuRect.Bottom := Y;
DrawFocusRect(Canvas.Handle,FocuRect);
Inc(Count);
IsEndDraw := True;
end;
end;
- 2023-02-14 21:35:04下载
- 积分:1
-
Delphi 7.0 使用Quotedstr函数返回字符串的引证串
Delphi 7.0 使用Quotedstr函数返回字符串的引证串,为了演示方便,本程序于SQLSERVER数据库结合,在运行此程序之前,需要附加数据库。具体附加数据库的方法请参见说明书。
- 2023-03-07 09:55:03下载
- 积分: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 改变当前鼠标样式,这个样式比较个性了,把箭头状的鼠标指针替换成了一幅图像,还有动画效果。具体实现,请下载本源码一看究竟。本程序具备的功能是可以选择的,用户可选择改变鼠标的形状是否是当前窗口或系统,选择当前窗口则只会在本测试程序的窗口中改变鼠标的形状。
- 2023-07-31 03:10: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实现圆角的窗体效果,将矩形的窗口效果修饰为圆角的风格,如示例截图所示的效果,核心的几行代码如下:
begin
hr:=createroundrectrgn(0,0,width,height,20,20);//定义园角矩形(win API函数)
setwindowrgn(handle,hr,true); //设置园角窗口
end;
- 2022-08-18 21:29:53下载
- 积分: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 渐变的RGB空心色环绘制源码演示
Delphi渐变圆形的实现方法,RGB色环空心绘制演示源码:
oBmp := TBitmap.Create; //为了代码整齐就不写try了
oBmp.PixelFormat := ABitmap.PixelFormat;
oBmp.Width := ABitmap.Width;
oBmp.Height := ABitmap.Height;
BitBlt(oBmp.Canvas.Handle, 0, 0, oBmp.Width, oBmp.Height, ABitmap.Canvas.Handle, 80, 80, SRCCOPY); //要拷贝的位图
oRgn := CreateEllipticRgn(0, 0, 100, 100); //创建圆形区域
SelectClipRgn(ABitmap.Canvas.Handle, oRgn); //选择剪切区域
ABitmap.Canvas.Draw(0, 0, oBmp); //位图位于区域内的部分加载
- 2022-03-21 13:09:53下载
- 积分: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编写制作一款形象的电子表(钟表)效果,模拟时钟,界面方面做成了圆形,看不见窗口的边框,像是透明的窗口,各个指针会走动,关于各个指针的移动及计算方法,有兴趣可参考:
vh := Hour/12.0*2*Pi;
vm := Min/60.0*2*Pi;
vs := Sec/60.0*2*Pi;
with Canvas do
begin
Pen.Width:=4;
Pen.Color := clBlack;
MoveTo(60,60);
LineTo(60+Round(25*Sin(vh)),60-Round(25*Cos(vh)));
Pen.Width:=2;
Pen.Color := clBlack;
MoveTo(60,60);
LineTo(60+Round(45*Sin(vm)),60-Round(45*Cos(vm)));
Pen.Width:=1;
Pen.Color := clRed;
MoveTo(60,60);
LineTo(60+Round(55*Sin(vs)),60-Round(55*Cos(vs)));
end;
窗体方面:这个圆盘窗口要是能移动就好了,不支持右键菜单,也不能关闭,关闭窗口需要按键盘上的ALT+F4。
- 2022-01-27 12:29:32下载
- 积分:1