![]() |
NativeInt to string
Kann ich NativeInt wie bisher mit IntToStr zu String konvertieren? Oder geht dabei was verloren..
|
AW: NativeInt to string
Kannst du. Unter 64-Bit wird dann die Int64-Variante von IntToStr verwendet.
|
AW: NativeInt to string
Zitat:
|
AW: NativeInt to string
Es stimmt was nicht mehr.
Delphi-Quellcode:
ImgBack: LONG_PTR;
Das ImgBack wird geladen .
Delphi-Quellcode:
ImgBack := SkinEngine.skCreateImageFromFile(SelectedImg);
Delphi-Quellcode:
und in eine TStringList gepackt.
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;
Delphi-Quellcode:
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:
Später lese ich das ImgBack aus den Propertys zurück.
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;
Delphi-Quellcode:
ImgBack := GetProperty(WinHandle, PROP_IMAGE_SELECTED);
Zeichne ich jetzt den Button
Delphi-Quellcode:
und hole mir die Image Größe dann krachts.
SkinEngine.PaintButton(Graphics, 4, ImgBack, Rect.Left,
Rect.Top - (ListItemHeight - 16) div 2, UInt(Rect.Right - FLeft), UInt(ListItemHeight), BS_PUSHBUTTON)
Delphi-Quellcode:
if ImgBack <> 0 then
begin GetImageSize(ImgBack, BackW, BackH);
Delphi-Quellcode:
Die Probleme habe ich nur unter 64Bit und D11.2 vorher unter D11 funktioniert noch alles.
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; |
AW: NativeInt to string
TSplitStrArray sind Strings.
Zitat:
Fazit: Zuerst der String zu Integer NativeInt (weil sonst knallt es mal im 64 Bit) und das dann zum Pointer. Ja, IntToStr gibt es in zwei Varianten, wie dir das CodeInsight und die Hilfe sagen wird. Nur anderstum, muß man es manuell machen, also StrToInt64, weil der Parameter "String" ja identisch wäre. |
AW: NativeInt to string
Zitat:
Delphi-Quellcode:
{$EXTERNALSYM UINT_PTR}
LONG_PTR = NativeInt; |
AW: NativeInt to string
Zitat:
Das wird der Zeiger auf den String, in dem die "Zahl" als Text drin steht, oder nicht? |
AW: NativeInt to string
Zitat:
So funktioniert es nun bis das nächste Problem auftaucht. :)
Delphi-Quellcode:
Danke
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(StrToInt64(SplitProperty[2])); exit; end; end; end; end; |
AW: NativeInt to string
Egal was es für ein Typ ist.
Der "Wert" ist/war die Adresse (Zeiger) des Strings. |
AW: NativeInt to string
Zitat:
Ohne deine Hilfe hätte ich das Problem nicht so schnell gefunden. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:17 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz