Where does Delphi store property information set at design time? - delphi

Whenever you set a property in the Object Inspector, it must be writing some code or somehow saving the information somewhere, but where? I want to know so I can set properties and events from code but the question is the one above. Where's the code?

It's in the Delphi form file. This file has the same name as your unit *.pas source code file but has the *.dfm extension.
The current source code of your form you will get also if you're in form designer and press ALT + F12. There you can modify what you need and with the same keystroke go back to the designer.
You can check also what other files might be generated by Delphi for your project here.

The object inspector does not write the "code" so much as it just saves your selections in the form data.
If you want to modify any properties from the code, just write
SomeObject.property = "sdfsdfsdf";

Values of all the property stored into respective .dfm file.
Right click on the DFM design time form and select view as text or you can directly open dfm file in notepad

Related

How can I set a TClientDataSet's data in the design view?

I have a TClientDataSet object that I've added to my form.
I've managed to define the fields through the object inspector. However, is there a way to define the data the TClientDataSet contains without doing it in code?
I've managed to do it by adding some AppendRecord statements to the ShowForm event; but I'd rather keep the definition of the TClientDataSet all in one place.
Prior to v10.2 (Seattle, Berlin, etc.), there were no facilities to do this.
You can store and load a file into the ClientDataSet or you can use the Assign Local Data (right click on the ClientDataSet) to load data from an existing source. However, you cannot append or edit the data from inside the IDE directly.
As of v10.2 (Tokyo) has recently added this as a feature.

Delphi TComboBox Dropdown fields filtering [duplicate]

Everyone probably knows what I mean, but to clarify the control would need to:
Fire an event when user edits the text. The event would provide a SuggestionList: TStrings which you could fill with matches/suggestions.
if the SuggestionList is not empty a drop down should appear.
Unlike combo, the control should not attempt to automatically select/auto complete or otherwise affect the editing.
So, is there a Delphi edit/combo control that works like that ?
Use the autocompletion feature built in to all Windows edit controls.
First, fill your TStrings object however you want. Then use GetOleStrings to create a TStringsAdapter to wrap it. (The adapter does not claim ownership of the TStrings object, so you must make sure you don't destroy it while the adapter is still live.) The adapter gives you an IStrings interface, which you'll need because the autocompletion feature requires an IEnumString interface to provide the completion matches. Call _NewEnum for that.
Next, call CoCreateInstance to create an IAutoComplete object. Call its Init method to associate it with the window handle of your edit control. If you're using a combo box, then send it a cbem_GetEditControl message to find the underlying edit window.
You can stop at that point and autocompletion should work automatically. You can disable autocompletion if you want, or you can set any number of autocompletion options.
You say you don't want autocompletion, but in the OS terminology, I think what you really don't want is called auto append, where the remainder of the string is entered into the edit box automatically as the user types, but selected so that further typing will overwrite it, and the user needs to delete the excess text if the desired value is shorter than one of the matches.
There is also auto suggest, which displays a drop-down list of suggestions.
You can enable either or both options. You don't need to filter the list of suggestions yourself; the autocomplete object filters the IEnumString list by itself.
You can use standard TComboBox and faststrings library (for stringMatches() function).
procedure TForm1.cbChange(Sender: TObject);
var
s:Integer;
tmpstr:string;
begin
//suggestions: tstringlist
cb.AutoComplete:=false;
tmpstr:=cb.Text;
cb.Items.Clear;
for s:=0 to suggestions.Count - 1 do
if StringMatches(suggestions[s],cb.Text+'*') then
cb.Items.Add(suggestions[s]);
cb.DroppedDown:=(cb.Items.Count<>0) and (Length(cb.Text)<>0);
cb.Text:=tmpstr;
cb.SelStart:=Length(cb.Text)
end;
If you just want to show a file or url list:
SHAutoComplete(GetWindow(eb_MyComboBox->Handle, GW_CHILD), SHACF_AUTOSUGGEST_FORCE_ON | SHACF_FILESYS_DIRS);
I first implemented this feature like Rob described it in his answer. Later I saw that TComboBoxEx has the property AutoCompleteOptions where I set acoAutoSuggest to True and acoAutoAppend to False. The ComboBox now filters its item list when doing some entry and shows the matching items.
I'm using RAD Studio 10 Seattle and XE2 but don't know if this feature is available in older versions.
To the last bit of your question: "So, is there a Delphi edit/combo control that works like that ?":
A bit late to the party but yes, I have written a free and open source component that implements the Google Place Autocomplete and Google Place Details API's:
It does inherit from the standard TComboBox but you can modify the code to work with any TEdit
https://carbonsoft.co.za/components/
or
https://github.com/RynoCoetzee/TRCGPlaceAutoCompleteCombo

Umbraco - Edit a custiom data type

I want to modify an existing custom data type in Umbraco. I tried to look for an option but somehow I can't see the Edit option in context. Does anyone have an idea about this ?
Your help is much appreciated.
Thanks!!!!
To create your own Data Type click right on the Data Types folder in the Developer section of the Umbraco Admin page select create and type in the name you want to call it.
A panel will then be displayed where you can choose which data type you want in the Property editor.
When you press the save button the settings relevant to the data type you have chosen will be displayed. They will also always then show up when you select that data type in the data types tree.
These are the only data type settings you can change in the Umbraco Admin section I know of.

How to adding new section in INI file using TJvAppIniFileStorage

I have a database application project written in Delphi XE and connected to MySQL Database using dbExpress. I use JVCL grid Components to show the records from the Dataset. It will be more efficiently if I can use another JVCL Components to do the FormStorage.
I've been suggested to use TJvFormStorage and TJvAppIniFileStorage for form storage. I have many forms on this project so I need to adding new section in my INI file to store the form size values but I don't know how to do that using TJvAppIniFileStorage.
The TJvAppIniFileStorage is just providing the DefaultSection() method which means it's just can modify and write into one section only which declared as the default.
Anyone can describe to me how to adding new section using the JVCL's TJvAppIniFileStorage?
Thanks in advance.
Is the TJvFormStorage instance the one that determines in which path of the abstract storage to put the data about this form, with the value of the AppStoragePath property.
You can use the special value '%FORM_NAME%' to determine that path automatically at run-time. The '%FORM_NAME%' is changed for the real .Name property of the form where the component is located, or if it is a frame, a dot list of the frame chain up to the form containing it. That way you can have different instances of the same class saving the info to different paths.
When you're using a TJvAppIniFileStorage instance as the data storage backed to save the form data to a INI file, that path is equivalent to the INI section where the information is stored.
In other words, if you want to store the info of your form in a section called 'MyForm', set that value to the AppStoragePath property of the TjvFormStorage instance in that form.
Use the Source, Luke! ;)
My guess is: It uses Parent.Name or Parent.ClassName to store parameters.
Another point: take in mind several monitors on user's computer. Almost no app takes in mind this case.

Need help with deriving from TImage (to store the path to image's file)

I have an Object Inspector, just like Delphi's, which I show at run-time to allow the user to change properties of components displayed in my app.
I would like to create a component derived from TImage with one extra property where I can store the path from which the image was loaded. To do so, I presume that I can subclass TImage, have an event to select the image by using something like ...
var OpenPictureDialog: TPictureEditorDlg;
if OpenPictureDialog1.Execute then
OpenPictureDialog1.FileName <-- contains what I want
But, if I wrap that in a proc/fn, what's the signature and how do I get it to be called when the user clicks on the ellipsis next to the Picture property in the Object Inspector?
Or perhaps my question ought to have been whether there is an existing 3rd party component which already does this ...
50 point bounty for a free component which can be used in commercial applications (I will increase the bounty for an very good component)
If anyone can give the URL of a component that does this then I will start another bounty, 100 this time, and award it to them
That depends on how your Object Inspector works. It would help if we knew where you got it from.
The way it works in Delphi's Object Inspector is that BPL packages can register property designers with the IDE, so when it sees a certain type, such as your custom TImage, it opens that designer instead of whatever it would normally open. See if your Object Inspector supports this, or if not, if you can add the functionality.
TImage does not know the file name of the loaded picture. Because it receives only the image content, not the file name. So in order to get this information you must replace that default open picture select dialog with your own, and in it you pass the filename and the image content. Then your custom TImage can store this information.
MiTeC's ImageEx is a small, simple and free component that extends Delphi's TImage. It doesn't have a "path" property, but it has an "about" property that you could use as the path property, or as a template to add your own path property.
For something more comprehensive and not too expensive, you might try the Envision Image library by Interval Software, It is integrated with Delphi's TImage. It costs $69 US.
If i understood correctly, you want to load an image, then get the path to image's file.
This should work:
procedure TForm1.Button1Click(Sender: TObject);
var Imagefilepath:String; //Declare Imagefilepath:String;
begin
//Get name of file path
if opendialog1.Execute then Imagefilepath:=opendialog1.FileName;
//Load the picture
image1.Picture.LoadFromFile(Imagefilepath);
//show the name
showmessage(Imagefilepath);
end;
And make sure you have written in uses "JPEG" so that it loads JPEG images
Easy Peasy

Resources