-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
procedure TForm1.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer); begin LockWindowUpdate(0); end; procedure TForm1.FormBeforeMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer); begin LockWindowUpdate(Handle); end;
-
The TitleBarPanel is used by the IDE. I guess it was developed to resolve the problem with the disappearing/flickering controls of the IDE title bar (search, layout controls, etc.), It can accommodate Toolbars (including the ActionMainMenuBar) and other controls, so you can place the main menu on the titleBar (see the sample app). And to answer the original question, you would need to manually adjust the Titlebar colors every time there is a style change. This is probably how the IDE styles its TitleBarPanel. @Vincent Parrett I also do not like the overcrowding of TForm and other controls with rarely used properties. (e.g. CustomHint that can be linked to a Balloon Hint all but abandoned - not DPI aware).
-
Direct2D 1.1 canvas much slower that Direct2D 1.0
pyscripter replied to FPiette's topic in Windows API
Regarding the RenderTarget I showed the code above. For details have a look at https://github.com/EtheaDev/SVGIconImageList/blob/master/Source/D2DSVGFactory.pas) . What I am suggesting is that you build your app as if it was a GDI app. And just use D2D in your painting code (override Paint, OnPaint event etc) utilising a single DCRenderTarget. -
Direct2D 1.1 canvas much slower that Direct2D 1.0
pyscripter replied to FPiette's topic in Windows API
You can get a Device context from the Render Target. I am using ID2D1DeviceContext5 which was introduced with the Creators Update. if Supports(RenderTarget, ID2D1DeviceContext5, DeviceContext5) And as I said you do not need (multiple) D2D Windows. Just use standard forms and one DCRenderTarget to use in the OnPaint event of the form or by overriding the Paint method of Controls. And in terms of speed D2DSVG renders 300 svgs to bitmaps in less than 15ms. -
The most common way do text-processing in Delphi is to load a file into a TStringList and then process the text line-by-line. Often you need to save the contents of the StringList back to the file. The TStringList is one of the most widely used RTL classes. However there are a number of limitations discussed below: a) No easy way to preserve line breaks on Load/Save TStringList does not make any effort to recognize the type of line breaks (LF, CR or CRLF) in the files it opens, let alone save that for use on saving. b) Information loss without any warning or any option for dealing with that. Internally TStringList uses unicode strings, but when you save its contents to a file using the default encoding (ANSI), this may result in information loss, without getting any warning or having any means for dealing with that. TEncoding.GetBytes also suffers from that. c) No easy way to determine whether a file you loaded into a TStringList contained a BOM When you load a file (LoadFromFile method), the encoding of the file is stored but not the information about whether the file contained a BOM or not. The WriteBOM property is only used when you save a file. d) Last but not least, no easy way of dealing with utf8 encoded files without a BOM The default text file format in Linux systems, in Visual Studio Code and other editors, as well as in languages such as python 3 is utf8 without BOM. Reading such files with TStringList is problematic and can result in errors, because it thinks such files are ANSI encoded. You could change the DefaultEncoding to utf8, but then you get errors when you read ansi files. No effort is made to detect whether a file without a BOM contains utf8 sequences. Overall, it is desirable that, when you load a file using LoadFromFile and then you save it using SavetoFile, the saved copy is identical to the original. I am attaching a general purpose TStringList descendent that deals with all the above issues in case anyone has a use for that. XStringList.pas
-
Direct2D 1.1 canvas much slower that Direct2D 1.0
pyscripter replied to FPiette's topic in Windows API
I have used D2D to draw SVG images (see https://github.com/EtheaDev/SVGIconImageList/blob/master/Source/D2DSVGFactory.pas) and the performance is very good! I found that Vcl.Direct2D was not worth the trouble and that it was easier to work directly with the D2D interfaces. Also I preferred to use the DCRenderTarget as opposed to HWndRendertarget, since the former blends better with GDI and GDI+ applications. One issue I had was with hardware acceleration. if not Succeeded(D2DFactory.CreateDCRenderTarget( D2D1RenderTargetProperties( {$IFDEF GPUSupprt} D2D1_RENDER_TARGET_TYPE_DEFAULT, {$ELSE} D2D1_RENDER_TARGET_TYPE_SOFTWARE, // much faster in my desktop with a slow GPU {$ENDIF} D2D1PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 0, 0, D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE), RenderTarget)) In the code above D2D1_RENDER_TARGET_TYPE_SOFTWARE avoids hardware acceleration and it was massively faster in a Desktop with a slow GPU. You may want to try that. -
What is wrong with TStringList
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Agree. In the old days (pre Unicode) I wrote the attached Strmtxt.pas (converts a stream to a text file). It would need to be updated to work with recent versions of Delphi. And it works great with buffered streams such as @David Heffernan's TReadOnlyCachedFileStream. With that you could do something like: var Stream := TReadOnlyCachedFileStream.Create('c:\temp\t'); AssignStream(Txt, Stream); while not EOF(Txt) do begin Readln(Txt,S); Writeln(MemoText, S); end; However when you build a text editor such as SynEdit, you typically load the whole file in memory. In any case, the focus of this topic was the limitations of TStringList with regards to dealing with encodings, BOM and Line breaks. It was not about what is the most efficient way to do text processing in Delphi. STRMTXT.PAS -
Delphi 10.4.1 LIBSUFFIX AUTO
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Already reported by @Remy Lebeau!😀 https://quality.embarcadero.com/browse/RSP-30820?jql= -
Delphi 10.4.1 LIBSUFFIX AUTO
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Thanks Darian. I did. The problem only happens when you have a dpk file without a project file. If the dpk file contains the new directive {$LIBSUFFIX AUTO} the IDE does not recognize that and thinks the actual suffix is "AUTO". -
I would like to add that if you change the default Windows page to 65001 and have pas files containing ASCII characters > 127 then your files will be messed up when you open them in Delphi. Also if you build your Delphi projects you will get warnings or even worse produce erroneous executables without warnings. Try to compile SynEdit for example. Having said that, this option is great for interacting with console applications and system processes and being able to at last handle unicode console input/output.
-
Agree with all the above, except that UTF8String is an an AnsiString with a Code Page 65001 and is also Unicode compliant and incurs no conversion loss. It is the default string type in FPC. In Linux systems everything is UTF8. And nowadays 65001 it can be set as the default code page in Windows.
-
Delphi 10.4.1 LIBSUFFIX AUTO
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
During building the package from inside the IDE, -
Amazing! After installing a few packages in 10.4.1 (Synedit was one of them) Gexperts Grep Results now works! Nice because Grep Search and Unit Clause Manager are my favorite Gexperts.
-
Running the stand-alone grep reports: "Failed to load any of the possible GExpert.dlls"
-
Help: preview of Svg image in Open-Dialog works only with VCLStyle active.
pyscripter replied to Carlo Barazzetta's topic in VCL
It should be mentioned that one of the package units registers the new file format: initialization TPicture.RegisterFileFormat('SVG', 'Scalable Vector Graphics', TSVGGraphic); Use PowerToys to get SVG preview at run time when you disable Vcl styles. (Also in File Explorer) -
10.4.1 Released today
pyscripter replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
Wow! And a fix for Threading - Incorrect calculation of IdleWorkerThreadCount. See https://en.delphipraxis.net/topic/2428-threads-in-ppl-thread-pool-not-returning-to-idle-as-expected/ -
10.4.1 Released today
pyscripter replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
The fix to TMonitor discussed in is in. -
... of TXMLDocument. Fully agree. MSXML contains a SAX reader/writer. Delphi implementation examples at http://www.craigmurphy.com/bug/. XMLLite is a good alternative to SAX on Windows. See the note about push and pull parsers. Similar speed and much easier to program with. And there is a Delphi wrapper (just a single unit to add to your project).
-
OmniXML is included in Delphi, but I am not sure how it compares to the standalone one. If you look at the benchmarks of OXml you will see that if you access the library through Delphi XML and the OXml vendor you would consume almost 10 times more memory and 5.7 times more CPU time compared to raw access. The navigation time increases 32 times!! Which is exactly the point I was trying to make.
-
Where exactly do we disagree? I started by saying the features are great. But if xml processing is a performance bottleneck you can improve performance drastically (see below) by accessing the underlying implementation directly with minimal changes to your code, since implementations follow the standard DOM interfaces.
-
imagelist Looking for Icon Fonts support in Delphi for High-DPI and Themed app?
pyscripter replied to Carlo Barazzetta's topic in VCL
Indeed: From https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-addfontmemresourceex -
dic.Items['aaa']:=l2; dic.Items['aaa'] already contains l2 and l2 is freed before it is readded, since you set doOwnsValues Also an issue would occur if you do dic.Items['bbb']:=l2; When the dictionary is destroyed the list will be freed twice.
-
See https://github.com/akramhussein/Mute
-
Generic circular buffer library released
pyscripter replied to TurboMagic's topic in Algorithms, Data Structures and Class Design
Has this been released? Is that the develop branch? -
PyScripter reached 1 million downloads from Sourceforge
pyscripter replied to pyscripter's topic in I made this
True, but it is kind of hard to keep track of them (count, geographic distribution etc.).