Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 10th, 2003, 09:13 AM
teo.castoro teo.castoro is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: milan
Posts: 14 teo.castoro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy 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 hinstunsigned long reasonvoidlpReserved)
{
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(TComponentOwner)
        : 
TForm(Owner)
{
}

//---------------------------------------------------------------------------
void __fastcall KeyEvent(Messages::TWMKey &Msgbool &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(TComponentOwner);
        
void __fastcall KeyEvent(Messages::TWMKey &Msgbool &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 ErrorUnresolved 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

Reply With Quote
  #2  
Old November 10th, 2003, 01:22 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,382 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 31 m 48 sec
Reputation Power: 4080
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

Reply With Quote
  #3  
Old November 11th, 2003, 05:33 AM
teo.castoro teo.castoro is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: milan
Posts: 14 teo.castoro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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(TComponentOwner)
        : 
TForm(Owner)
{
HINSTANCE mylib LoadLibrary("trigger3sec.dll");
 if(
mylib){
  
myfunc GetProcAddress(mylib,"_GetEvent");
 }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if((
myfunc) && myfunc()){
  if (
Color==clBtnFaceColor=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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > still problems with linker error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap