Add fmx form to Delphi Package - delphi

As the title says really. How can I add an FMX form to a delphi package? In the package I have a Tpanel descendant component - which is all installed fine. What I'd like to do is include a form in the package so that when I click on the panel at runtime the form pops up for example. (I don't want to use the FMX form at design time - just at runtime, so I just want to include the FMX form as in the package, the component has design time properties though)
It seems I can only add a VCL form to the package - when I right click and 'add new' to the package, it tries to add the VCL to the package - which I don't want. I want to run it on OSX.
I've found plenty of adding VCL forms e.g. Adding forms and frames to packages probably something obvious I'm missing - tia
Delphi XE6 on Windows 8/OSX target

Packages have affinity to a particular framework. Your package appears to be a VCL package. In the .dproj file you will find
<FrameworkType>VCL</FrameworkType>
Change this to
<FrameworkType>FMX</FrameworkType>
to have affinity to FireMonkey.
Although I've not done so recently, I expect that you get to make the framework affinity choice when you create the package. Presumably you chose VCL. Or the package was created before FMX existed and the project upgrade process added (correctly) the VCL framework setting.

Related

What can cause DCLUSR.$$$ access denied error whilst installing a user defined component

I have found the component TColorbutton and am trying to install it in Delphi 10.4.2. I know that is currently embedded in FMX, but I want it available in VCL. However, the installation fails:
Failed to save project "c:\program files (x86)\embarcadero\studio\21.0\lib\win32\release \dclusr.dproj". The following error occurred while saving: Cannot create file "c:\program files (x86)\embarcadero\studio\21.0\lib\win32\release\dclusr.$$$"
What can I do to get it installed? Or, is there a way to use the FMX version within VCL?
The installation fails because you are trying to install the component while its unit is under the C:\Program Files (x86) folder. Since this folder is one of the protected system folders, Windows prevents Delphi from creating necessary files during compilation.
You should move the component File to a non-protected folder, like C:\Users\<YourUsername>\Documents\Embarcadero before you try to install it. This way, Delphi won't be blocked by Windows while compiling the needed component package.
It seems you're trying to "extract" a component from the FMX lib and "move it over" to the VCL lib. DO NOT DO THAT!!! If you THINK you got it to work, you probably hosed-up your installation.
You didn't say what library you installed this into, but you should always install your own components into your own component library. I use one that I call "AddOns". Some people use their name. If you try to install it into one of the system libs, you're going to find it impossible to install Delphi updates as well as any libraries that depend on those components. NEVER UPDATE DELPHI COMPONENT LIBRARIES!!! (Yes, you CAN, but just DON'T!)
VCL and FMX use totally different approaches to writing to the screen (among other things), which is why they are separate libraries. FMX has a layer between the component and the platform's "screen" (OpenGL I believe), while VCL calls the Windows API directly.
If there's stuff in FMX that you'd like to see in VCL, then look for a VCL-specific component that does what you want. Or build your own that derives from an existing one.
Search Google for TColorButton and you'll find several references to things you can use. There are some on Torry's.
There's an article on it in the newer about.com site (ThoughtCo.com) but I couldn't find a link there to the source code.
Google is your friend. Try this:
https://www.swissdelphicenter.ch/en/showcode.php?id=1100

Advantech DAQNavi ActiveX Components in Delphi 10.4

Has anyone had any success installing the Advantech DAQNavi components in Delphi 10.3 or 10.4 ?
The big problem is that I cant find a detailed step by step explanation of how to install activex components into Delphi 10.3 or 10.4.
I pay embarcadero for support but their response is "Ask Advantech" !
I have installed the Advantech DAQNavi ActiveX components into Delphi 10.3 and everything appears to go OK without any issues but If I then add them to a form nothing shows on the form. The components appear in the structure list and I can edit them that way, the same applies if I open a project created with an earlier version of Delphi that uses the Advantech ActiveX components.
The fact that something has not worked correctly during the install worries me and I dont feel comfortable compiling projects using these components with this version of Delphi.
Following is a step-by-step guide to installing an ActiveX component for which you have a type library in Delphi Sydney (v.10.04).
Assuming you have a drive D: (I have never trusted Windows with saving important work on its boot drive), create the folder d:\D104, and 2 subfolders below it, d:\D104\Units and d:\D104Pkg.
Start the Delphi IDE if not already running, or do a Close All if it is.
Goto Component | Import Component in the IDE main menu.
Select your type lib from the pop-up
Click Next and set Palette Page to "My Imports"
Click Next and set the radio button to Install to New Package.
Click Next and set the Package name to e.g. D:\d104\Pkg\MyPackage.dpk and fill in the Description box as you think.
Click Finish. The IDE will generate
a file in D:\D104\Units named like MyTypeLib.Pas (but see the comment below step 9) and
the file D:\D104\Pkg\MyPackage.dproj
It will then attempt to compile D:\D104\Pkg\MyPackage.Bpl, which is the package that you need to install in the IDE to have the component(s) in your typelib show up on the MyImports tab of Delphi's Component Palette. Btw, a .Bpl file is a special sort of Dll which, as well as your components, contains some "behind the scenes" code to help .Bpl files get along with one another and the IDE, including memory-sharing.
Assuming the compilation generates no errors, go to Component | Install Packages in the IDE and use the Add button in the pop-up to add D:\D104\Pkg\MyPackage.Bpl and you're done.
If the compile in step 9 doesn't appear to have done anything, it's most likely because the BPL has been generated to the wrong place. Find it and delete it (because otherwise it will come back to haunt you), then:
Open D:\D104\Pkg\MyPackage.dproj as a project in the IDE, then from the IDE's main menu, click Project ! Project Options & on the Project pop-up, select the
"Delphi Compiler" tab, and on the right, set the package Output Directory to D:\D104\Pkg
and click Save, then re-compile the project and use Component | Install Packages to install the .Bpl file.
=================================
Fwiw, in the D5/D6/D7 era, adding components to the IDE was much simpler (and IME less error-prone) because you could do the entire process using a stand-alone Package Editor.\Units
Embarcadero have now looked into it and responded :
"It is bug... it was a fix, for another bug this is one of those good intentions paving fixes."
Apparently the bug simply prevents the control appearing on the form at design time and does not affect the operation of the OCX.

Can we use Popupmenu in FMX?

I am developing a mobile app in FMX where i need Popupmenu but it is showing disable in Tool Palette i cant use it but in VCL its enabled in Tool Palette and can use it. I just want to know if Firemonkey supports Popupmenu or my installation is having problems or we have to use other tools instead of Popupmenu in FMX? or what else can I do?
and actually i opened one VCL project and copied popupmenu from there to FMX and wrote code on one button and that code is
procedure TFRM_Party.BTN_Party_OptionClick(Sender: TObject);
begin
PopupMenu1.Popup(10,10);
PopupMenu1.Parent := Self;
end;
this code is not showing any error and also not performing also.
what to do? anybody having idea?
The short answer to your question is "Yes", you ought to be able to use the FMX version of TPopupMenu in a project created from File | New |Multi-Device Application in the IDE. If you can't find the FMX TPopupMenu on the Component Palette, something must be wrong with your Delphi install. I'm not quite sure what you mean when you say that it's "disabled" - components are usually either on the Component Palette or not, I don't recall seeing one looking disabled there.
You don't say in your question which version of Delphi you are using, but if it has FireMonkey at all, AFAIK it definitely ought to have the FMX version of TPopupMenu.
In Delphi 10.2 Seattle, for example, the FMX TPopupMenu appears on the "Standard" tab of the component palette, and is contained in the source unit FMX.Menus along with TMenuBar and TMainMenu, amongst others.
If you go to Component | Install packages in the IDE, the pop-up should show Embarcadero FMX Standard Components in the list, which is the file dclfmxstd250.bpl in the bin folder of your Delphi install. If that package isn't listed, that explains why you can't find the FMX TPopupMenu, but if that's the case for you, your Delphi ought to be lacking a lot more FMC components besides TPopupMenu. However, it should be easily solved by installing the .bpl file (or equivalent in your Delphi version). If the package is there, clicking the Components button to the bottom right of the pop-up should bring up the entire list of FXM standard components (which in my case does include TPopupMenu).
If your Delphi does include the Embarcadero FMX Standard Components but is still lacking TPopupMenu, you might try creating a new Package, adding FMX.Menus.pas to it and compiling and installing it in the IDE.
BTW, although it is possible to set up a combined FMX + VCL project (Google for how), just because you might be able to put a VCL TPopupMenu on an FMX Form doesn't mean that it's going to work.
Components are Grayed if you can't use its on current OS(your current choice in top combobox)

Error Loading a Form

I am a .Net programmer and I'm currently debugging a Delphi application and as I go along
I encountered the following error:
Could you explain to me what is this error, and how I can resolve it?
I am new to using Delphi.
Error Explanation
The error that is been presented to you is telling you that a component on that form is not registered in the IDE, in this case TsStatusBar which is from the AlphaControls library: http://www.alphaskins.com/
The form would have been saved at some point with TsStatusBar placed on the form. When any component is added onto a form they leave references to the component in both the forms source file (*.pas) and the inside the forms dfm. This is why you are getting this error, because the component cannot be found, yet the references linking to it still remain.
Option 1 - Install the AlphaControls packge
The best option would be to install the components that are missing, this will solve your error problem as shown in your question.
Option 2 - Convert Project
AlphaControls provides a tool to convert a project from standard VCL to AlphaControls and vice versa, this may be an easier option then installing the AlphaControls package or manually editing source files, the convert tool is free. Just remember to make a backup before converting should anything go wrong.
Option 3 - Manually Editing the Source Files
You could manually remove these references yourself. Do note though, if you remove the references then Delphi will no longer know that the TsStatusBar was ever there, and without a doubt there will be code somewhere that would have interacted with this component which will create compiler errors.
As an alternative to removing the references, you could rename them from TsStatusBar to TStatusBar, which is a standard statusbar from the VCL. At worst there may be some small syntax errors that may need correcting. If you do decide to edit the forms source and dfm files then I would suggest you do it before loading the form into the IDE.
Option 4 - GExperts
You can also install an IDE Expert such as GExperts which can automate the process of renaming/converting component references.
I would however advise against removing or renaming the references in this circumstance as it seems the project is reliant on the AlphaControls package.
Summary
I can see there are more components from the AlphaControls package been used, so fixing the TsStatusBar error manually will only fix part of the problem.
If the project must remain in its current state then Installing the AlphaControls package is the way to go, if you are able to edit it then I would also suggest the project convert option, this way you won't even need the AlphaControls package.
If you do chose to install the package, it is important to realise that once you install the package Delphi knows where the source files are to be able to compile. After installing the packages, goto Menu > Tools > Options from the IDE, then you need to go to Library and add the folder for the AlphaControls source to the library path. The source folder will be the one containing the most .pas files, but you could add all folders if you are unsure. If you don't add to the Library path then Delphi will not be able compile when using the new components.
Your IDE does not have the package which contains TsStatusBar installed. Find that package, build it, and install it.
Design time components need their code to be integrated into the IDE. This is done using what are called packages. The package project has extension .dpk. You should find this package project in your revision control system. Load the .dpk file in Delphi, click Build from the package manager, and finally, when built, click Install. Now that the package with your component is known to the IDE, your form will load. Whoever maintains this code in your organisation will be able to help with all the details.

What are the Delphi XE2 VCL Runtime BPLs?

The old Delphi 7, uncheck runtime packages and build all trick doesn't seem to work anymore so I can't restore whatever would be a good set of runtime BPL's for my Delphi project.
I've got a problem, which I will probably ask another question about and link here, which I think might be solved by including a particular BPL that contains VCL.CheckLst.pas.
The reason I don't just know the answer to this is when I start a new VCL forms project, there are no VCL BPLs in the runtime packages by default, there's RTL and some firemonkey stuff and good old MadExcept and Indy, but no VCL, what's the deal with that? is my Delphi misconfigured?
There are no VCL. (note the . after VCL) runtime packages. There are the standard RTL packages you've been used to before; the VCL namespaces are contained in them.
To find out exactly what runtime packages you need to distribute, you might find this useful.
Go to the Project Options/Packages/Runtime Packages dialog (image below to help explain).
Expand the Link with runtime packages node, check True, and clear the three Value node checkmarks. You can also open the nodes below Runtime packages and clear the lists for the three entries there. Save the changes and close the dialog. (The IDE will repopulate the list and store it in the .dproj file; you'll see it if you reopen the Project Options dialog after building.)
Use Project|Build <yourproject>. Once it builds, use Project|Information for <yourproject>; the right side panel will show you the BPLs you'll be required to distribute. (VCL.CheckLst is in vc1x60.bpl, BTW, according to Sertac's comment below.) Make sure you build and don't just compile; you need to make sure all the dcu's are rebuilt so the package list can be determined.

Resources