Topendialog not displaying file extensions - delphi

This problem only occurs on applications that were previously designed under Delphi 7 and migrated to Delphi 2007 running on WinXP.
I tried for ages to get this problem sorted with no luck.
As far as I am aware, the Topendialog is a Win32 dialog wrapper and it should inherit the windows folder options which, in my case, is set to show the file extensions of all files.
Now, if I create a new application and drop a Topendialog on it, when it runs, it shows the file extensions as expected.
If I drop the same dialog onto an existing application and run, it doesn't show the file extensions.
If fact if I write a filename string into the filename property before calling the dialog a la 'Myfile.txt', when the dialog is displayed the filename is shown as 'Myfile', the extension doesn't show and neither do any files in the list.
Has anyone else seem this behaviour?
Anybody have any workarounds?
Edit: Images uploaded to shown differences between Topendialog on a new project and existing project.

OK, I have a workaround for this problem.
It turns out that calling SHGetSettings in the right place actually stops the problem from occurring.
So the workaround is to put it in the project source right at the start.
eg
program Blah;
uses
Forms,shlobj,
blah,
.... etc
{$R *.TLB}
{$R *.RES}
var ShellFlags:TShellFlagState;
begin
SHGetSettings(ShellFlags,SSF_SHOWEXTENSIONS); .....
I have no idea why this makes it work, it shouldn't make any difference as its only a query but it works.
So, thanks to Justmade for suggesting that API call.

Related

How can i deny an unit from deactivating Code Insigth in Firemonkey?

I want to import an unit to save ini files with this unit from Github, but, as soon as i import it, code insight stops working - instead of opening itself doesn't even open anymore. It isn't a change in the IDE options, as it works in every unit/project in which i don't use it. So, the line
Uses: [...], FMX.IniFile;
Seems to deactivate Code Insight. I use Rad Studio 10.3. Is this a known issue or does a solution already exists?
Thanks
Edit: In order to use the file correctly, i need to import the files for android and Apple as well, which are in the same directory as the main FMX.IniFile.Pas, these might cause the problem as well
Sorry, I just tried what you describe in your q and code completion continues to work fine.
Here's exactly what I did:
Created a new multi-platform application.
Saved the default new Form1 unit the IDE creates and the project.
Created a new unit and cut and pasted the source of FMX.IniFile into it.
Saved the new unit in the project's folder under the name FMX.IniFile.Pas
Added FMX.IniFile to Form1's unit's Uses clause.
Added a TButton to Form1 and did a Save All
Created a `Button1Click' event on Form1.
Switched from the form editor to the code editor and, in the Button1Click handler skeleton and started to type
Self.c
and the IDE immediately offered the various properties of Form1 beginning with c as code-completion possibilities.
I'm using Delphi 10.2.3 on Windows 10 Pro 64-bit.

Delphi .exe after build error

good day! i have a project and it runs perfectly, i did that project 3 months ago. Then, i tried to put some changes and even BUILD ONLY the project (no additional codes). When i open the .EXE it appears errors like this.
when i clicked DON'T SEND
and when i clicked OK
When i opened the form this message appers:
How to fixed it? I really need to add some functions to that project.
Thanks in advance!
Your .dfm file refers to a property that is not published by the component which is being streamed. The streaming framework is attempting to read into a property named Quality of an object named frxPDFExport1. And that object does not publish a property of that name.
Most likely there's a mismatch between the design time package that you used to generate the .dfm file, and the run time component that is reading that .dfm file. Have you upgraded one and not the other recently?
I'm afraid I cannot give you precise steps to fix the problem, but what I describe above is what is happening. Hopefully that will be enough to lead you to the solution.
You must have updated the component used, which looks like Fast Reports. You need to open up the form in Delphi and the new property will be added by Delphi. Any other forms that use the same component will also need to be opened up to update the properties.
When the error reading form message comes up, click ignore. This should add the missing property. You will want to view the DFM as text to make sure the property has been added.

Unable to display .chm help file in Delphi XE2 app - why?

We are porting our app to Delphi XE2 from Delphi 6. Problem is, the help file will not display no matter what I try.
Using Delphi XE2 (Update 3) on Win 7 64.
Using a valid help file (.chm) that works with my Delphi 6-built app.
I create a simple app with one button that calls help thusly:
Application.HelpFile := 'Help.chm';
if Application.HelpFile <> '' then begin
Application.HelpContext(0);
end;
I have HTMLHelpViewer in my uses clause.
The help file is in the same directory as the app. When I click on the button the help file is not displayed! I see nothing. No errors.
I tried several different help files, all of which are valid and I can open via Explorer.
I also tried calling the table of contents directly like this:
HtmlHelp(0, Application.HelpFile, HH_DISPLAY_TOC, 0);
Nothing is displayed this way either.
What the heck am I missing here? This is a show stopper if I can't make the help file display when users hit the F1 key.
------ EDIT - PROBLEM SOLVED! ------
Sigh, I'm an idiot, but only partially. :)
The simple app indeed had the help file in the wrong directory. The new Delphi XE2 has the default output in a sub-directory, not the original directory like Delphi 6 used to do. I've been bitten by that twice now. :)
So, once I figured that issue out I had to go back to the original app and figure that one out.
It turns out we had our own HTMLHelpViewer.pas unit in the project (BIG project) and that conflicted with the built-in HTMLHelpViewer unit that comes with Delphi XE2.
Once I whacked our version of that file and removed it from the hard drive and added in Delphi's version everything works swimmingly.
Thanks for the knock on the head to help me figure this out.
The only explanation that I can see, given the information that you have provided, is that the help file is not in the current working directory.
I would keep the working directory out of the equation and set Application.HelpFile to be the fully-qualified path to the help file.
Was the helpfile installed by an installer?
If not, right click it and select "unblock" in the properties

Delphi: How to get rid of "Ancestor of TMyForm not found error'?

I have some forms inherited from a TMyForm (TMyForm is a 3rdparty component with source code form).
When I open in the IDE my forms inherited from TMyForm I have:
Error creating form: Ancestor for
'TMyForm ' not found.
The workaround is to open the TMyForm unit in the IDE and then try top open my inherited forms.
But how can I avoid that Delphi gives this error and is able to open my forms even if TMyForm is not opened in the IDE?
You need to have the parent form opened in the IDE or added to the project, there's no workaround, unfortunately. Over here: Register custom form so I can inherit from it from multiple projects, without copying the form to the Object Repository folder I attempted lots and lots of things, without success.
My Workaround. There are several ways:
Add to project full path to all of the parent form. Uncomfortable, because of absolute path
Add package with parent forms to the project list. In this case, no problems there. But every time it is necessary to open a components
in the delphi environment.
Use a temporary solution from embarcadero.
There is automatically opens all the child forms:
Ticket, was created about 10 years ago: http://qc.embarcadero.com/wc/qcmain.aspx?d=8376
Here you can download the version for Delphi XE2: https://bitbucket.org/hemn/autoopenunit
I recommend it!
I've been searching all over for a solution to this and it seems I've finally found one.
I'm using a package with several base forms and frames.
I've added these to the repository, yet still the error came up.
Some of the forms and frames didn't show a 'dfm' in the Project Manager, it seems key to this, is to edit the .dpr file and add the name in curly brackets:
fIBSConnectionForm in 'GUI\BaseGUI\fIBSConnectionFrom.pas',
into
fIBSConnectionForm in 'GUI\BaseGUI\fIBSConnectionFrom.pas' {frmIBSConnectionForm},
and for frames, make sure to use {f...: TFrame}
After doing this and restarting Delphi, I could open descendant forms again!

One project in Delphi 2007 doesn't show procedure name in the IDE Obj Inspector's Events

I have a Delphi project in 2007 that doesn't show the procedure names in the Object Inspector's Events such as Form OnClose, OnCreate or OnShow in the IDE. The code is there and if you click on OnCreate (for example) you are taken to the code and the IDE fills in the name of procedure. However on reload, the procedures are missing from the IDE again.
This same project causes various error messages when Delphi closes also, but I am not sure if this is related (no other project developed under this Delphi does but this one is the largest app and uses several 3rd party add-in libraries).
I have moved this app to various Delphi 2007 installations and it reacts the same, so it isn't a corrupt Delphi situation. Is there any way to rebuild or fix a corrupt project like this? Any help would be appreciated.
I would try to remove all the files and keep only the dpr and the pas/dfm files in case it's a corrupted project file.
I would also double check if there is any Form inheritance mess, as I have seen somewhat similar issues with the inherited event handlers. (look at the dfm files directly)
Try delete all the .DCU's, close Delphi, restart Delphi then rebuild your project.
Delphi's IDE takes several liberties with your code without warning you.
In particular : if you have a callback (eg: "TMyForm.FormCreate") linked in the dfm, and the IDE detects that the function's body is empty, when you save your unit, the ide removes the declaration and the implementation before saving your file.
Adding anything (even a simple "//") in the function's body prevents this : try typing some code or some comment in your function before closing your Delphi.
As for errors when Delphi closes, there can be so many reasons.
Do you have any third-party components or experts installed ?
Have you tried installing IDEFixpack for D2007 ?

Resources