

PeterBelow
-
Content Count
565 -
Joined
-
Last visited
-
Days Won
13
Posts posted by PeterBelow
-
-
3 hours ago, Zakaria said:how to correct
Well, what do you want to achieve here?
Look at the source code for TControl, from which TPanel inherits the Caption property and its SetText and GetText accessor methods.
procedure TControl.SetTextBuf(Buffer: PChar); begin Perform(WM_SETTEXT, 0, Buffer); Perform(CM_TEXTCHANGED, 0, 0); end;
Setting a control's Caption or Text properties ends up sending messages to the control. WM_SETTEXT stores the passed string and CM_TEXTCHANGED is a notification for the control that the caption or content has changed, which typically makes the control redraw itself.
TCustomPanel, the immediate ancestor of TPanel, has a private message handler
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
that just calls Invalidate to redraw the panel. If you want to react to a change of the panel Caption you have to add a handler for this message to your modified TPanel class. You cannot override the parent method since it is not virtual or dynamic and also private. But you can call the inherited message handler inside your handler using the inherited keyword.
If you just want a panel that does not show the Caption: it has a ShowCaption property that you can set to false to achieve that. You could set that in an overridden Loaded method.
-
1 minute ago, Miguel Jr said:I'm using Interbase. I don't understand why you're warning me. I'm following the book that I'm using. But anything you can tell me will be useful for my learning. Once again, it's not SQL, it's Interbase. But I'll pay attention to what you're telling me. If you can help me any further, I'll be grateful.
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.
-
2 hours ago, Mike Warren said:I tried it like this, which shows I don't understand interfaces properly:
IapShape = interface procedure SetThing(AThing: Boolean); property Thing: Boolean read FThing write SetThing; // Error here: Field or method identifier expected end; TapRectangle = class(TRectangle, IapShape) private FThing: Boolean; procedure SetThing(AThing: Boolean); public property Thing: Boolean read FThing write SetThing; end;
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!
-
1
-
-
18 hours ago, alogrep said:Hi.
I have this event
procedure Tdm2.APostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin ACTION:=DAaBORT; end;
Then this piece of pseudocode
try table.1.edit; table1.post except on E: SysUtils.Exception do begin if islockerror(e.errocode) then repeatit() else dosomethingelse();; end; end;
The function islockerror() checks if the error code is one of timeut, table locked, etc.
It always returns false because the E.errorcode is always "Operation aborted".
How can I get the value of the REAL error that triggered the event?
Thanks
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...
-
1 hour ago, Virgo said:Previous character, not next.
CharPrev works also, if character consists of multiple codepoints...
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...
-
2 hours ago, UCT_24 said:Hello everybody,
i am wondering if a Control can have a specific EventHandler.
I mean the following: If a Control has a certain "Event", i can implement an Event Handler for the Form which holds the Control.
I wonder if it possible to implement the Event handler as a method of the Component class and thus, the Event is handled by each instance of this component on any Form i use this Component class on (without implementing an event handler on every Form for every Instance, hope it is possible to understand what i am aiming at.)I have never seen such thing. If this is possible, can someone maybe advise me an example how this can be done?
Thanks a lot and kind regards,
UCT
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.
-
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?
-
4 hours ago, direktor05 said:Hello,
I have TCanvas and I want to dynamically add onClick event. How do I do that?
I read something about TNotify and adding property, but how exactly? Need whole code.
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.
-
On 7/19/2024 at 11:52 AM, christos papapostolou said:Hello, i am new to Delphi i come from a c++ background and i was assigned to migrate a legacy delphi app from delphi 7 borland to the latest embacardero version. The main issue that i am dealing with is that when i just run the program inside the IDE (with the debugger on obviously ) everything works fine, while when i run the app again from the IDE but without debugging when particular(not all!) forms .show i get access violation errors which i cannot locate cause i don't have the debugger. If someone with more experience than me can locate the issue i would be very happy to hear a solution for my problem
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.
-
4 hours ago, dormky said:(These are TBitBtns)
In the first image, all buttons are enabled. In the second, the bottom two are disabled. It seems that the disabling makes every color except for pure black completely disappear (see the grey at the top of the pencil disappeared too). What can I do to prevent this ? The icon should just be greyed out, not entirely disappear.
I don't want to make greyed out glyphs and switch them around for literally every button in the program either.
Although if it comes down to it, I guess I could always have a custom button that takes the existing glyph and greys it ? But that sounds finicky and there's probably a better way of solving this.
Thanks !
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.
-
24 minutes ago, Patricia Rosman said:I don't think that is the case because I can't even create a new localization DLL project. The menu option Project > Language isn't available in my Delphi. I tried reinstalling it, but the menu item still doesn't appear. Additionally, I can't find the Resource DLL Wizard under File > New > Other > Delphi Projects > Resource DLL.
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.
-
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.
-
20 minutes ago, The Code Captain said:I write property and component editors for the classes I define so that they can be edited in the IDE. When editing an object in the IDE's object inspector a standard TPersistent only exposes properties which are not events. However, some TPersistents (notably anything deriving from TCollectionItem) do expose events. I would like to have events declared on TPersistent derived objects editable, but I cannot discover what I need to do in my property / component editors so that the IDE will expose them. I would very much appreciate a link to a sample component / property editor that does this.
Thanks in advance!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.
-
3 hours ago, Ron Schuster said:Angus, As I stated in my original post, it does not appear there. That is the main point of my issue.
The import menu should also have an "import .NET assembly" item that allows import of a COM-interop-enabled .NET library.
-
3 hours ago, Sanu said:I need your advice and insights on upgrading a large-scale EHR (Electronic Health Record) system from Delphi 6 to Delphi 12. This system was originally developed in 2006, and the upgrade is necessary to take advantage of the modern features and performance improvements in Delphi 12
Key Considerations:
- Code Compatibility: I'm aware there are differences between Delphi 6 and Delphi 12 in terms of language and runtime libraries. How significant are these changes, and what are some common pitfalls to watch out for?
- Third-Party Components: The system relies heavily on third-party components. What is the best approach to handling components that may no longer be supported or compatible?
- Database Connectivity: Are there major changes in database connectivity methods that I need to be aware of? What are the best practices for updating database interactions?
- User Interface: With the newer UI components in Delphi 12, what strategies do you recommend for updating the user interface to improve usability and aesthetics?
Emba Blog: https://blogs.embarcadero.com/upgrading-and-maintaining-delphi-legacy-projects/
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...
-
1
-
20 hours ago, PeterPanettone said: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.
-
2 hours ago, Uwe Raabe said:As I am not familiar with this feature, I wonder what the difference is between a standard bookmark and a global bookmark.
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.
-
12 hours ago, jesu said:Hello. I have 2 folders called CatalogRepository. One is C:\Users\usuario\Documents\Embarcadero\Studio\23.0\CatalogRepository and another one in D:\Delphi12\CatalogRepository.
I think this last one is the folder I chose during installation.
Each of them occupies several gigabytes. The one in C contains Fastreports, Jedi, Styles.. and the one in D has Android NDK, Konopka, FmxLinux,...Are both neccessary? Can I delete any of them to save some space?
Thanks.
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.
-
25 minutes ago, Willicious said:My Delphi program has a somewhat complex level selection menu which loads various items including graphics, level information and a treeview for selecting packs and levels.
Up until recently, the menu has started to hang and occasionally become unresponsive, occasionally requiring closing the program altogether using Task Manager.
My question is, how would I go about locating the source of the problem? Something as generic as a program hang which only happens occasionally doesn’t really point towards anything specific, but the chances are that it is something specific which is causing the issue.
I’m happy to share the entire .pas file for the level select menu (about 1700 lines of code) if anyone thinks it necessary, but I wondered if there might be a specific way to find out where loading bottlenecks might be happening, or how to isolate whatever is causing the program to hang. I use RAD Studio 10.4 (the program doesn’t compile at all on 11 or higher).
Suggestions welcome, thank you.
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.
-
1
-
-
5 hours ago, Tommi Prami said:For me this is very hard to wrap my brains around.
-Tee-
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.
-
1
-
-
5 hours ago, JIMSMITH said:Looking for a person with good UI design experience to redesign 3 forms in Delphi 11.x Berlin. The components to be used are VCL, DevExpress, or TMS. Need modern look and a business UI with good color scheme.
This post may be better served in the Job Opportunities section off this forum.
-
On 5/9/2024 at 8:23 AM, Robert Gilland said:I am using Delphi 10.2. How do I define an array of records in the type library editor?
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.
When will we have a 64-bit IDE version ?
in Delphi IDE and APIs
Posted
The IDE is 32 bits. The 64 bit compiler is a separate executable, which is why it can only be used if you compile via MSBuild. It is intended for use on build servers as I understand it, not while you're working in the IDE.