Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Di 25.04.06 17:07 
Hi @all,

ich habe mal wieder ein kleines Problem. Und zwar schreibe ich mir momentan Klassen, die von TObject abgeleitet sind. Da diese jedoch ggf. Messages abfangen können sollen, bleibt mir ja nix anders übrig als mit ein Handle von Windows gegeben zu lassen. Nur wie mache ich das? Denn mit dem Code von TWinControl komme ich nicht klar (wo es sein Händle bekommt), da dort ein paar Befhele drin sind, die mir nichts sagen und auhc nicht in der Delphi-Hilfe erklärt sind.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TWinControl.CreateHandle;
var
  I: Integer;
begin
  if FHandle = 0 then
  begin
    CreateWnd;
    SetProp(FHandle, MakeIntAtom(ControlAtom), THandle(Self));
    SetProp(FHandle, MakeIntAtom(WindowAtom), THandle(Self));
    if Parent <> nil then
      SetWindowPos(FHandle, Parent.PrecedingWindow(Self), 0, 0, 0, 0,
        SWP_NOMOVE + SWP_NOSIZE + SWP_NOACTIVATE);
    for I := 0 to ControlCount - 1 do
      Controls[I].UpdateAnchorRules;
  end;
end;


Was genau MakeIntAtom bedeutet habe ich bsierh nicht gefunden, genauso wie bei SetProp, also welche Eigenschaften er setzt.
Wisst ihr was die Befhele genau bedeuten und wie man für eine Klasse, die keine Oberfläche hat, nen Handle besorgt?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 25.04.06 19:14 
Ein Fenster-Handle kannst Du mit CreateWindow anlegen. von der VCL wird das sehr bescheuert gekapselt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 25.04.06 22:08 
Ein Handle kann man nicht erzeugen. Ein Handle wird von Windows deinem Objelt/Fenster zugewiesen.
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 26.04.06 06:04 
user profile iconLuckie hat folgendes geschrieben:
Ein Handle kann man nicht erzeugen. Ein Handle wird von Windows deinem Objelt/Fenster zugewiesen.


Ist schon klar, mit erzeugen meine ich hier, wie man es bekommt.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 26.04.06 09:26 
Am einfachsten per AllocateHWnd - die VCL erzeugt dabei pe CreateWindowEx ein unsichtbares und ersetzt die WndProc dieses Fensters per Subclassing durch die übergebene TWndMethod wobei die übergebene TWndMethod eine Methode deiner Klasse ist.
Freigeben einfach per DeallocateHWnd.

Gruß, Motzi

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!