

PeterBelow
-
Content Count
564 -
Joined
-
Last visited
-
Days Won
13
Posts posted by PeterBelow
-
-
3 hours ago, skyzoframe[hun] said:Greetings everyone,
I want to sort a tList with some kind of record parameter. Somehow I need to use pointers to get to the record without using the name of the record.
In this example I am using the name "Rec.x". However, in the future I would like to use "Rec.y", "Rec.z","Rec.ID" or any other record value in the sort. // See below
In fact, I have never used pointers before.
"function Foo.BubbleSort(AList: dmA00; SomeParameterHere:IsSomething ;out Error: String): Boolean;"
...
" if jRec.SomeParameterHere > j1Rec.SomeParameterHere then"
kind regards Zoltan.K
A TList<T> has a constructor overload that takes a comparer (IComparer<T> instance) to use for sorting and searching the list by default. The Sort method also has such an overload. You use
TComparer<T>.Construct()
to fabricate a suitable comparer on the fly, providing an anonymous method that does the actual comparison of two items in the way you want the sort to go. This anonymous method has to "know" the record type in question, so you can directly refer to the fields of the two items passed to it.
Forget about pointers, you do not need them to work with generics.
-
2
-
-
25 minutes ago, Squall_FF8 said:Hi guys,
I want to save/load the main window position, size, state so every time you reopen it, it looks the it was when you close it.
So the snippet bellow. It works ,... almost. When I close the app with a maximized window, after relaunch it is maximized, If I click the button to make it Normal, it doesnt go where I left it previously before maximizing.
Can you help me? What I'm missing?P.S. If it matters, I use Delphi 12.2, on Win 10.
Set the DefaultMonitor property of the form to dmDesktop, this way the form left and top do not depend on the monitor the form is on and will restore the form to the monitor it was on before (unless the user rearranges his desktop configuration). For the necessary code see the PB.Winset unit in the attached archive.
-
On 3/5/2025 at 1:18 PM, DaveB said:Hi everyone,
I am pretty much a newbie in Delphi (learnt a bit of Pascal and Delphi 20 years ago, but coming back to it in 2025 and everything feels very new to me). My intention is to start developping an app to handle chemistry operations. There are several nice toolkits around, for instance:
- EPAM's Indigo toolkit https://lifescience.opensource.epam.com/indigo/ (with pre-existing wrappers for C/C++/C#/Java/Python)
- Greg Landrum's RDKit https://www.rdkit.org/ (Python and C++ wrappers exist, as well as a MinimalLib CFFI https://greglandrum.github.io/rdkit-blog/posts/2021-05-01-rdkit-cffi-part1.html)
- the Chemistry Development Kit https://cdk.github.io/ (with tutorials to interface it in Java)
and probably others. However, I could not find any Delphi wrapper for any of them, nor any example case where someone would have been interfacing them in a Delphi app.
Well, well, has been some years since somebody asked about chemistry here 8-)...
As it happens I am a (retired) organic chemist and have worked for more than 30 years for a german (later french) pharma company in research. I wrote a lot of software working with chemical information, mostly from chemical databases. While the core of my library depended on MDL (later Accelrys) ISIS (long dead) and their Oracle chemistry package I tried during my last year at the company to get rid of the ISIS dependency by creating a Delphi wrapper for the Indigo library. Unfortunately I did not have enough time to complete and test the wrapper, and it is based on the 2017 32-bit Indigo DLLs, but perhaps you can find something of use in the mess. I also included some other units related to chemistry in the attached archive without ISIS dependencies.
Have fun ;).
-
1
-
-
If memory serves the IDE deletes these files when it closes normally. Check the first two items under "Autosave" as well. The first creates backups of open units in the _history folder.
-
1 hour ago, davornik said:I have seen this example.
Is there any way to just change font color without drawing a complete button?
Not if you use the standard Windows style. If you configure the app to use one of the custom styles (like Windows 10) you can set the StyleElements.seFont property element to false and it will then use the font.color you set and not the Windows default.
-
19 hours ago, Delphied said:Are there any companies that enable the ability to screenshot a specific component on a form? I found https://greatis.com/delphicb/screenshot/, but I don't believe they are in business anymore. Something like this would be most helpful and thanks in advance!
If you only need to capture TWincontrol decendants you can do this with a few code lines using the TWincontrol.PaintTo or TWincontrol.PaintWindow methods, using a properly sized TBitmap as target.
-
Try the ItemWidth property instead.
-
From the help it looks like the StyleServices function can take a parameter that specifies the control you want the style info for. So, have you tried to pass a main menu instance as this parameter? Or look at the drawing code in vcl.menus.pas, that should show you how the vcl gets the colors to draw with.
-
Components dropped at design time load their properties from the dfm file after the constructor has executed. To set a property to a different value you need to override the Loaded method and do the deed there.
-
-
13 minutes ago, araujoarthur said:I've been wondering, if within my project I have a structure that looks like:
Forms.Dialogs.pas
- Forms.Dialogs.BaseDialog.pas- Forms.Dialogs.IncludeDialog.pas
- Forms.Dialogs.WarnDialog.pas
- Form.Dialogs.ErrorDialog.pas
Is it possible to make IncludeDialog, WarnDialog and ErrorDialog available upon uses of Forms.Dialog?I assume Forms.Dialogs.pas is a unit not defining a form build in the form designer?
In this case I would export functions from that unit that internally create and show(modal) one of the specific form classes, setting any needed setup values from parameters passed to said functions and returning any data entered/selected by the user as function result or in var or out parameters. This way other units need not require the specific form class units in their uses clause, only Forms.Dialogs.
Note that the dialog forms would not be autocreated in this setup, the exported functions would all create, show, and then free a new instance of their dialog form.
-
1
-
-
23 hours ago, dormky said:Heavy disagree. A message/event driven environment should, you know, actually use events instead of mixing in state monitoring.
The VCL has to work in the API environment that Windows provides. So aim your criticism at Microsoft ;).
-
24 minutes ago, dormky said:Jesus Christ, that is awful design. It's amazing, everytime I encounter a situation where I ask myself "how am I meant to [thing] with this framework", the answer is always "we implemented it, just in the most non-sensical way possible lol".
You are wrong, the design makes eminent sense for a message/event driven environment like Windows. A modal form has its own internal message loop and that needs a way to figure out that it should exit the loop. Modalresult <> mrNone is that condition.
-
6
-
-
25 minutes ago, Anders Melander said:I don't think that list is up to date given that Delphi has complained when you tried to install it on Windows 7 since 10.3 (AFAIR).
That said, I upgraded my main system from Windows 7 to 10 last year but before then I didn't have any problems with the IDE or applications not working on Win7.
The IDE requires Win10 or 11, but applications build with it can run on older Windows versions, depending on which features they use. It may be necessary to modify the default manifest, though, if it specifies a newer Windows version as requirement (have not checked if it does).
-
Just now, Uwe Raabe said:This doesn't seem right. The call should be SetLength(arrayvar[rowindex], columnsize), shouldn't it?
Yes, my bad. I'm getting old ... 🙂
-
in a dynamic 2D array ( a type like TMyArray = array of array of integer) you can set the number of rows with a SetLength call on the array variable and, for each row, set the number of columns with a SetLength(arrayvar, rowindex) call. That should cover your requirements. To reduce memory fragmentation you should avoid multiple SetLength calls on the same array row or the array itself, though. Determine the number of rows/elements beforehand, if possible.
-
1
-
-
Well, it has to be something you do in your code then. I just created a new VCL app (D12.2), dropped a TRichedit on it, build and ran and it inserts an image (jpg in this case) dragged from Explorer to it just fine. If you now handle WM_DROPFILES or such try to disable that.
-
XE6 and D12 use different versions of the Windows richedit control as far as I remember, that may explain the change in behaviour you see.
-
11 hours ago, Mark Williams said:Same result. It reports true for Server Manager, but then fails with the variant does not reference... error on the call to ServerManager.GetAdminSection.
Looks like the GetAdminSection function does not return an automation-compatible interface. Can you check what VarType the returned OleVariant has?
-
Try
Result := not (VarIsClear(OleObject) or VarIsEmpty(OleObject) or VarIsNull(OleObject)) and (VarType(OleObject) = VT_DISPATCH);
-
If you open the wsdl in a browser you will see that it is very complex, importing a lot of xml schemas which partially import other schemas, using a host of namespaces. And the schemas seem to be not valid in some cases, e.g. by using namespace prefixes like tns: without defining them. The wsdls also refer to a script but fails to define a namespace for it, no idea if that is valid.
-
Look at this help entry for an overview of how to modify the way a TDBGrid is drawn. In your case set the DefaultDrawing property of the grid to false and attach a handler to the OnDrawColumnCell event. The handler can check the attached dataset's current row to see what row it has to draw. If it is the first just call the grid's DefaultDrawColumnCell method directly. If it is the second row change the grid.canvas.font to bold first and then call DefaultDrawColumnCell. That should do what you want.
-
13 hours ago, 357mag said:I'm considering working in Delphi for awhile, and I was looking through my books (I have four of them), and every book starts off right away with Windows programming. None of the books teaches you console programming. Personally, I like console programming. I was wondering if there is a reason all of my books starts you off that way. Perhaps because Delphi is a clean, fairly easy to grasp language?
GUIs are just the majority of the applications build with Delphi. But you can easily build console programs with it, too. The File -> New dialog also offers a template for that.
-
19 hours ago, aehimself said:We have ~1500 frames with at least 20-50 of these custom datasources on each and this problem only occures on one frame, two datasources (always the same 2). This makes me believe that fixing it won't be something generic - e.g. on component or project level.
In this case just override the Loaded method of the frame and link the event handler in code there, after calling the inherited method first. That will fix the issue even if you cannot figure out why it happens in the first place. Not really satisfactory, of course, but the only reason I can think of would be if somebody cleared the Name property of the dataset in question or moved the handler method from published to public scope by accident.
Is there a way to Clear content of TDateTimePicker?
in VCL
Posted
The control has a ShowCheckbox property. This gives the user a checkbox to check or uncheck to indicate a NULL or NOT NULL state. The Checked property then tells you the user's descision. A bit cumbersome but the Windows common control behind TDatetimepicker has no concept of an "empty" state.