HI!
I'm doing my work of thesis on a c++ project using C++ Builder 5.
My tutor has obliged me to do a thing (that I've had yet in a simpler way) using a DLL.
Here come the problems.
In fact in a common application like this:
, I'm able to use the command Application->OnShortCut. And the application does what required (the message is displayed).
Instead if I try to do a similar thing using a DLL, everything is harder (actually too hard for me).
In fact I think it's not possible to use a declaration like
void __fastcall TForm1::KeyEvent(TWMKey &Msg, bool &Handled)
in the body of the DLL, because of the fact that I cannot declare it anywhere (there isn't a header file to do this like in common applications).
So to avoid this problem I decided to add to my DLL a fictitious Form (Form2) where I declared the event KeyEvent: in the main body of the DLL I used the command Application->OnShortCut=Form2->KeyEvent.
According to me, everything should work, but it seems that the pushing of the key is not recognized. But I don't know why.
//---------------------------------------------------------------------------
/* Unit1.cpp ----it's the body of the DLL*/
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
#include "Unit2.h"
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
Form2 = new TForm2(NULL);
Application->OnShortCut = Form2->KeyEvent;
return 1;
}
//---------------------------------------------------------------------------
extern "C"
{
bool __export GetEvent()
{
bool ret = false;
if (come == true)
{
ret=true;
}
return ret;
}
}
/* Unit2.h ------ it's the header file of Form2 */
This simple application should return true if the RETURN key has been pushed, false in the other cases.
Any ideas?
Thanx
Try showing your form?
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
Form2 = new TForm2(NULL);
Application->OnShortCut = Form2->KeyEvent;
Form2->Show();
return 1;
}
The problem wasn't due to the showing of the form but to the unchecked option "Build with runtime packages" in Projects|Options|Packages.
Thanx 4 your help!