When deriving a new component from certain components like TPrinterSetupDialog you receive ?Unresolved external? linker errors like ?Unresolved external '__fastcall Dialogs::TPrinterSetupDialog::Execute(void *)' ?

Abstract: When deriving a new component from certain components like TPrinterSetupDialog you receive ?Unresolved external? linker errors like ?Unresolved external '__fastcall Dialogs::TPrinterSetupDialog::Execute(void *)' ?
  • Product Name: Borland C++ Builder
  • Product Version: 2006
  • Product Component: Compiler
  • Platform/OS Version: Win32

Description:

When deriving a new component from certain components like TPrinterSetupDialog you receive ?Unresolved external?linker errors like ?Unresolved external '__fastcall Dialogs::TPrinterSetupDialog::Execute(void *)' ? .


Answer/Solution:

The reason for this is issue is that there is a difference in the handle (normally window handles and device context handles) type definition used in the Delphi VCL and header file definition. In the Delphi RTL the handles are normally defined as unsigned integers and in C++ using the normal Windows API definition as ?void *?.

Normally this issue is smooth over with some ?glue code?, using ?thunks? to functions having the correct signature and a small bit of assembler that then JMPs to the actual VCL method. This can also be done in the actual header as follows:

For the TPrinterSetupDialog

1) Edit Dialogs.hpp

2) replace this method :

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

������������� virtual bool __fastcall Execute(HWND ParentWnd)/* overload */;

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

in the TPrinterSetupDialog with

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

���������������� virtual bool __fastcall Execute(unsigned int ParentWnd)/* overload */;

������ #pragma option push -w-inl

������ //Added method

������ inline bool __fastcall Execute(HWND ParentWnd) {TPrinterSetupDialog::Execute((unsigned int)ParentWnd);};

������ #pragma option pop

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Similar fixes can be applied to the other, dialogs that may exhibit similar issues.

For the TScrollBox,

1) Edit Forms.hpp

2) replace this method :

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

������������� virtual void __fastcall PaintWindow(HDC DC);

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

in the TScrollBox with

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

������ virtual void __fastcall PaintWindow(unsigned int DC);

������ #pragma option push -w-inl

������ inline void __fastcall PaintWindow(HDC DC) {TScrollBox::PaintWindow((unsigned int)DC);};

������ #pragma option pop

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


 
Copyright© 1994 - 2009 Embarcadero Technologies, Inc. All rights reserved. Contact Us   Site Map   Legal Notices   Privacy Policy   Report Software Piracy