Autor Beitrag
delphinia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Sa 24.04.04 11:37 
Hi

ich bin eigentlich eine ziemliche Anfängerin in Delphi
bin erst seit einem halben Jahr dabei!

Nun meine Bitte an Euch..

erklärt mir doch mal bitte Schritt für schritt den unten stehenden Quellcode

Das wäre echt nett von Euch!


CODE:


Zitat:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
procedure SaveListItemPosition(LVH : THandle; RemoteAddr : Pointer); 
var 
lvi : TLVITEM; 
lenlvi : integer; 
nb : integer; 
buffer : array [0..MAX_PATH] of char; 
Base : Pointer; 
Base2 : PByte; 
i, ItemsCount : integer; 
Apoint : TPoint; 
key : HKEY; 
Dummy : integer; 
begin 
ItemsCount := SendMessage(LVH, LVM_GETITEMCOUNT, 0, 0); 
Base := RemoteAddr; 
lenlvi := SizeOf(lvi); 
FillChar(lvi, lenlvi, 0); 
lvi.cchTextMax := 255; 
lvi.pszText := Base; 
inc(lvi.pszText, lenlvi); 

WriteToRemoteBuffer(@lvi, Base, 255); 

Base2 := Base; 
inc(Base2, Lenlvi); 

RegDeleteKey(HKEY_CURRENT_USER, RegSubKeyName); 

RegCreateKeyEx(HKEY_CURRENT_USER, 
PChar(RegSUbKeyName), 
0, 
nil, 
REG_OPTION_NON_VOLATILE, 
KEY_SET_VALUE, 
nil, 
key, 
nil); 

for i := 0 to ItemsCount - 1 do 
begin 
nb := SendMessage(LVH, LVM_GETITEMTEXT, i, LParam(Base)); 

ReadRemoteBuffer(Base2, @buffer, nb + 1); 
FillChar(Apoint, SizeOf(Apoint), 0); 

WriteToRemoteBuffer(@APoint, Base2, SizeOf(Apoint)); 
SendMessage(LVH, LVM_GETITEMPOSITION, i, LParam(Base) + lenlvi); 

ReadRemoteBuffer(Base2, @Apoint, SizeOf(Apoint)); 
RegSetValueEx(key, @buffer, 0, REG_BINARY, @Apoint, SizeOf(APoint)); 
end; 
RegCloseKey(key); 
end;



es handelt sich um den Code aus dem Tipp
www.swissdelphicente...showcode.php?id=1897

Moderiert von user profile iconPeter Lustig (12:41, 24.04.2004): Topic verschoben
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Di 25.07.06 19:57 
niemand der das kann/Mag?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 25.07.06 20:01 
Was genau interessiert dich?

_________________
Markus Kinzler.
delphinia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131

XP Pro Sp2
Delphi 5 Standard
BeitragVerfasst: Di 25.07.06 20:02 
ganz ehrlich? alles. Vorallem aber die Geschichte mit dem Buffer!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 25.07.06 22:10 
Ich erlaub mir mal, das zu formatieren:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
Procedure SaveListItemPosition(LVH: THandle; RemoteAddr: Pointer);
Var
    lvi: TLVITEM; //keine ahnung was ein TLVITEM ist.
    lenlvi: integer;
    nb: integer;
    buffer: Array[0..MAX_PATH] Of char; //der buffer dient meist zum zwischenspeichern. das array of char ist
            //praktisch wie ein string, eben eine reihe von buchstaben/zeichen
    Base: Pointer; //Ein Pointer ist ein Zeiger auf eine Adresse im Speicher. Kann zum beispiel auf ein Objekt zeigen.
    //hast du für ein Objekt den Speicherbereich von adresse 000000 bis 001000 dann würde der Zeiger den Wert
    //001000 erhalten. Hierzu hat Luckie ein tutorial glaub ich, einfach mal google/DF suchen.
    Base2: PByte; //würd ich jetzt vermuten, dass das P auf Pointer hinweist ... :/
    i, ItemsCount: integer;
    Apoint: TPoint; //TPoint ist ein Punkt. APoint.X ist integer, APoint.Y ist integer, das ist alles.
    key: HKEY; //Guuuute frage ...
    Dummy: integer; //Dummy weist darauf hin, dass eine Procedur einen var parameter verlangt, den man nicht braucht.
Begin
    ItemsCount := SendMessage(LVH, LVM_GETITEMCOUNT, 0, 0); //sendmessage sendet eine nachricht an ein Fenster.
    //Das Fenster ist im Handle definiert, das hier LVH ist. Das Handle ist eine Zahl die jedes Programm von Windows
    //zugewiesen bekommt.
    Base := RemoteAddr; //wer weis das schon ... 8(
    lenlvi := SizeOf(lvi); //sizeof gibt die größe von z.B. einer Datei oder..
    //glaub dem speicherbereich eines objekts (?) zurück
    FillChar(lvi, lenlvi, 0); //naja.. haut halt ein Zeichen an eine bestimmte stelle.
    lvi.cchTextMax := 255;
    lvi.pszText := Base;
    inc(lvi.pszText, lenlvi);

    WriteToRemoteBuffer(@lvi, Base, 255);

    Base2 := Base;
    inc(Base2, lenlvi); //bis hier her: tja... frag jemand anders.. ^^

    RegDeleteKey(HKEY_CURRENT_USER, RegSubKeyName); //löscht einen schlüssel in der Registry, vermute ich ^^

    RegCreateKeyEx(HKEY_CURRENT_USER, //erstellt diesen wieder.
        PChar(RegSubKeyName),
        0,
        Nil,
        REG_OPTION_NON_VOLATILE,
        KEY_SET_VALUE,
        Nil,
        key,
        Nil);

    For i := 0 To ItemsCount - 1 Do
    Begin
        nb := SendMessage(LVH, LVM_GETITEMTEXT, i, LParam(Base));

        ReadRemoteBuffer(Base2, @buffer, nb + 1);
        FillChar(Apoint, SizeOf(Apoint), 0);

        WriteToRemoteBuffer(@Apoint, Base2, SizeOf(Apoint));
        SendMessage(LVH, LVM_GETITEMPOSITION, i, LParam(Base) + lenlvi);

        ReadRemoteBuffer(Base2, @Apoint, SizeOf(Apoint));
        RegSetValueEx(key, @buffer, 0, REG_BINARY, @Apoint, SizeOf(Apoint));
    End;
    RegCloseKey(key);
End;

Alles was ich weis, hab ich auch gleich kommentiert. Ist nicht grade viel, aber jetzt ist der Code wenigstens leserlich und die Leute haben mehr spaß am angucken :D

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.