canvas教程

创建不规则形状的Control程序设计

字号+ 作者:H5之家 来源:H5之家 2015-10-31 10:32 我要评论( )

内容提要:;functionTHotTrackImage.DoPaletteChange:Boolean;varParentForm:TCustomForm;Tmp:TGraphic;beginResult:=... ; function THotTrackImage.DoPaletteChange: Boolean; var ParentForm: TCustomForm; Tmp: TGraphic; begin Result := False; Tmp :=

内容提要:;functionTHotTrackImage.DoPaletteChange:Boolean;varParentForm:TCustomForm;Tmp:TGraphic;beginResult:=...

;

function THotTrackImage.DoPaletteChange: Boolean;
var
ParentForm: TCustomForm;
Tmp: TGraphic;
begin
Result := False;
Tmp := FPicture;
if Visible and (not (csLoading in ComponentState)) and (Tmp <> nil) and
(Tmp.PaletteModified) then
begin
if (Tmp.Palette = 0) then
Tmp.PaletteModified := False
else
begin
ParentForm := GetParentForm(Self);
if Assigned(ParentForm) and ParentForm.Active and Parentform.HandleAllocated then
begin
if FDrawing then
ParentForm.Perform(wm_QueryNewPalette, 0, 0)
else
PostMessage(ParentForm.Handle, wm_QueryNewPalette, 0, 0);
Result := True;
Tmp.PaletteModified := False;
end;
end;
end;
end;

function THotTrackImage.GetCanvas: TCanvas;
begin
Result := FPicture.Canvas;
end;

function THotTrackImage.GetPalette: HPALETTE;
begin
Result := FPicture.Palette;
end;

{procedure THotTrackImage.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);

procedure ReSearch;
var
P:TPoint;
I:Integer;
TempHK:TControl;
begin
for I:=0 to Parent.ControlCount-1 do
begin
TempHK:=Parent.Controls[I];
if TempHK is THotTrackImage then
begin
if not THotTrackImage(TempHK).FSearching1 then
begin
P.X:=X;
P.Y:=Y;
P:=THotTrackImage(TempHK).ScreenToClient(ClientToScreen(P));
THotTrackImage(TempHK).MouseDown(Button,Shift,P.X,P.Y);
Exit;
end;
end;
end;
end;

begin
if not FSearching1 then
begin
FSearching1:=True;
try
if (X>=0)and(X<FPicture.Width)and(Y>=0)and(Y<FPicture.Height) then
begin
if FPicture.Canvas.Pixels[X,Y]=FPicture.Canvas.Pixels[0,0] then
begin
ReSearch;
end else
begin
inherited;
end;
end else
begin
ReSearch;
end;
finally
FSearching1:=False;
end;
end;
end;}

{procedure THotTrackImage.MouseMove(Shift: TShiftState; X, Y: Integer);

procedure ReSearch;
var
P:TPoint;
I:Integer;
TempHK:TControl;
begin
for I:=0 to Parent.ControlCount-1 do
begin
TempHK:=Parent.Controls[I];
if TempHK is THotTrackImage then
begin
if not THotTrackImage(TempHK).FSearching then
begin
P.X:=X;
P.Y:=Y;
P:=THotTrackImage(TempHK).ScreenToClient(ClientToScreen(P));
THotTrackImage(TempHK).MouseMove(Shift,P.X,P.Y);
Exit;
end;
end;
end;
end;

procedure Slicen;
var
I:Integer;
TempHK:TControl;
begin
for I:=0 to Parent.ControlCount-1 do
begin
TempHK:=Parent.Controls[I];
if TempHK<>Self then
begin
THotTrackImage(TempHK).SetHoted(False);
end;
end;
end;

begin
if not FSearching then
begin
FSearching:=True;
try
if (X>=0)and(X<FPicture.Width)and(Y>=0)and(Y<FPicture.Height) then
begin
if FPicture.Canvas.Pixels[X,Y]=FPicture.Canvas.Pixels[0,0] then
begin
SetHoted(False);
ReSearch;
end else
begin
SetHoted(True);
Slicen;
inherited;
end;
end else
begin
SetHoted(False);
ReSearch;
end;
finally
FSearching:=False;
end;
end;
end;}

{procedure THotTrackImage.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);

procedure ReSearch;
var
P:TPoint;
I:Integer;
TempHK:TControl;
begin
for I:=0 to Parent.ControlCount-1 do
begin
TempHK:=Parent.Controls[I];
if TempHK is THotTrackImage then
begin
if not THotTrackImage(TempHK).FSearching2 then
begin
P.X:=X;
P.Y:=Y;
P:=THotTrackImage(TempHK).ScreenToClient(ClientToScreen(P));
THotTrackImage(TempHK).MouseUp(Button,Shift,P.X,P.Y);
Exit;
end;
end;
end;
end;

begin
if not FSearching2 then
begin
FSearching2:=True;
try
if (X>=0)and(X<FPicture.Width)and(Y>=0)and(Y<FPicture.Height) then
begin
if FPicture.Canvas.Pixels[X,Y]=FPicture.Canvas.Pixels[0,0] then
begin
ReSearch;
end else
begin
inherited;
end;
end else
begin
ReSearch;
end;
finally
FSearching2:=False;
end;
end;
end;}

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 可创建gooey效果抖动窗口的jquery插件

    可创建gooey效果抖动窗口的jquery插件

    2017-04-15 10:00

  • 创建和导出SVG的技巧

    创建和导出SVG的技巧

    2017-04-03 16:05

  • 如何创建嬉皮士货车海报.doc 全文免费在线阅读

    如何创建嬉皮士货车海报.doc 全文免费在线阅读

    2017-03-04 15:02

  • uGUI 系统的介绍与创建 Canvas 画布

    uGUI 系统的介绍与创建 Canvas 画布

    2017-02-24 14:02

网友点评