Board index » cppbuilder » Porting Delphi HID Component to C++Builder 5 - made progress but request advice

Porting Delphi HID Component to C++Builder 5 - made progress but request advice


2004-08-06 01:07:13 AM
cppbuilder96
Hi all,
I've been struggling for the last couple of days with the problem of porting Robert Marquardt's HID controller component (www.soft-gems.net/Controls.php) to C++Builder 5.0. As an aside, I tried to post in the group yesterday, but I foolishly posted from Google groups, which doesn't reach this newsgroup. Anyhow, I've mostly resolved my problem and am posting here to get feedback and to share what I've learned with someone else that might have this problem. I'm new to converting components between Delphi and C++ Builder... this was my first time thru.
I'm using the HID component developed by Robert Marquardt. The component comes with a Delphi package and a C++ Builder package. I was able to use the component with Delphi 6, it's fantastic and does everything I need. I then needed to use the component with C++ Builder 5. Unfortunately, the package for C++ Builder is for version 6, and won't work with version 5. Following the directions I've read in this newsgroup and others, I created a new package and added the .Pas files. The component installed without error. However, when I add the component to a new application, I couldn't build. I got errors in SetupApi.hpp, the most common of which was 'PByte' is not a member of 'System'. I tried about 10 times to remove and reinstall this package using a variety of techniques I've found via google. So far, nothing worked. I finally resolved these difficulties by making sure the header files were in the Tools->Environment Options ->Library path. It seems obvious now, but at the time I was stumped.
After I resolved these errors, I was still stuck. I had errors in SetupApi.hpp, on the line:
typedef SP_POWERMESSAGEWAKE_PARAMS_A *PSPPowerMessageWakeParamsA;
The error message is "E2257 , Expected". When I grepped for PSPPowerMessageWakeParamsA, I found it in SetupApi.pas... so I concluded that I was missing something that makes the hpp be built correctly. I commented out these 6 lines in the hpp file, and was able to build and compile my test application. Success!!! I was very happy.
So today I came into the office, and the damn component had come off the toolbar. After a bit more research, I learned that this means my component hadn't installed correctly. I cleaned up, uninstalled everything, and started over. This time, I opened the SetupApi.pas source, commented out the six lines that looked like SP_POWERMESSAGEWAKE_PARAMS_A, and built the component. It installed fine in Delphi. I then repeated the above described process, and the component installed fine in C++ Builder 5.
So here is my question... does my solution sound reasonable or am I asking for trouble? In my testing so far, I think I'm okay... but as I am new to building components in general and porting them from Delphi to C++ Builder in specific, I have my doubts.
---------------------
Just for completeness, here are a variety of things I tried which sounded good but didn't do anything at all. Hopefully I can save someone else some of the hassle I went thru:
1) Put {$ObjExportAll On} at the top of the file. So far as I can tell, this doesn't do anything at all to help in later versions of C++ Builder.
2) Adding various units to the requires portion of the package. Popular suggestions were vcl* and the like. Sounds great, totally ineffective.
3) Adding switches like <PFLAGS value...>to the source. I couldn't figure out where to add this, but the -LUDesignIde flag sounds like it's been depricated anyhow.
4) Copy header and .obj and .bpl files to random directories in the Borland tree. Totally unnecessary so long as your environment paths are set correctly.
-------------
Thanks very much in advance,
Chris Gutierrez
email: gcgutier (at) hotmail (dot) com
www.chrisgutierrez.org
 
 

Re:Porting Delphi HID Component to C++Builder 5 - made progress but request advice

This component is available in the JVCL 3 as Robert Marquardt is a
developer in this library. The JVCL 3 compiles under C++ Builder 5.
To get the JVCL 3, you will need the latest versions of both the JCL and
the JVCL. Please get them from here:
jvcl.sf.net/daily/
jcl.sf.net/daily/
Read the readme.htm files, the installation should be really
straightforward.
Should you require any help, please ask your question on the JVCL
newsgroup here:
Cheers
Olivier Sannier
JVCL Developer