![]() |
Direct2D Anwendung
Hallo zusammen,
ich experimentiere mit Direct2D und in diesem Zusammenhang fehlen mir die Units Winapi.DWrite.pas und Winapi.DWrite1.pas, um auch Text ausgeben zu können. Die sind in der Community Edition leider nicht vorhanden. Kann mir jeman vielleicht diese beiden Routinen zur Verfügung stellen? Vielen Dank! |
AW: Direct2D Anwendung
Die Units sind auch in den höheren Editionen nicht dabei. Woraus schließt du denn, dass du diese Units brauchst?
|
AW: Direct2D Anwendung
Ich möchte konkret an einem Beispiel in alle in einer Schleife gezeichneten Rechtecke eine Nummer als Text eintragen.
Das geht zwischen BeginDraw und EndDraw nur mit Direct2D-Befehlen, normale GDI-Ausgabe würde nach EndDraw überschrieben. Diese Befehle für Textausgabe sind, wie ich mittels künstlicher Intelligenz ermittelt habe, nur in den genannten Units vorhanden. |
AW: Direct2D Anwendung
Ich habe mal die künstliche Intelligenz gefragt, wo ich die gesuchte Datei finde.
Die KI schrieb u.a. was von einem "MfPack" bei SourgeForge, über das ich dann das Projekt bei Github fand: ![]() Eventuell hat sich der Dateiname etwas geändert. Schau mal unter dem folgenden Link, ob es die gesuchte Datei ist: ![]() Alles ohne Gewähr! |
AW: Direct2D Anwendung
Vielen Dank für den Hinweis.
Indem angegebenen Bereich finden sich tatsächlich die gesuchten Dateien, aber in anderem Kontext. Das Zusammenspiel funktioniert leider noch nicht wie erwartet. |
AW: Direct2D Anwendung
Zitat:
![]() Be careful it is full of miss ordered functions with overload , it may be all of them are wrong in every file in that translation. here two examples 1) IDWriteFontSet1 ![]()
Code:
but in the translation from
....
IDWriteFontSet1::GetFilteredFonts Retrieves a subset of fonts filtered by the given ranges, endpoint-inclusive. IDWriteFontSet1::GetFilteredFonts Retrieves a subset of fonts filtered by the given properties. IDWriteFontSet1::GetFilteredFonts Retrieves a subset of fonts, filtered by the given indices. .... ![]()
Delphi-Quellcode:
the three overloads are miss placed and they should be like this , the order should be
function GetFilteredFonts(properties: PDWRITE_FONT_PROPERTY;
propertyCount: UINT32; selectAnyProperty: BOOL; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall; function GetFilteredFonts(fontAxisRanges: DWRITE_FONT_AXIS_RANGE; fontAxisRangeCount: UINT32; selectAnyRange: BOOL; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall; function GetFilteredFonts(indices: UINT32; indexCount: UINT32; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall;
Delphi-Quellcode:
2) IDWriteGdiInterop1 from
function GetFilteredFonts(indices: UINT32;
indexCount: UINT32; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall; function GetFilteredFonts(properties: PDWRITE_FONT_PROPERTY; propertyCount: UINT32; selectAnyProperty: BOOL; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall; function GetFilteredFonts(fontAxisRanges: DWRITE_FONT_AXIS_RANGE; fontAxisRangeCount: UINT32; selectAnyRange: BOOL; out filteredFontSet: IDWriteFontSet1): HResult; overload; stdcall; ![]()
Code:
The translation from
IDWriteGdiInterop1::CreateFontFromLOGFONT
Creates a font object that matches the properties specified by the LOGFONT structure. (IDWriteGdiInterop1.CreateFontFromLOGFONT) IDWriteGdiInterop1::GetFontSignature Reads the font signature from the given font. (overload 2/2) IDWriteGdiInterop1::GetFontSignature Reads the font signature from the given font. (overload 1/2) IDWriteGdiInterop1::GetMatchingFontsByLOGFONT Gets a list of matching fonts based on the specified LOGFONT values. Only fonts of that family name will be returned. ![]()
Delphi-Quellcode:
Also wrong and should be
IDWriteGdiInterop1 = interface(IDWriteGdiInterop)
['{4556BE70-3ABD-4F70-90BE-421780A6F515}'] function CreateFontFromLOGFONT(_logFont: LOGFONT; fontCollection: IDWriteFontCollection; out font: IDWriteFont): HResult; stdcall; function GetFontSignature(font: IDWriteFont; out _fontSignature: FONTSIGNATURE): HResult; overload; stdcall; function GetFontSignature(fontFace: IDWriteFontFace; out fontSignature: FONTSIGNATURE): HResult; overload; stdcall; function GetMatchingFontsByLOGFONT(_logFont: LOGFONT; fontSet: IDWriteFontSet; out filteredSet: IDWriteFontSet): HResult; stdcall; end;
Delphi-Quellcode:
this was only two examples but i think may be every overload is wrong in that library.
IDWriteGdiInterop1 = interface(IDWriteGdiInterop)
['{4556BE70-3ABD-4F70-90BE-421780A6F515}'] function CreateFontFromLOGFONT(_logFont: LOGFONT; fontCollection: IDWriteFontCollection; out font: IDWriteFont): HResult; stdcall; function GetFontSignature(fontFace: IDWriteFontFace; out fontSignature: FONTSIGNATURE): HResult; overload; stdcall; function GetFontSignature(font: IDWriteFont; out _fontSignature: FONTSIGNATURE): HResult; overload; stdcall; function GetMatchingFontsByLOGFONT(_logFont: LOGFONT; fontSet: IDWriteFontSet; out filteredSet: IDWriteFontSet): HResult; stdcall; end; How to do it right ? lets assume A,B,C,D,E,O? are interface methods, only O1,O2,O3 are overloaded methods for O, they have the same name with different parameters let say we have an interface declared like this in an interface from Windows SDK for C++
Code:
the right translation in Pascal/Delphi should be like this
A
O1 B O2 C O3 O4 O5 D
Code:
I pretty sure about the above problem with overloaded functions ordering and how VisualStudio missed this for long time as they can't fix it or change it, if someone can prove me wrong, then please i would to see the correct ordering.
A
O5 O4 O3 O2 O1 B C D |
AW: Direct2D Anwendung
There was a discussion of this problem, can't remember much about it but in essence it was the same order overload problem.
|
AW: Direct2D Anwendung
Kannst Du über GetIt das Paket "Windows API from WinMD" installieren und die Dateien dort finden?
|
AW: Direct2D Anwendung
Zitat:
COM Interfaces in Pascal brauchen (um was zu verhindern?) eine andere deklarierte Reihenfolge der Methoden als im MS SDK header (.h)? |
AW: Direct2D Anwendung
Zitat:
So let me show and point to one or more example about this very problem, and remember one thing the declaration header and methods order is SDK is exactly as the documentation in Microsoft site, 1) IDWriteGdiInterop1 from ![]() Zitat:
Zitat:
![]()
Code:
Now we see the fontFace then font also the added number which goes right with (2/2) and (1/2) in reversed order, how Delphi do it ? well i put it up in earlier post
Source
impl IDWriteGdiInterop1 Source pub unsafe fn CreateFontFromLOGFONT( &self, logFont: *const LOGFONTW, fontCollection: *mut IDWriteFontCollection, font: *mut *mut IDWriteFont, ) -> HRESULT Source pub unsafe fn GetFontSignature_2( &self, fontFace: *mut IDWriteFontFace, fontSignature: *mut FONTSIGNATURE, ) -> HRESULT Source pub unsafe fn GetFontSignature_1( &self, font: *mut IDWriteFont, fontSignature: *mut FONTSIGNATURE, ) -> HRESULT Source pub unsafe fn GetMatchingFontsByLOGFONT( &self, logFont: *const LOGFONTW, fontSet: *mut IDWriteFontSet, filteredSet: *mut *mut IDWriteFontSet, ) -> HRESULT ![]() 2) IDWriteFontFace4 from ![]() ![]() now compare with Rust declaration ![]() The only difference now we only have one with number of order (1/2) for the second one in the SDK 3) This case is peculiar and interesting as it is fixed and swapped ! IDWriteFactory3 ![]() has these overloaded in this order, also notice they don't have numbers (?/?) Zitat:
in Pascal translation the order is right ! ![]()
Delphi-Quellcode:
And in Rust
function CreateFontFaceReference(filePath: PWideChar;
lastWriteTime: FILETIME; faceIndex: UINT32; fontSimulations: DWRITE_FONT_SIMULATIONS; out fontFaceReference: IDWriteFontFaceReference): HResult; overload; stdcall; function CreateFontFaceReference(fontFile: IDWriteFontFile; faceIndex: UINT32; fontSimulations: DWRITE_FONT_SIMULATIONS; out fontFaceReference: IDWriteFontFaceReference): HResult; overload; stdcall; ![]()
Code:
Rust order without the _1 and _2 is wrong !, yet the numbers here will save you as Rust has extra layer and will use the right order based on the suffixes _1 and _2
pub unsafe fn CreateFontFaceReference_2(
&self, fontFile: *mut IDWriteFontFile, faceIndex: UINT32, fontSimulations: DWRITE_FONT_SIMULATIONS, fontFaceReference: *mut *mut IDWriteFontFaceReference, ) -> HRESULT Source pub unsafe fn CreateFontFaceReference_1( &self, filePath: *const WCHAR, lastWriteTime: *const FILETIME, faceIndex: UINT32, fontSimulations: DWRITE_FONT_SIMULATIONS, fontFaceReference: *mut *mut IDWriteFontFaceReference, ) -> HRESULT So this one was fixed in Pascal/Delphi and i think the reason is someone tried to use it and found the right order to make it work, unlike many others ! Also notice how they are declared in the SDK header file ![]() Why this happen ? 1) While Delphi is rightfully very strict in building the VTable, Visual Studio and every other compiler is also rightfully can change the order. 2) While VT is something belongs to the compiler to decide when and where, Delphi is right, Visual Studio on other hand rearrange them as see fit, and here i am not talking about interfaces, just VT in general, VS compiler optimize the table. 3) The problem in my opinion is from very old introduced bug and when Windows SDK introduced interface, ATL and COM they failed to foresee the incompatibility with compilers form different languages, so they can't change their own SDK and they can't break compiler it self for libs that already being built, hence they left it like that undocumented and don't want to talk about it and don't to document it ! @pcoder, i added examples here and hope they are clear or clearer to see and fact checking if there is questions then please explain it in details. Hope that helps. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:05 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