How to intermix Windows dialogs and VCL forms? - delphi

I want to interoperate with third-party application and to provide a dialog box to it. API wants standard DialogProc and DLGTEMPLATE pointers. However, i'd really like to take advantages of VCL, form designer and such. How can i do this? Which code samples i can study?
Technical:
How can i do:
embed VCL form (or frame) into dialog box created from some boilerplate DLGTEMPLATE i supplied.
connect VCL WndProc to windows DialogProc.

Delphi VCL does not interoperate with standard windows Dialogs designed with dialog resource types. Visual studio supports creating dialog resources, still, even in VS 2010, but Delphi never has. Whatever it is that you've got an API for, please mention exactly what it is, and this will (if it isn't some obscure or in-house thing) increase the odds that someone can help you. Since the API expects a dialog handle, and expects to show that dialog and then run your dialog procedure, and send you stuff, you have two choices:
Don't use delphi at all. Use visual studio 6, because that's about the era that this API must have been designed for.
Use delphi, but use a third party dialog designer from Visual Studio 6 or Borland C++ 4.5, or so, we're talking about 1996 era here, and then write your DialogProc without benefit of any VCL controls or vcl code whatsoever.
I have never ever heard of anybody daft enough to rely on windows dialog resources to build their plugin-screens-in-a-dll-via-an-API. I'd really like to know what app it is you're trying to extend.
You might be able to add a modal dialog box that you show modally, from your code, and such a modally shown sub-dialog (a second level dialog) could use the VCL, but the top level dialog is not even under your control.

Related

Using FMX forms in a VCL application in XE7?

Even though it is not officially supported by Embarcadero there are many examples showing that you can include a FMX form in a VCL application e.g. MonkeyMixer and this SO question.
However, when I create a test application with only one empty VCL form and one empty FMX form, I get two problems:
There are two application icons in the task bar (apparently one for
each instance of TApplication i.e. VCL and FMX)
It crashes when I close the application (when it calls TStyleManager.UnInitialize in FMX.Forms.FinalizeForms).
How can I make this work?
I need this combination as we want our application to be native on Windows, Mac OS and iOS. Therefore on Windows it is a VCL application and the other OS's are FMX using the TMS native components. We have some large custom graphical components that are made for FMX, and they must also work on Windows.
Edit:
I see only two alternative solutions, and I like none of them:
Use FMX on Windows too. I don't like the idea of styled components instead of native. Experienced users can easily tell the difference.
Maintain to sets of our custom components: VCL and FMX editions. That will require some work, and also the graphical features of FMX are much better than VCL.
I've needed to host an FMX app inside a VCL app for display and training purposes. The FMX app is really an Android target and the VCL a Windows 'demonstrator'. The FMX hosting is done using TFireMonkeyContainer hosting the FMX main form. Yes it's got slight wrinkles but it works ok and I'm sure we'll find a way to improve things.
My FMX main form is created at runtime and has visibility of only FMX.Forms. It is then passed to TFireMonkeyContainer and is destroyed by it when the VCL app closes.

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.)

Behavior in Delphi Documentation Viewer

Delphi XE2 Update 4 Hotfix 1 and Help Update 6 for XE2.
If I am in the IDE, highlight an object name such as TLabel, then hit F1, I am transported to the description of Vcl.StdCtrls.TLabel in Delphi's help application. The page gives me information for both the Delphi and C++, but I can click on Display Preferences in the top right and 'un-tick' C++ so only the Delphi information is displayed. But now, if I click on TEdit (either by clicking within the help page under See Also or by selecting and F1-ing in the IDE), the Display Preferences automagically reverts to both Delphi and C++ when the TEdit Help is displayed.
If, on the other hand, I go directly to embarcadero online help, for example: http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.StdCtrls.TLabel to get the same information (using Chrome), the browser (?) remembers my Display Preferences and, once I have un-clicked C++, will only show me the Delphi information if I click on TEdit or further pages.
This drives me to distraction, as I am not the least interested in C++. Have I missed some option within XE2 to only select Delphi in Help's Display Preferences, or is this a 'feature'.
I don't think there's anything you can do with XE2's docs to fix this.
This was improved on in XE3's documentation, and improved even further in XE4's and since there have been four versions released since XE2 there won't be any further updates to it.
(You can't compare the online documentation with the local disk documentation; the first uses the functionality of the web browser, while the second uses the functionality in the MS documentation viewer, which happens to contain a web browser control but implements the functionality in the app itself instead.)
Answer by Ken White

How to implement this type of Docking?

Take a look at this Open Source Application called Construct
.
It uses Panel Docking where you can drag a Panel, and then some on screen visual aids to show where the Panel may be docked, as seen below:
Before Dragging/Docking
During Dragging/Docking stage
When dragging/moving one of the Dock Panels the Window now looks like this:
As you can see, when dragging/moving the Object Panel it displays the visual aids of where the Panel can be docked. It also moves around like a free Window when not in a docking position. The same applies when dragging/moving other Dock Panels such as the Project Panel in this example.
This is an example of an Application using this, I have also seen other Applications employ this too.
Is there a Delphi way of acheiving this behaviour?
I have some panels that take up some space, freely moving or docking them would be useful feature to implement.
Thanks.
UPDATE
It seems the LMD Components offer such a component which I may look into.
See this old question for docking library.
Recommendations for a docking library for Delphi / C++Builder?
Why there shouldn't be a way of achiving this in Delphi?
I don't know if there are free components around but DevExpress offers a library for it and other vedors for sure have such libraries in there portfolio too.
If you're interested in coding such a thing your self, you might take a look at Dockpanel Suite it is written in C# but the WinAPI fundementals behind it are the same.
Addition:
does anyone know of good delphi docking components?
There's a new release of the DevExpress docking components coming soon. It includes the Visual Studio style docking that you show in your image.
See this link for more information: http://community.devexpress.com/blogs/ctodx/archive/2011/04/26/sneak-peek-visual-studio-dock-style-for-vcl-docking-library-coming-in-v2011-1.aspx
Delphi supports this out of the box. There's a limited demo (meaning they didn't demonstrate all of the functionality) in the Samples (Demos) folder, depending on which version of Delphi you're using. In Delph7, for instance, it's in $(DELPHI)\Demos\Docking, and in D2007 and up you'll find it in C:\Documents and Settings\All Users\Documents\RAD Studio\x.0\Demos\DelphiWin32\VCLWin32, where x.0 refers to the Delphi version. The locations for D2009 and XE will vary if you've installed on Vista or Win7, but I'll trust you can track them down; if you can't, use the Start Menu's Embarcadero RAD Studio <version>, and choose Samples.
There's also the TDockTabSet component included in later versions of Delphi, and you can find an article and code at Embarcadero Developer Network explaining and demonstrating it's use. (TDockTabSet is pretty much what's used in the IDE for docking now, I believe.)
I did a few intro videos on dockable forms in Delphi, there are available here and here. They're also on YouTube - Part 1, and Part 2. They are pretty introductory however.

Switch GUI application behavior between SDI and MDI

I currently have an SDI application that is build with Delphi 7, I want the final user to choose the type of interface between SDI and MDI at runtime. my question is how can I change the behavior of the application between SDI and MDI at runtime?
Currently I know a couple of applications build with delphi that allow this: EMS SQL Manager and TOAD.
thanks in advance.
Download the Jedi JVCL and install it and look at the Demos for JvDocking "docking in code". They do this exactly.
They mean that you do not actually use the FormStyle=fsMDIChild unless you want lots of problems. MDI is "emulated" when you need it by docking in code.
Do not convert windows into frames. This is a bad solution.
For an MDI-like environment, that does not have the MDI problems, use a docking solution (components either commercial or open source that support docking). I use JvDocking which is included in the JEDI JVCL, which is free and open source.
You use your forms in both "docked" and "undocked" (floating) modes, and this gives you a docked IDE look and feel (VIsual Studio and RAD Studio), and an undocked IDE Look and feel (RAD Studio in undocked, or classic delphi 7).
I would convert my current windows into frames and put these frames with align=alClient into either mdi child windows or normal windows as configured.
But beware: I have never actually done this, so there might be problems that I don't know about.
At runtime set TForm.FormStyle either to fsNormal or fsMDIChild depending on if you want SDI or MDI.
Like #WarrenP's solution, I strongly recommend a docking-based solution. It should be said that you don't need to use Jedi VCL to achieve this. As an example, here's a very simple (all-native-vcl) component I've produced which allows you to simply drop on as many instances to your form(s) and set their alignment to enable docking (and tabbed docking) in those regions.
MDI itself is an accident waiting for a place to happen. There are solutions available to achieve the "MDI look and feel" without using MDI itself, though I've yet to encounter one I'd consider "neat" (probably for a lack of looking).
Ultimately you should probably question the wisdom in providing MDI as an option. Docking (with or without the ability to undock, and especially when Tabbed Docking is a user-determined choice) feels more modern, and (done properly) can be far more flexible and intuitive than MDI ever was.
Just my 2-pence worth.

Resources