Thema: Delphi NativeInt to string

Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#4

AW: NativeInt to string

  Alt 10. Sep 2022, 15:24
Es stimmt was nicht mehr.

ImgBack: LONG_PTR;

Das ImgBack wird geladen .

ImgBack := SkinEngine.skCreateImageFromFile(SelectedImg);
Delphi-Quellcode:
function TSkinEngine.skCreateImageFromFile(FileName: WideString): LONG_PTR;
var
  Img: LONG_PTR;
begin

  Img := 0;

  if not FileExists(FileName) then
  begin
    Result := 0;
    Exit;
  end;

  //Image laden
  try
    GdipCheck(GdipLoadImageFromFile(PWideChar(FileName), Img));
  finally
    Result := Img;
  end;
end;
und in eine TStringList gepackt.
SetProperty(Handle, PROP_IMAGE_SELECTED, ImgBack);
Delphi-Quellcode:
procedure TSkinListBox.SetProperty(WinHandle: hWnd; Item: Integer; V: LONG_PTR);
begin
  if (Item > 0) and (WinHandle <> 0) then
    PropList.Add(IntToStr(WinHandle) + ',' + IntToStr(Item) + ',' + IntToStr(V));

end;
Delphi-Quellcode:
function TSkinListBox.GetProperty(WinHandle: hWnd; Item: Integer): LONG_PTR;
var
  SplitProperty: TSplitStrArray;
  IntI: Integer;
begin
  Result := 0;

  if (Item > 0) and (WinHandle <> 0) then
  begin
    for IntI := 0 to PropList.Count - 1 do
    begin
      SplitProperty := Split(PropList.Strings[IntI], ',');
      if SplitProperty[0] = IntToStr(WinHandle) then
      begin
        Result := LONG_PTR(SplitProperty[2]);
        exit;
      end;
    end;
  end;

end;
Später lese ich das ImgBack aus den Propertys zurück.

ImgBack := GetProperty(WinHandle, PROP_IMAGE_SELECTED);

Zeichne ich jetzt den Button
Delphi-Quellcode:
          SkinEngine.PaintButton(Graphics, 4, ImgBack, Rect.Left,
            Rect.Top - (ListItemHeight - 16) div 2, UInt(Rect.Right - FLeft), UInt(ListItemHeight),
            BS_PUSHBUTTON)
und hole mir die Image Größe dann krachts.
Delphi-Quellcode:
  if ImgBack <> 0 then
  begin
    GetImageSize(ImgBack, BackW, BackH);
Delphi-Quellcode:
procedure TSkinEngine.GetImageSize(Img: LONG_PTR; var imgW, imgH: UINT);
begin
  if img <> 0 then
  begin
    GdipCheck(GdipGetImageWidth(Img, imgW));
    GdipCheck(GdipGetImageHeight(Img, imgH));
  end;
end;
Die Probleme habe ich nur unter 64Bit und D11.2 vorher unter D11 funktioniert noch alles.

Geändert von venice2 (10. Sep 2022 um 16:16 Uhr)
  Mit Zitat antworten Zitat