The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Delphi Programming
|
still problems with linker error
Discuss still problems with linker error in the Delphi Programming forum on Dev Shed. still problems with linker error Delphi Programming forum discussing Delphi related topics including Kylix, C++ Builder, and more. Delphi is a high-performance language, originally based on the PASCAL language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 10th, 2003, 09:13 AM
|
|
Junior Member
|
|
Join Date: Nov 2003
Location: milan
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
still problems with linker error
Hi! I'm tryin' to create a simple dll with an included module (Form7) with BCB5 but I’ve some linking problems.
This is the code:
PHP Code:
// Mydll.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#include "Unit7.h"
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
Form7=new TForm7(NULL);
Application->OnShortCut=Form7->KeyEvent;
KeyPressed = false;
return 1;
}
//---------------------------------------------------------------------------
extern "C"
{
bool __export GetEvent()
{
bool ret=false;
if (KeyPressed)
{
ret=true;
KeyPressed=false;
}
return ret;
}
}
// Unit7.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
bool KeyPressed;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall KeyEvent(Messages::TWMKey &Msg, bool &Handled)
{
if(Msg.CharCode == VK_ESCAPE)
{
KeyPressed=true;
Handled = true;
}
}
// Unit7.h
//---------------------------------------------------------------------------
#ifndef Unit7H
#define Unit7H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm7 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TForm7(TComponent* Owner);
void __fastcall KeyEvent(Messages::TWMKey &Msg, bool &Handled);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm7 *Form7;
extern bool KeyPressed;
//---------------------------------------------------------------------------
#endif
When I compile, everything it’s OK, but I’ve this linker error:
PHP Code:
[Linker Error] Unresolved external '__fastcall TForm7::KeyEvent(Messages::TWMKey&, bool&)' referenced from D:\DOCUMENTS AND SETTINGS\MATTEO\DESKTOP\PROVALADLL\MYDLL.OBJ
I’ve tried to change the position of the declaration of void __fastcall KeyEvent (I think this is the problem), but I still have errors of this kind.
Anyone can help me, please?
Bye,
Castoro
PS:I’ve forgot to say that the dll should simply return true if the key “Esc” has been pushed (without generating a OnKeyPress event – so using the OnShortCut event of TApplication), else return false in the other cases (generating a OnKeyPress event).
Bye
|

November 10th, 2003, 01:22 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
In unit7.cpp, change this line:
void __fastcall KeyEvent(Messages::TWMKey &Msg, bool &Handled)
to this:
void __fastcall TForm7::KeyEvent(Messages::TWMKey &Msg, bool &Handled)
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

November 11th, 2003, 05:33 AM
|
|
Junior Member
|
|
Join Date: Nov 2003
Location: milan
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Yes,this is the error. now my dll is well compiled and linked but still doesn't do what I need. If I use it in a simple program as:
PHP Code:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Prova_src.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
FARPROC myfunc;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
HINSTANCE mylib = LoadLibrary("trigger3sec.dll");
if(mylib){
myfunc = GetProcAddress(mylib,"_GetEvent");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if((myfunc) && myfunc()){
if (Color==clBtnFace) Color=clRed;
else Color=clBtnFace;
}
}
//---------------------------------------------------------------------------
if I push the "Esc" key my dll doesn't respond with the Form7->KeyEvent as should do.
It could be a problem due to the fictitious form (Form7) that I've decided to use??
Is there a way to use an event in a dll without using this fictitious form?
And in this case where I should declare this function in the dll?
Thanks for your help, hoping u will have still some time to dedicate to my problem (and to understand my English,too;-))!
Bye
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|