Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#20

AW: 2 Arrays vergleichen\sortieren

  Alt 22. Nov 2017, 20:53
Sollte in etwa so aussehen. Ist nur so runtergetippt, also kann noch Fehler enthalten:
Delphi-Quellcode:
function GetObjectOrder(hParent: HWND): LongInt;
var
  pZP, UB, K, nCount: LongInt;
  A1, A2: TArray<ShortInt>;
  buffer: array[0..2048 - 1] of Byte;
begin
  pZP := gPropertyItem(hParent);
  if (pZP > -1) then
  begin
    if (g_Prop[pZP].ordersize > 0) then
    begin
      Exit(pZP);
    end;
  end;

  UB = UBOUND(g_zObj);
  if (UB > 0) then
  begin
    K = 0;
    nCount := 0;
    SetLength(A1, UB);
    SetLength(A2, UB);
    for K := 0 to UB - 1 do
    begin
      if (g_zObj[K].hwned = hParent) then
      begin
        A1[nCount] := SmallInt(g_zObj[K].order);
        A2[nCount] := SmallInt(K);
        nCount := nCount + 1;
      end;
    end;

    SortShortTagArray(A1, A2, nCount);

    ZeroMemory(@buffer[0], SizeOf(buffer));
    for K := 0 to nCount - 1 do
    begin
      CopyMemory(PByte(@buffer[0]) + K * SizeOf(SmallInt), @A2[K], SizeOf(ShortInt));
    end;
    SetLength(A1, 0);
    SetLength(A2, 0);

    if (pZP < 0) then
    begin
      pZP := LongInt(UBOUND(g_Prop));
      g_Prop.resize(pZP + 1);
    end;
    g_Prop[pZP].hWnd := hParent;
    CopyMemory(@g_Prop[pZP].order, @buffer[0], SizeOf(buffer));
    g_Prop[pZP].ordersize := nCount;
  end;
  Result := pZP;
end;
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat