TOpenPictureDialog for FMX? - delphi

In VCL I used TOpenPictureDialog for loading of image files because it's useful to see a preview when selecting from a long list of files. I also used it for loading my own binary file format by creating a class derived from TGraphic, overriding the load and draw functions and registering it with TPicture. Now I've moved to FMX and would like a similar preview, but there is no TOpenPictureDialog. My only alternative currently seems to be to create a custom form for loading these files, including the ability to browse folders, etc, which seems like a big job to replicate all the functionaly of TOpenPictureDialog. Before I do that I wonder if anyone knows of a pre-existing component that does this? I'd like to support Windows and OSX initially.
If I do end up making my own component, would it be easier to start from scratch or to derive from and extend TOpenDialog? It seems that TOpenDialog is just running the default Windows open dialog in Windows so it seems unlikely that I could do that.
This is one of the few things missing from FMX that is available in VCL.

Related

delphi integrate custom file editor into IDE

I have deveoped a custom file type, together with a custom editor (basically a tree with several data pages attached and a few extra buttons). OK, I can run it stand alone and that is fine, and even add it to the tools menu, but I would like to integrate it into the Delphi IDE so that my custom editor (or a similar new version) appears in the IDE, rather like a DFM file has a custom editor. I can find references to most extensions in the Delphi IDE, but not this one. Any guiding hands? Note that this is not a property or component editor (the file type has nothing to do with either of these) nor is it simply syntax highlighting of a text file.
AFAIK it currently isn't possible to reliably integrate a custom editor into the Delphi IDE. The required API simply isn't there. See QC89028 Custom Module support.
During the Delphi 2010 and XE betas I spent most my spare time trying to get a resource editor integrated. Although the effort had the official blessing of Embarcadero and got some, half hearted, support from the IDE engineer, I was never able to get them to deliver on their promises and surface the module API. I eventually abandoned the project.
Update: I've now checked my old correspondence regarding this and it turns out part of the problem was that IOTAModuleCreator (used to implement File|New for custom file types) and IOTAEditorContent (used to transfer data to/from the custom module) only supports text data. Binary data gets mangled.
You can probably do this via an IDE plugin that uses the ToolsAPI (see ToolsAPI.pas in the IDE's source folder (e.g. Program Files (x86)\Embarcadero\Studio\source\ToolsAPI\ToolsAPI.pas.)
For information on writing a plugin in general, see David G Hoyle's excellent blog. Once you know the basics - i.e., write a 'wizard' and get it to do something - you will need to work on integrating your editor.
I have never done this, and so I can't guarantee it is possible. However, some interfaces that look worth investigating and implementing are INTACustomEditorView, which represents a 'view' (file tab when that file is open - think the code editor, Welcome view, type library editor, etc) and IOTAEditorViewServices, to register your custom view. I do not know how you associate a view type with a file type, sorry - possibly something to do with the personality interfaces. You might also be interested in INTACustomEditorSubView which is what creates a tab on the bottom of a file.
Good luck, and if you find a solution please write here so that other people can learn too!

VCL Components not rendering pretty Windows styles

My delphi application looks nice and pretty in the editor, but when compiled it's seemed to being using super old rendering for the buttons and stuff. I thought my compiled applications used to look pretty like the editor. What could I have screwed up for this to be happening?
One suspicion: a while back I was messing with manifests on a different app that needed to find the actual program files directory. Could I have screwed up my delphi project trying too hard for that? This project is set to use runtime themes.
The top is in the editor, the bottom is the compiled version
Your program is being rendered without themes. Possible causes for that:
Your executable has no manifest.
Your executable has a manifest, but it does not specify v6 comctl32.
Your manifest does specify v6 comctl32 but the process is using an external compatibility mode.
Your program disables visual styles in code. For example with a call to SetThemeAppProperties.
Your program uses activation contexts to activate a different manifest from that linked to the executable.
These possibilities get progressively more far-fetched. Most likely you've somehow fluffed your manifest. That's easy to check with a resource editor.

Form/Button/other component styles

Ok, so I downloaded a .zip file of all different kinds of examples from embarcadero... the way the buttons look and among other things are completely different from when I just create an application within my Delphi 7. I believe these examples were made for or made at a new time... because the button look way different from the way the button when I put them on my application. the buttons from the example look very modern and sleek and have mouse over effects (This applies for all the examples..its not a custom component ) I was wondering I can get this effect in my own applications within Delphi 7.. I can do this by opening one of the examples and just erasing all the code... but that's not what im trying to do..im wondering how I can accomplish these styles.. how come the examples have these nice looking buttons and such..but when I make an app within D7 its much older looking and such..
I apologize if my question is hard to understand.. and I appreciate any help on this.
Thank you in advance.. I appreciate it.
If I understand your question correctly, you're asking about the native control appearance changes that were added by the addition of Windows Themes in Windows XP.
Delphi 7 supported themes by use of the XPManifest component, which does nothing but add a manifest to your application which tells Windows your app is theme-aware and therefore it should load a more recent version of the common controls library. You can find the XPManifest component in the VCL component palette on the Win32 tab, or simply add the XPMan.pas unit to your uses clause. Note that the themed drawing does not work for all controls (grids, for instance, are not drawn using themes, and IIRC neither is TSpeedButton - it's been a long time since I used D7, so I'm not sure exactly what is and isn't supported, but the support is limited).
Starting with Delphi 2007, there is built-in support for Windows Themes, which is available by default in new projects. It can also be enabled in older projects using a checkbox in the Project->Options->Application dialog.
(Of course the real answer is that if you want your app to have the features included in modern versions of Windows, you should upgrade from your Windows-95 era version of Delphi to one that is more recent.)

Updates for controls in Win3.1 palette

Some people are saying that I must update the controls in Win3.1 palette (especially TFilterComboBox) with modern ones. But does Delphi provide such new controls?
I need to create a GUI (somehow similar to Windows Explorer, consisting in a DirectoryListBox, FileListBox and a FilterComboBox) where I allow the user to easily explore for files of a specific type. Since the interface is centered around this Explorer, a TOpenDialog will be like hitting the customer with a hammer in the middle of his head. I need an 'easy to use' solution.
Unfortunately Shell Controls are not stable enough to be used as replacement.
The Shell Controls that come as a demo with Delphi only have to be installed, and you'll have some nice shell controls. There is, IMO, no big need to get 3rd party components for that.
Look for ShellCtls (or similar, can't check right now) in your demos folder. That Demos folder can be accessed from the Windows Start menu for your version of Delphi.
Update
They are not in a Demos folder, it is called Samples now. They can be found in Samples\Delphi\VCL\ShellControls. Install vclshlctrls.dproj first and then dclshlctrls.dproj.
In our application we use tpShellShock which works rather well. You may need to tweak it a little for Unicode Delphi, but if I recall correctly that was pretty simple to do.
Here's what it looks like:

Library to create forms/GUIs/dialogs from scripts?

At the moment, whenever I need a custom dialog, however simple, I use Delphi's form designer to create a new dialog form. The form is then wrapped in an easy to use ShowMessage() type function.
In some situations it would be easier if forms could be created at run-time from a script. The script would detail all form components and their properties, much like Delphi's .DFM files.
Creating GUIs from scripts could be useful in other situations as well. For example, a GUI of a mini application could be embedded into the window of an existing application. Or the GUI script could be modified at run-time to create GUI variations.
I could create something to do this myself, but I assume other people have already tackled this problem. However I can't find anything using google. Is there anything currently available offering this kind of functionality? (Free or otherwise) Or does it already exist in Delphi?
Check out some of the scripting solutions for Delphi. For example, the TMS Scripting Studio, dwScript, RemObject's, FastScript, etc. I believe some of them are able to use DFM's for this purpose.
http://www.torry.net/pages.php?id=280 Delphin v.1.21, it can process DFM files, maybe you just want the DFM to code converter.
You might try XI Library (commercial): http://xilib.com/
I have never used it, it's just something sitting in my bookmarks, but it looks like it fits the bill. Not a scripting engine, more of a way to define dialog boxes via XML. There's sample XML code right on the front page, just click "Show the example".

Resources