Sign in to follow this  
Slug

Delphi dialog in VC++?

Recommended Posts

Slug    100
Hello, I,ve read somewhere that you can use a form created in delphi and use it in your vc++ project, it is true?

Share this post


Link to post
Share on other sites
SiCrane    11839
You can compile your Form into a DLL including an exported function to show the form, import that DLL in a MSVC project and then invoke the function from your C++ code.

It's somewhat annyoing, but, yes, it's possible to do.

Share this post


Link to post
Share on other sites
Useless Hacker    372
Quote:
Original post by Slug
Yeah but i've tried to wrote a delphi dll an use it in my vc++
project and that dosen't work...
What exactly doesn't work? You will need to make sure sure you use the same calling convention in the C++ and Delphi code, for example stdcall. Also there may be problems with the memory management.

Share this post


Link to post
Share on other sites
Shannon Barber    1681
Using the same calling conventions can be... challenging. stdcall/pascal and cdecl are safe, but fastcall is tricky. Both MSVC and Delphi/BCB have a fastcall, but they are not the same. They use different registers and IIRC they push stuff onto the stuff in the opposite order. I wrote a bunch of inline assembly to invoke Borland fastcall compiled code from MSVC a couple of years ago.

Share this post


Link to post
Share on other sites
iMalc    2466
Quote:
Original post by Slug
Yeah but i've tried to wrote a delphi dll an use it in my vc++
project and that dosen't work...
It does work! I have a project that does exactly that. My Delphi DLL works fine in Delphi, VB, MSVC++ etc...

Just use stdcall in the DLL function definitions, or alternatively cdecl if you don't need it to work with VB.
You can even generate a lib file for your C++ app using LIB.EXE, or simply use LoadLibrary at run-time.

You also need to avoid passing 'String's to and from your Delphi DLL. You can use them inside it (I do), but the function definitions should use PChar, otherwise you have to distribute some other borland dll with your code.

[Edited by - iMalc on November 29, 2004 11:27:09 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this