was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

29 Visitors Online


 
...einen in einer DLL gespeicherten Control erzeugen?
Autor: Lüpher Cypher
[ Tip ausdrucken ]  

Tip Bewertung (15):  
     


// In DLL
//
// This is our windowed control, which also
// contains more windowed controls within itself

type
TMyPanel = class(TPanel)
fSomeControl: tMyWinControl;

constructor Create(aOwner: TComponent); override;
procedure updateControls();
end;...

// Initialize properties here
constructor TMyPanel.Create(aOwner: TComponent);
begin
inherited
Create(aOwner);
...end;

// This method adds this control to its parent
// and initializes and adds its own controls
procedure TMyPanel.updateControls();
begin
// Now, here we have to set ParentWindow,
// because this control is in a DLL.
// Doing it otherwise will cause "Control
// has no parent window" error.
// We do it before we assign Parent (if we)
// assign Parent first, the assignment
// to ParentWindow will have no effect.
// After these two assignments, our
// control is contained within its parent
// so, we setup the parent dependant
// properties now, such as align
Self.ParentWindow := TWinControl(Owner);
Self.Parent := TWinControl(Owner);
Self.Align = alLeft;
...fSomeControl := TMyWinControl.Create(Self);
fSomeControl.ParentWindow := Self.Handle;
fSomeControl.Parent := Self;
fSomeControl.Align := alTop;
// init more properties
...end;


// In application
//

...MyPanel := TMyPanel.Create(Form1);

MyPanel.updateControls();

// Note that if we created the TMyPanel object in
// DLL (e.g. with a call to a function that
// returned the object), we should destroy it
// in DLL, too, to avoid the access violation.


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners