-
Content Count
2921 -
Joined
-
Last visited
-
Days Won
170
Everything posted by Uwe Raabe
-
It shows the return type of the selected property or function, void in case of a procedure, empty if nothing like that is selected. I have no CnPack installed here.
-
There must be more than only these two steps. Changing something in a unit and closing it without saving happens several times in an hour without showing any problem - not only on my system I guess.
-
Are you trying to say, you are using interfaces only to avoid being responsible for destroying your object instances?
-
Yes, the variable where the date is going to be stored.
-
Let me guess. Your code looks something like this: if TryStrToDate(Edit1, theDate) then But it should be if TryStrToDate(Edit1.Text, theDate) then
-
What is the best way to convert between UnicodeString and UTF-8
Uwe Raabe replied to alank2's topic in General Help
Well, I cannot speak for C++-Builder, but in Delphi there is type UTF8String and you can just assign to and from string: var S: string; u8: UTF8String; begin S := 'Hello World'; u8 := S; u8 := 'Hello World'; S := u8; end; -
What is the best way to convert between UnicodeString and UTF-8
Uwe Raabe replied to alank2's topic in General Help
What variable type are you going to store the UTF-8? -
Strange behavior with "is" operator
Uwe Raabe replied to Sonjli's topic in Algorithms, Data Structures and Class Design
Check if you have more than one declaration of MyAttributeOne. -
ShowModal does not show window after a few tries (It does not pop up)
Uwe Raabe replied to ChrisChuah's topic in VCL
IMHO, using caFree seems not the best approach for the ShowModal case. With caFree a message CM_RELEASE is placed inside the message queue of the form, which will lead to Free when this message is processed later. This is OK when calling Show for the form. I suggest to keep the default caHide Action in the FormClose and add a FDetailForm.Free in the finally block. -
When the MainForm is closed the application is terminated. That implies that all forms created with Application as owner will be destroyed, but not closed (so OnDestroy is called, but not OnClose). The order depends on the components order inside Application. Any form created without an Owner will just vanish.
-
Is it possible to make changes to the source code for reserved words?
Uwe Raabe replied to Al T's topic in Delphi IDE and APIs
No, that is not possible. -
Conditional compiling - Delphi has a bug
Uwe Raabe replied to KodeZwerg's topic in RTL and Delphi Object Pascal
If it is a regression, it dates back to Delphi 7 (cannot test for Delphi 6). Given that conditional expressions were introduced in Delphi 6 I wonder if that has ever worked.- 5 replies
-
- delphi
- conditional
-
(and 1 more)
Tagged with:
-
What is the reason for this code in TTestDataProvider.GetProvider?
Uwe Raabe posted a topic in DUnitX
The current implementation of one overload of TTestDataProvider.GetProvider looks like this: class function TestDataProviderManager.GetProvider(const AClass: TTestDataProviderClass) : ITestDataProvider; var key : string; begin result := nil; if (FList.ContainsValue(AClass)) then begin for key in flist.keys do begin if (flist[key] = AClass) then begin result := TTestDataProviderClass(flist[key]).Create; break; end; end; end; end; Is there any reason why that cannot be written as: class function TestDataProviderManager.GetProvider(const AClass: TTestDataProviderClass) : ITestDataProvider; begin result := AClass.Create; end; With that one could avoid registering the provider. The reasoning for my question is, that I have a base provider class and several derived classes to overcome the lack of ability to parametrize a data provider instance. All these derived classes are local to one test unit and I would like all of them to have the same class name. Unfortunately the registration requires me to give distinct names for them and you know - naming is hard. Just declaring the derived class and use that in a TestCaseProvider attribute would simplify this a lot. Concrete: TTestDataFilesProvider provides a list of files, but requires the path and search pattern as parameters. Now I derive individual classes (with fixed values) immediately before they are used. -
TFDScript.ExecuteALL does not seem to behave as expected
Uwe Raabe replied to Dustin T Waling's topic in Databases
Perhaps you are just expecting something the method isn't intended for. ExecuteAll doesn't execute all scripts in the SQLScripts collection. It only executes the first one (the main script), while the others are meant as subscripts to be called by name from the main script or other subscripts. This is an example from the docs: with FDScript1.SQLScripts do begin Clear; with Add do begin Name := 'root'; SQL.Add('@first'); // explicitly call 'first' script SQL.Add('@second'); // explicitly call 'second' script end; with Add do begin Name := 'first'; SQL.Add('create table t1 (...);'); SQL.Add('create table t2 (...);'); end; with Add do begin Name := 'second'; SQL.Add('create procedure p1 (...);'); SQL.Add('create procedure p2 (...);'); end; end; FDScript1.ValidateAll; FDScript1.ExecuteAll; That said, TFDScript is not a container for scripts to be executed in sequence by calling ExecuteAll. That has to be done by your own code. -
What graphic class is image? You can retrieve that from imgPerson.Picture.Graphic.Classname
-
FireDAC - TFDQuery - How to default calculated fields in the dataset to ReadOnly=False
Uwe Raabe replied to JonathanW's topic in Databases
In that case changing that field value inside the program seems a pretty rare case. The shown queries give the impression that some dummy fields are returned with no relation to the data in the database. As there are better ways to create such fields in the program it makes the query the wrong place for it. -
FireDAC - TFDQuery - How to default calculated fields in the dataset to ReadOnly=False
Uwe Raabe replied to JonathanW's topic in Databases
Exactly! The approach used in the query is just the wrong one. -
That's correct. So we need to know the Delphi version being used.
-
What about using TDBImage instead of TImage?
-
Reinstalling Delphi: Use Installer for 11.1 or 11.1.5?
Uwe Raabe replied to Achim Kalwa's topic in Delphi IDE and APIs
As mentioned in this blog post: Available Today: the C++Builder and RAD Studio 11.1.5 C++ Code Insight Update (emphasizes by me): -
Ask for comments to improve this code
Uwe Raabe replied to Berocoder's topic in Algorithms, Data Structures and Class Design
procedure TForm1.SomeControlEvent(Sender: TObject); begin var myLabel: TLabel; if Sender.Supports<TLabel>(myLabel) then myLabel.Caption := 'handled'; end; -
Ask for comments to improve this code
Uwe Raabe replied to Berocoder's topic in Algorithms, Data Structures and Class Design
Thinking out of the box here: type TSupport = class helper for TObject public function Supports<T: class>(out ResObj: T): Boolean; end; function TSupport.Supports<T>(out ResObj: T): Boolean; begin ResObj := nil; if Self is T then begin if not ((Self is TBoldObject) and TBoldObject(Self).BoldObjectIsDeleted) then ResObj := T(Self); end; result := ResObj <> nil; end; -
Ask for comments to improve this code
Uwe Raabe replied to Berocoder's topic in Algorithms, Data Structures and Class Design
That would require to pass a TObject variable to that parameter, which is not helpful. An out parameters works like a var parameter, where the types must match exactly. -
Ask for comments to improve this code
Uwe Raabe replied to Berocoder's topic in Algorithms, Data Structures and Class Design
Which version of Pascal Analyzer do you use? I couldn't reproduce it here. -
The best way to handle undo and redo.
Uwe Raabe replied to skyzoframe[hun]'s topic in Algorithms, Data Structures and Class Design
You might be interested in the Delta property of TFDQuery.