Board index » cppbuilder » using VCL components in non-VCL, form-less applications

using VCL components in non-VCL, form-less applications

Hi,
I'm relatively new to Windows API C++ programming and BCB. I am currently
using BCB v5 Enterprise Edition, and find the VCL and form-based interface
quite easy and time/labour saving for general purpouse applications.
However, the way it isolates the programmer from the guts of the
application's code seems unsuitable for more in-depth programming (creating
applications using the  DriectX API being a prime example.) As such, I have
started taking the "long way" and written all the window creation,
initialisation, etc. my self as a single .cpp file with no forms, and an
as-yet very basic project file. the problem I have encounted, however, is
when I try to use a VCL component in such an application. I include vcl.h
and create an instance of a component (in this case a memo-box) in the
prescribed way:

    TMemo *memobox;
    memobox = new TMemo(&hwnd);
    .....
    delete memobox;

Yet still I get a mass of linker errors in the vein of:

    [Linker Error] Unresolved external '__fastcall
Stdctrls::TCustomMemo::~TCustomMemo()' referenced from C:\PROGRAM
FILES\BORLAND\CBUILDER5\PROJECTS\TEST\WINTEST.OBJ

I am stuped as to the cause of this, and the help files have failed to point
out the cure, so I am looking forward to any insight anyone may have to give
in this case.

Thankyou for your help.

 

Re:using VCL components in non-VCL, form-less applications


Quote
"Tyrone C" <jeebuscripe...@yahoo.com.au> wrote in message

news:3d3d0e86_2@dnews...

Quote
> However, the way it isolates the programmer from the guts
> of the application's code seems unsuitable for more in-depth
> programming (creating applications using the  DriectX API
> being a prime example.)

On the contrary, the VCL can be used alongside raw API code just fine.  The
VCL may hide many of the lower-level details, but it certainly doesn't
prohibit you from doing anything yourself directly, and many controls do
provide access to their underlying API data for direct access and
manipulation as well.

As for DirectX specifically, you can program DX in a VCL appliction just
fine.  There are also third-party VCL components available that wrap the DX
API for you for easier use.

Quote
> the problem I have encounted, however, is when I try to use
> a VCL component in such an application. I include vcl.h

Did you explitically choose to create a VCL project from the "File > New"
dialog, or did you manually add vcl.h to a non-VCL console project?  If the
latter, then you can't do that.  VCL and non-VCL programs have very
different startup code internally, you can't simply add vcl.h to a non-VCL
project and expect it to work correctly, because it won't.

Quote
> and create an instance of a component (in this case a memo-box)
> in the prescribed way:

If hwnd is a HWND, then you're passing a HWND* rather than a HWND to the
constructor, which won't work because it's not expecting a HWND*.

Quote
> Yet still I get a mass of linker errors in the vein of:

>     [Linker Error] Unresolved external '__fastcall
> Stdctrls::TCustomMemo::~TCustomMemo()' referenced
> from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\TEST\WINTEST.OBJ

Yes, because from the sounds of it, you didn't start with a VCL project to
begin with, but rather simply included vcl.h in a non-VCL project.  In which
case, the VCL libraries are not linked in to the project correctly, and it
will not compile.  If you intend to use anything VCL-related, then you MUST
start with a true VCL project from the very beginning.

However, there are two ways to approach it, if you intend to continue
writing API-only code -

1) File > New > Application
    Close the MainForm files without saving them.
    What's left is a VCL-enabled WinMain() shell that you can use.

2) File > New > Console Wizard
    Make sure the "C++" and "Use VCL" options are enabled, and the "Console
Application" option is disabled.
    What's created is a VCL-enabled WinMain() shell that you can use.

Gambit

Other Threads