

PeterBelow
Members-
Content Count
563 -
Joined
-
Last visited
-
Days Won
13
Everything posted by PeterBelow
-
Why does the field type change after saving the Table within the database?
PeterBelow replied to Miguel Jr's topic in Databases
Interbase is a SQL database. The book you are using seems to be very old, probably written for an ancient Delphi version like Delphi 7, which used the Borland Database Engine (BDE) for database access and the Database Desktop app for managing the database. This is about 20 years out of date; the BDE has not been offficially supported for more than a decade and it and its tools are difficult to install and get to work on Windows 10 or 11. If you want to learn to program in Delphi get the free Delphi Community edition. It comes with a modern version of Interbase and allows you to build application using a local database. The IDE has an integrated database view that can be used for simple database management, but the Interbase installation has its own toolset, like ISQL, which you can use to execute DDL (Database Definition Language) scripts to manage the database. -
Simulate Multiple Inheritance
PeterBelow replied to Mike Warren's topic in RTL and Delphi Object Pascal
Interfaces can only have methods, not fields. Your Thing property needs a GetThing method as read accessor and the implemention can then refer to the FThing field of the class implementing the interface. Interfaces also imply lifetime management by reference counting (that comes from their original purpose in Delphi to work with COM). All classes derived from TInterfacedObject have the necessary infrastructure build in, but beware: classes derived from TComponent inherit an implementation of the relevant methods (_AddRef and _Release) that is not reference-counted, since the lifetime of components is controlled by their Owner. So do never store an interface reference obtained from a component in a field/variable that may outlive the component itself, that is a sure way to produce access violations when the compiler-generated code tries to finalize said reference when the field/variable goes out of scope! -
In the OnPostError handler you have to store the error code (E.Errorcode) or the class of the exception passed to the handler (E.Classtype) into a field of the datamodule. Since you told the handler to abort the operation the exception you trap in the try except block will always reflect that, but you can examine the value stored by the handler to figure out what went wrong. But be careful, it is not a good idea to execute code from an except block that may trigger another exception. Just set a flag, that indicates the action to take and act on that after the try except block. Oh, by the way, do not store the E parameter's reference in the handler, that may become invalid after the handler returns since it probably destroys the exception object...
-
What does this function mean? CharPrev / Range Check Error
PeterBelow replied to terran's topic in General Help
That is not relevant for Unicode UTF-16, which is what the String type uses in all Delphi releases since more than a decade. Who relies an ANSI/MBCS strings these days anymore? Windows has used Unicode internally for ages... -
If you look at the VCL source (if you have it) in the design the VCL follows each component having an event also has a virtual or dynamic method, usually protected, that fires the event. This method can be overridden in descendants to change the way the component handles the event. So, in your case, you would implement such a method to provide the default processing and optionally to also fire an associated event, if a handler has been assigned to it.
- 5 replies
-
- vcl
- component classes
-
(and 2 more)
Tagged with:
-
Delphi 2007 and XE5 Crashes on Windows 11
PeterBelow replied to CarGo's topic in Delphi IDE and APIs
Have you tried to explicitely set the OS compatibility of the affected bds.exe to Windows 7? I don't have Win11 installed yet but it should have this option like Win10 and older Windowses in the EXE properties dialog. -
Try to not use anchors but set the new panel's Align to alTop instead. If you want vertical spacing set the panel's AlignWithMargin property to true and set its Margin.Bottom to the spacing you want and all other Margin members to 0.
-
Have you tried using scrollbox.clientwidth instead of scrollbox.width?
-
Add onClick event on TCanvas
PeterBelow replied to direktor05's topic in Algorithms, Data Structures and Class Design
You don't. Use a TPaintbox as a drawing surface, it has a Canvas and an OnClick event. TImage is another candidate, it contains (by default) a bitmap you can draw on using the image component's Canvas, and it also has an OnClick event. As explained in other replies a TCanvas is just a wrapper for a window's device context, it cannot receive mouse events directly. -
Access violation errors while running without the debugger
PeterBelow replied to christos papapostolou's topic in Algorithms, Data Structures and Class Design
Moving from D7 to Delphi 12 (Athens) is a very big jump. If you can build the old codebase at least you don't have to worry about old 3rd-party components, but there have been a lot of changes on the way, the most important one perhaps the move from ANSI to Unicode (UTF16) characters. Sizeof(char) = sizeof(byte) = 1 is no longer true, and that hits hard if the old code misused string variables for storing binary data. Incrementing a pointer of type PChar will now increment it by 2, not by 1, and that can easily cause old code to overwrite memory, which may be at the root of your problem. It may work for debugging just due to a different stack layout caused by different options, e.g. for using stack frames. A stack overwrite can corrupt a return address and that may lead to the exception you see. As recommended in other replies using a tool like MadExcept may be the best way to nail down the problem location, but if it is indeed a stack corruption the actual cause may be far from the location where it finally manifests. In this case doing an in-depth code review may be a better option, since there are likely more of these problematic code bits in your project. -
Do you know that you can supply up to four images in the bitmap you use for the Glyph property? See here for what they are used for. If your bitmap only contains one glyph image the control will synthesize the disabled image from it and the results are often not that good.
-
Troubleshooting W32ResourceDLL.Personality Error in Delphi Professional Athens
PeterBelow replied to Patricia Rosman's topic in General Help
The old translation tool has been deprecated for a couple of versions already and was removed from D12 completely. Check if it is still available as add-on via GetIt, the IDE seems to still use it. It was probably dropped finally since it's Windows only and i'm not sure if it ever worked for FMX projects even there. -
Troubleshooting W32ResourceDLL.Personality Error in Delphi Professional Athens
PeterBelow replied to Patricia Rosman's topic in General Help
May be a problem in the dproj file, the IDE has never been very good in converting that from a previous Delphi version. Make a backup of the project's dproj file, delete it, and then open the project's dpr file. That will create a new dproj file without any garbage from the previous version. You may have to adjust the project options, though. -
Setting Events on TPersistent members
PeterBelow replied to The Code Captain's topic in Delphi IDE and APIs
I think all you have to is to define the events with published scope and then register the property editor for that event handler type. -
How to import Type Library for Managed Code DLLs
PeterBelow replied to Ron Schuster's topic in General Help
The import menu should also have an "import .NET assembly" item that allows import of a COM-interop-enabled .NET library. -
delphi 12 migration Upgrade from delphi 6 to delphi12
PeterBelow replied to Sanu's topic in General Help
Emba Blog: https://blogs.embarcadero.com/upgrading-and-maintaining-delphi-legacy-projects/ https://blogs.embarcadero.com/a-roadmap-to-migrate-your-legacy-delphi-and-c-applications-to-the-latest-blazing-fast-version/ Book review: https://dalijap.blogspot.com/2022/06/book-review-delphi-legacy-projects.html I hope you have plenty of unit tests etc. for your project. With a jump that large and a project using many 3rd-party components this will probably amount to a major rewrite... -
Showing TMenuItem icons at design time in the IDE
PeterBelow replied to PeterPanettone's topic in Delphi IDE and APIs
Do you use the Bitmap property of the menu items or have you attached an imagelist to the popup menu and used the imageindex property of the menu items? The latter is the way to go these days. -
A bookmark with a name given by the user, not just a number as the standard IDE bookmarks get. The latter do not make sense across units but the former do.
-
The one on d: contains stuff fetched by the installer, the one on C:\users stuff you fetched via GetIt yourself, so both are independent.
-
How to debug a Not Responding program element
PeterBelow replied to Willicious's topic in Delphi IDE and APIs
If you can reproduce the problem in the debugger the Run -> Program Pause menu item should get you the code location the program is currently executing. -
What do you think of "Local Global variables"
PeterBelow replied to Tommi Prami's topic in RTL and Delphi Object Pascal
Nested procedures/functions are basically legacy from the times of Turbo Pascal, before we could write properly object-oriented code. They are still useful for procedural code, but if you organize your program's tasks into classes then you can replace nested procedures with private methods of the class and either pass needed values as parameters or move the local variables used as private fields to the class declaration. IMO that gives a much cleaner and easier to understand design, and it keeps down the size of the methods. -
Refresh UI Desigh with DexExpress and / or TMS
PeterBelow replied to JIMSMITH's topic in Job Opportunities / Coder for Hire
This post may be better served in the Job Opportunities section off this forum. -
Safe Array Definition inside Type LIbrary Editor
PeterBelow replied to Robert Gilland's topic in RTL and Delphi Object Pascal
Is this for defining a method parameter? I think you have to define it as SAFEARRAY[VARIANT] (perhaps the syntax is SAFEARRAY(VARIANT), do not remember) in the code editor part, that is: in the ridl file. The type library editor only offers long as the element type for a safearray parameter. The server would have to construct a safearray with variants of type VT_RECORD. I have never worked with such user-defined types in COM applications, but from the docs it looks to be horribly convoluted, to say the least... As far as I know Delphi's support for OLE Variants does not include anything for UDTs, you would have to implement the necessary details in your own code. -
I remember another post with a similar issue that turned out to be linked to the size of the project (number of units, forms, something like that). Do you get the same message if you start the IDE with no project open (-np command line switch if memory serves)?
-
Perhaps you remember TGauge, one of the sample components that came with early Delphi versions, before Windows introduced the progressbar common control.