लक्ष्य के नजदीक एक तरीका जो आप TWINcontrols के लिए इंटरपोजर कक्षाओं का उपयोग करना होगा और टीसींट्रोल कन्ववास और "हुकिंग" WM_PAINT का उपयोग करके पहले से चित्रित किए जाने के बाद छवि को उनके ऊपर ले जाया जाएगा।
कोड एक semitransparent पीएनजी छवि का उपयोग कर कच्चे मसौदे दिखा रहा है और बढ़ाया जा सकता है।
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, dxGDIPlusClasses, ExtCtrls;
type
TButton=Class (StdCtrls.TButton)
Procedure WMPaint(var MSG:TMessage);Message WM_Paint;
End;
TEdit=Class (StdCtrls.TEdit)
Procedure WMPaint(var MSG:TMessage);Message WM_Paint;
End;
TForm2 = class(TForm)
Image1: TImage;
SpeedButton1: TSpeedButton;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TButton }
procedure TButton.WMPaint(var MSG: TMessage);
var
cc:TControlCanvas;
begin
inherited;
CC:=TControlCanvas.Create;
CC.Control := TControl(Self);
CC.Draw(-Left,-Top,Form2.Image1.Picture.Graphic);
CC.Free;
end;
procedure TEdit.WMPaint(var MSG: TMessage);
var
cc:TControlCanvas;
begin
inherited;
CC:=TControlCanvas.Create;
CC.Control := TControl(Self);
CC.Draw(-Left,-Top,Form2.Image1.Picture.Graphic);
CC.Free;
end;
end.
एक और (बेहतर) जगह "हुक" अधिभावी किया जाएगा PaintWindow
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, dxGDIPlusClasses, ExtCtrls;
type
TButton=Class (StdCtrls.TButton)
procedure PaintWindow(DC: HDC);override;
End;
TEdit=Class (StdCtrls.TEdit)
procedure PaintWindow(DC: HDC);override;
End;
TForm2 = class(TForm)
Image1: TImage;
SpeedButton1: TSpeedButton;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TButton }
procedure TButton.PaintWindow(DC: HDC);
var
cc:TCanvas;
begin
inherited;
CC:=TCanvas.Create;
CC.Handle := DC;
CC.Draw(-Left,-Top,Form2.Image1.Picture.Graphic);
CC.Free;
end;
procedure TEdit.PaintWindow(DC: HDC);
var
cc:TCanvas;
begin
inherited;
CC:=TCanvas.Create;
CC.Handle := DC;
CC.Draw(-Left,-Top,Form2.Image1.Picture.Graphic);
CC.Free;
end;
end.
तो अपने प्रश्न "* है कि कैसे मैं एक TWinControl के सामने एक TImage ला सकता है और साथ ही क्लिक के माध्यम से क्लिक करें? "* (जैसा कि आप जानते हैं कि आप एक छवि पर क्लिक कर सकते हैं।) –
चूंकि TGraphicControl (जैसे TLabel, TImage, TSpeedbutton) से प्राप्त घटकों को उनके माता-पिता डीसी पर चित्रित किया गया है, वहां लाने का कोई तरीका नहीं है ए अपने स्वयं के डीसी के साथ एक TWincontrol के सामने TGraphicControl। – bummi
जैसा कि बुम्मी कहते हैं। आपका 'आगे बढ़ना लेबल के लिए काम करना है' दावा गलत है। –