Dark Templar
Dark Templar

Reputation: 1305

How do I call other functions from the message loop of a VCL project?

I have project where I need to use an API which comes with a dll and .cpp as well as .h files. In the documentation I am told to use the PreTranslateMessage(MSG* pMsg) class function of the provided API and place it into the message loop of the User Interface.

Is it possible to use C++ Builder as the IDE for this project, and if yes, then how, as it doesn't have a message loop where I could place this function.

Upvotes: 1

Views: 701

Answers (2)

Remy Lebeau
Remy Lebeau

Reputation: 597860

A VCL app in C++Builder does have a message loop (it is a normal Windows app, after all). It is tucked away inside the TApplication::Run() method, which is called inside the project's WinMain() function. If you want to call PreTranslateMessage() inside this loop, you can assign an event handler to the TApplication::OnMessage event, either directly or via the TApplicationEvents component. The OnMessage event is triggered immediately after a message is removed from the message queue before the VCL processes it.

Upvotes: 1

dinox0r
dinox0r

Reputation: 16059

Check this out, it has some documentation about the process of integrating Windows Event messages with the VCL, althougth don't know if that applies for your project, in case that your project uses the MFC framework, you are better with Visual Studio.

In either case, you can include windows.h and have access to the win32 API functions

Upvotes: 1

Related Questions