replacing AxMSComCtl2.AxAnimation with a .net equivalent - activex

I have a legacy implementation that I am upgrading from VS 2008 to VS 2010.
Embedded in the application is an animation using AxMSComCtl2.AxAnimation. when I try to view the form, I get a Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG) for the AxAmimation.
This is a trivial animation that works under VS 2008 executibles that shows stuff moving from one place to another. It is not required for the application to work correctly.
I would love to get rid of the ActiveX stuff and replace it with a .net equivalent, but I haven't been able to find documentation on the AX animation or on .net equivalents. I would gladly just eliminate it if I cannot replace it.

Related

Delphi - How to correctly register a graphic class since XE8?

I'm writing a Delphi package, which provides a new custom TGraphic object, allowing to read a new image format in VCL components like TImage.
I originally developed this package with RAD Studio XE7, and it worked well. However I migrated recently to a newer RAD Studio compiler version, and although my package continues to work properly on that new version, I noticed a strange bug that never appeared before.
I have a form with several components, some of them are TImage components. Immediately after opening the IDE, the first time I open my project in design time, all the TImage components containing my custom TGraphic component loose their content. If I close then reopen the project, the images reappear, and the bug no longer happen until I close and reopen my IDE.
I dug in my code to understand what may cause the issue. To register my custom TGraphic component, I use the class initialization section, in which I wrote the following code:
initialization
begin
Vcl.Graphics.TPicture.RegisterFileFormat('svg', 'Scalable Vector Graphics', TWSVGGraphic);
end;
However I found that, since the XE8 compiler version, the TImage constructor is called before my initialization section, causing thus apparently the above mentioned issue. All the compiler versions since XE8 are affected, but this bug never happened on XE7 or earlier. So something changed since XE8.
Here are my questions:
Is the way I use for register my custom graphic class correct?
If not, what is the correct way to do that?
As something seems different since XE8, what it the new correct manner to register my graphic component?
Did anyone else faced the same issue? How he resolved it?
Is this may be a new RAD Studio bug, or the issue is rather on my side?
This is most likely a side effect of the smart loading the IDE applies to design time packages. You can overwrite this behavior by calling ForceDemandLoadState(dlDisable) during the Register procedure of your package.
More about this can be found in the documentation of more recent versions of Delphi than XE8: Explicitly disabling smart loading of components in a design-time package

Is there any Delphi Open Source project that Implement a basic IDE structure?

I have written a framework for Android and Windows, and got some tool that draw the forms and scripting that run on both enviroments. Just another solution like thousands.
What I want to do now is using Delphi (Xe2 in my case) to write an IDE like Delphi itself. That I could manage source files in a project and have forms. I have much of it already on DevExpress components. But I was wondering if there is anything that I could reuse to not invent the wheel again.
Certanly the drawing form should be necessary to have changes for my particular case, however it being capable of drawing forms with buttons, text, those common controls we find in majority of the platforms.
Right now I am using Balsamiq Mockup to draw and export xml to my compiler to integrate on the framework, it is nice, because it is a great drawing product, howeve there is a need to have all that IDE properties integrated and the need to put events on each control, for that an IDE all in one solution is better.
TMS Scripter -> I have found this commercial package, that comes with basically everything I need, scripting (I need VB but with different flavor, I believe it could be changed), form designer, project management, etc... It is very nice indeed. However I would like to hear of open source solutions
How about Lazarus? I think that's free, and it certainly has an extensive IDE.
http://www.lazarus.freepascal.org/
It's not a Delphi Open Source IDE, but I think it is free for use and feature rich:
MS Visual Studio Shell
what-is-the-visual-studio-shell-standalone-shell-good-for
RemObject use it for there tools. So it fits also for Delphi.

How to intermix Windows dialogs and VCL forms?

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.

Delphi forms in dlls

Is it good idea to put Forms that have complete functionality in dll.
And main app will invoke dll function that returns form object.
The accepted way to do this in Delphi is to use packages rather than DLLs.
Packages are essentially DLLs but with Delphi specific capabilities that allow VCL objects to be used across package boundaries.
Trying to do this with DLLs will lead to a variety of problems that packages deal with. One downside of packages is that all modules must be compiled with the same version of Delphi. But if you are wanting to share objects across module boundaries then you would face the same restriction if you used DLLs.
The Delphi documentation has extensive coverage of packages.
Having said all that, I would add that if you can put all your code into a single module (.exe or .dll) then it does make life a lot simpler.
Adding to the answers about using packages:
Packages can only be used if both, the main app and all dlls (plugins) are written in Delphi and are written using the same version of Delphi
DLLs can be written in any programming language that can create them and can be used by any program regardless of the programming language
So, using dlls rather than packages does make sense.
Regarding the actual question: Yes, it is possible to put forms into dlls and they usually work fine. Just make sure that you do not pass them around because they are only valid objects within the context of the dll. You will experience the odd problem with forms losing focus or coming up behind other forms. This can usually be fixed by passing a window handle from the main executable to the dll which is then used as the parent for the form.
Also note: TObject of your dll is different from TObject of your application. The same applies to other commonly used classes and variables like (Forms.)Application.
I have done it and it was a pain in the lower back but it was not impossible. The main program was written in Visual Basic 6, some modules were written in Delphi 6, others were written in Delphi 7 and Delphi 2007.
Conclusion: If you are sure you will never use something different than Delphi for your app and for your dlls (plugins) and are willing to always recompile everything when you switch Delphi versions, you should use packages. Otherwise it might be better to use regular dlls. (And are you sure you will always be the only person writing these dlls? Maybe at some time there will be a 3rd party developer for one of the dlls who does not own the Delphi version he needs.)
IMO this is sometimes a very good idea and the only way to go - for the reasons others have mentioned, I'm not a fan of packages, and am very comfortable with DLL's. I am currently adding functionality to an app written in Delphi 5 using Delphi XE - it was either use DLL's or write in D5 - of course I opted for the former: D5 app calls DLL's written in XE that contain all the latest and greatest features. (The first projects I did in Delphi were done via the old Borland Paradox - Paradox app invoked DLL's written in Delphi 1!)
But, I don't send the form or module from the DLL back to the main app - I just send the DLL module a structure containing what it needs to know to do its work, and when it's done and the DLL's form closes, it cleans up and then and returns a numerical code or structure back to caller indicating success, failure etc ( old fashioned but very effective).
Passing the form instance from the DLL back to your main app across the DLL threshhold can be problematic - note #dummzeuch's excellent answer above with some good tips on how to negotiate some of those problems should you decide that is your only solution.
+1 for everything that David Heffernan says.
Strategically, you really only need to implement forms (or other functionality) in external files if you're implementing a plug in system.
If you're going to allow plugins to be authored in any language, then DLL's are the only way to go.
If your plugin system will be restricted to developers with the same version of Delphi (same team perhaps?) then go with BPL's. The additional drawback of Delphi packages, from my perspective, is the need to deploy the VCL BPL's with your app, which are always more Mb than a single compiled module.
If on the other hand you want to write a modular system, you can still do that by implementing loose coupling & "plugin" techniques within your code and still compile to a single module.
If you put a form in a normal dll the form won't be able to intercept the TAB or arrow keys. I have been told that this is due to the OnKeyDown not be passed through.

Compatibility on WinXP and Vista

I developed an application using also third party components (developed on D7, WinXP).
When I deploy this application on XP everything works fine. When I run it on Vista, the application cease to work properly:
Toolbuttons on Toolbar does not size equally, when I switch visibility on/off, thats why (third party) skins are not properly nested and then it looks ugly. It bothers, it's annoying but it is not fatal as the next point.
Third party text processing component cease to write. I wrote some routines, which allows writing on this component under certain circumstances. It was a big shock to find out, that I can not write anything (probably these routines return false for writing, but I do not see any reason, why on XP it should work fine, but on Vista not).
The application runs (at last), but not in the way, like it supposed to !!!!
I would like to debug it, but how?
Should I install Delphi 7 on this problematic Vista computer and compile project on it? (this is it, what I am going to do...)
Is it problem of third party components?
Is there any possibility to use some compiler directives to ensure, that application will run on Vista flawless ? (be honest I do not know if Vista is to claim in general).
Is Delphi 7 too old for Vista?
NOTE:
When I run the same application on Win98, I get error message about invalid floating point operation...
Has anybody solved such problem?
Thanks
If Delphi 7 is compatible with Windows Vista, it only really means one or both of the following:
You can run Delphi 7 on Windows Vista
Delphi 7 can be used to write programs that can run on Windows Vista
It does not automatically mean that
All programs I create in Delphi 7 runs on Windows Vista
All programs I create in Delphi 7 runs properly on Windows Vista
Let me give you an analogy: That you can use a hammer to get a nail into your wall without hurting yourself does not mean that no matter what you do, you won't hurt yourself.
If your program, either in your own code, or as part of the third party components you use, use parts of Windows that has changed or possibly even been removed (although that's far less), then you need to fix your program, there's no way around it.
There's no silver bullet either, so no compiler directives or whatnot. The most I can think of is that perhaps Windows Vista has some compatibility settings for the shortcuts that might turn on some XP-compatibility layer in Vista that fixes the particular issues you have.
However, the only long-term solution is to change your program so that it is properly compatible with Windows Vista, and probably Windows 7 as well.
Since you say you're using third-party components, have you verified if the particular versions of them that you use happen to be Vista-compatible? You need to go check on the websites of the authors to find that. Perhaps it can be solved by simply upgrading those components.
However, it might also be that you need to make changes to your own code.
The best way to move forward is to install Vista and possibly Windows 7 and start debugging to try to find the underlying cause of the problems.
Note that just installing Delphi 7 on Vista and recompiling will not fix anything. The compiler does not produce a different program if you compile it on a particular Windows version. Only changes to the code will apply the necessary changes.
The easiest solution is to make sure your Delphi version and 3rd party components are Vista compatible.
Delphi versions since 2007 are.
Recent TMS, DevExpress and Raize components are.
The hard solution is to do all the changes yourself.
Be prepared to modify the VCL sources from 2002, carefully modify them to bring them up to Delphi 2007 level.
Then do the same for your 3rd party components.
--jeroen
I never really investigated, but I noted that in some apps that I have, in all skinned modes (XP-teletubbie, and Vista/W7 non classic) I had paint artifacts with all delphi verrsions if I put buttons and labels directly on tframes or ttabsheets.
The problems went away when I inserted a panel inbetween.

Resources