begin process at 2012 02 10 17:00:49
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

Implémentation de fonctions


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Implémentation de fonctions

mercredi 23 février 2005 à 03:50:05 | Implémentation de fonctions

vez_from_hell

Bonjour j'aimerais implémenter des fonctions mais je ne sais vraiment pas comment. Lorsque je compile, les erreurs suivantes s'affichent:

(Lieur Erreur) Unresolved external '__fastcall TForm1::FileSaveClick(System::TObject *) referenced D:\...\Main.obj

 (Lieur Erreur) Unresolved external '__fastcall TForm1::SaveAsButtonClick(System::TObject *) referenced D:\...\Main.obj

(Lieur Erreur) Unresolved external '__fastcall TForm1::FileNewClick(System::TObject *) referenced D:\...\Main.obj

(Lieur Erreur) Unresolved external 'TCharsetObject::' referenced D:\...\Main.obj

(Lieur Erreur) Unresolved external '__fastcall TCharsetObject::TCharsetObject(int)' referenced D:\...\Main.obj

voici la source de mon programme:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <windows.hpp>
#include <stdlib.h>
#include <stdio.h>
#include "Main.h"
#include "ReConst.hpp"

 

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)

{
SetFileName(Reconst_SUntitled);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SelectionChange(TObject */*Sender*/)
{
  char sizebuf[6];

  try {


    SpeedButton2->Down = RichEdit1->SelAttributes->Style.Contains(fsBold);
    SpeedButton3->Down = RichEdit1->SelAttributes->Style.Contains(fsItalic);
    SpeedButton4->Down = RichEdit1->SelAttributes->Style.Contains(fsUnderline);


    FontName->Text = RichEdit1->SelAttributes->Name;


  }
     catch (...) {
       FUpdating = False;
     }
     FUpdating = False;
}
//----------------------------------------------------------------------------
TTextAttributes *__fastcall TForm1::CurrText(void)
{
    return RichEdit1->SelAttributes;
}
//----------------------------------------------------------------------------
int __stdcall EnumFontsProc(TLogFontA &LogFont, TTextMetricA &/*TextMetric*/,
                                int /*FontType*/, Pointer Data)
{
     TCharsetObject *FontCharset;
     FontCharset = new TCharsetObject((int)LogFont.lfCharSet);
     ((TStrings *)Data)->AddObject((AnsiString)LogFont.lfFaceName,FontCharset);
     return 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::GetFontNames(void)
{    HDC hDC = GetDC(0);
     void * cTmp = (void *)FontName->Items;
     EnumFonts(hDC, NULL, (FONTENUMPROC) EnumFontsProc, (long) cTmp );
     ReleaseDC(0,hDC);
     FontName->Sorted = True;
}
//----------------------------------------------------------------------------
void __fastcall TForm1::SetFileName(const AnsiString FileName)
{
     LPSTR lpBuf = new char[MAX_PATH];
     sprintf(lpBuf, Reconst_SPercent_s.c_str(), ExtractFileName(FileName).c_str(),
             Application->Title.c_str());
     Caption = (AnsiString)lpBuf;
     FFileName = FileName;
     delete lpBuf;
}
//----------------------------------------------------------------------------
void __fastcall TForm1::CheckFileSave(void)
{    if ( RichEdit1->Modified ) {
        switch(MessageBox(Handle, Reconst_SSaveChanges.c_str(),
          Reconst_SConfirmation.c_str(),MB_YESNOCANCEL | MB_ICONQUESTION))
        {  case ID_YES    : FileSaveClick(this);
           case ID_CANCEL : Abort();
        };
     }
}
//----------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject* /*Sender*/)
{
  AnsiString asLcid;
  int iLcid;

  Application->OnHint = &ShowHint;
  OpenDialog1->InitialDir = ExtractFilePath(ParamStr(0));
  SaveDialog1->InitialDir = OpenDialog1->InitialDir;
  GetFontNames();
  SelectionChange(this);

}
//----------------------------------------------------------------------------
void __fastcall TForm1::ShowHint(TObject* /*Sender*/)
{    StatusBar1->SimpleText = Application->Hint;
}
//----------------------------------------------------------------------------

void __fastcall TForm1::NewButtonClick(TObject *Sender)
{
    CheckFileSave();
     SetFileName(Reconst_SUntitled);
     RichEdit1->Lines->Clear();
     RichEdit1->Modified = False;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::OpenButtonClick(TObject *Sender)
{
CheckFileSave();
     if (OpenDialog1->Execute()) {
        RichEdit1->Lines->LoadFromFile(OpenDialog1->FileName);
        SetFileName(OpenDialog1->FileName);
        RichEdit1->SetFocus();
        RichEdit1->Modified = False;
        RichEdit1->ReadOnly = OpenDialog1->Options.Contains(ofReadOnly);
     }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SaveButtonClick(TObject *Sender)
{
if ( !strcmp(FFileName.c_str(), Reconst_SUntitled.c_str()) )
        FileSaveAsClick(Sender);
     else
     {
        RichEdit1->Lines->SaveToFile(FFileName);
        RichEdit1->Modified = False;
     }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FileSaveAsClick(TObject* /*Sender*/)
{    if ( SaveDialog1->Execute() ) {
        // Options + OverwritePrompt = True thus no need to check.
        RichEdit1->Lines->SaveToFile(SaveDialog1->FileName);
        SetFileName(SaveDialog1->FileName);
        RichEdit1->Modified = False;
     }
}

//---------------------------------------------------------------------------

void __fastcall TForm1::PrintButtonClick(TObject *Sender)
{
 if ( PrintDialog1->Execute() ) RichEdit1->Print( FFileName );
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if ( RichEdit1->HandleAllocated() )
        SendMessage(RichEdit1->Handle, EM_UNDO, 0, 0);       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Cut1Click(TObject *Sender)
{
RichEdit1->CutToClipboard();       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Copy1Click(TObject *Sender)
{
RichEdit1->CopyToClipboard();       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::C1Click(TObject *Sender)
{
RichEdit1->PasteFromClipboard();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Font1Click(TObject *Sender)
{
 FontDialog1->Font->Assign( RichEdit1->SelAttributes );
     if ( FontDialog1->Execute() )
        CurrText()->Assign( FontDialog1->Font );

     RichEdit1->SetFocus();       
}
//---------------------------------------------------------------------------


void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
if ( !FUpdating )
     {  if ( SpeedButton2->Down )
           CurrText()->Style = CurrText()->Style << fsBold;
        else
           CurrText()->Style = CurrText()->Style >> fsBold;
     }       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
if ( !FUpdating )
     {
        if ( SpeedButton3->Down )
           CurrText()->Style = CurrText()->Style << fsItalic;
        else
           CurrText()->Style = CurrText()->Style >> fsItalic;
     }       
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SpeedButton4Click(TObject *Sender)
{
if ( !FUpdating )
     {
        if ( SpeedButton4->Down )
           CurrText()->Style = CurrText()->Style << fsUnderline;
        else
           CurrText()->Style = CurrText()->Style >> fsUnderline;
     }
}
//---------------------------------------------------------------------------
voici pour le Main.cpp

//---------------------------------------------------------------------------

#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <Outline.hpp>
#include <Grids.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <StdCtrls.hpp>
#include <ComCtrls.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <Forms.hpp>
#include <Controls.hpp>
#include <Graphics.hpp>
#include <Classes.hpp>
#include <SysUtils.hpp>
#include <Messages.hpp>
#include <Windows.hpp>
#include <System.hpp>
#include <ToolWin.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // Composants gérés par l'EDI
        TMainMenu *MainMenu1;
        TMenuItem *File1;
        TRichEdit *RichEdit1;
        TLabel *Label1;
        TSaveDialog *SaveDialog1;
        TOpenDialog *OpenDialog1;
        TPrintDialog *PrintDialog1;
        TMenuItem *New1;
        TMenuItem *Save1;
        TMenuItem *Saveas1;
        TMenuItem *N1;
        TMenuItem *Open1;
        TMenuItem *Print1;
        TMenuItem *N2;
        TComboBox *FontName;
        TCoolBar *CoolBar1;
        TSpeedButton *OpenButton;
        TSpeedButton *SaveAsButton;
        TSpeedButton *NewButton;
        TSpeedButton *SaveButton;
        TSpeedButton *PrintButton;
        TSpeedButton *SpeedButton1;
        TSplitter *Splitter1;
        TBevel *Bevel3;
        TBevel *Bevel1;
        TBevel *Bevel2;
        TComboBox *ComboBox1;
        TBevel *Bevel4;
        TComboBox *ComboBox2;
        TSpeedButton *SpeedButton2;
        TMenuItem *Exit1;
        TBevel *Bevel5;
        TSpeedButton *SpeedButton3;
        TSpeedButton *SpeedButton4;
        TStatusBar *StatusBar1;
        TMenuItem *Edit1;
        TMenuItem *C1;
        TMenuItem *Copy1;
        TMenuItem *Cut1;
        TMenuItem *N4;
        TMenuItem *About1;
        TMenuItem *N3;
        TMenuItem *Font1;
        TFontDialog *FontDialog1;
        void __fastcall NewButtonClick(TObject *Sender);
        void __fastcall OpenButtonClick(TObject *Sender);
        void __fastcall SaveButtonClick(TObject *Sender);
        void __fastcall SaveAsButtonClick(TObject *Sender);
        void __fastcall PrintButtonClick(TObject *Sender);
        void __fastcall SpeedButton1Click(TObject *Sender);
        void __fastcall Cut1Click(TObject *Sender);
        void __fastcall Copy1Click(TObject *Sender);
        void __fastcall C1Click(TObject *Sender);
        void __fastcall Font1Click(TObject *Sender);
        void __fastcall SpeedButton2Click(TObject *Sender);
        void __fastcall SpeedButton3Click(TObject *Sender);
        void __fastcall SpeedButton4Click(TObject *Sender);
        void __fastcall SelectionChange(TObject *Sender);
        void __fastcall FileNewClick(TObject *Sender);
 void __fastcall FileOpenClick(TObject *Sender);
 void __fastcall FileSaveClick(TObject *Sender);
 void __fastcall FileSaveAsClick(TObject *Sender);
        void __fastcall FormCreate(TObject *Sender);
private: // Déclarations utilisateur
                void __fastcall ShowHint(TObject *Sender);
                AnsiString FFileName;
         bool FUpdating;
         int FDragOfs;
         bool FDragging;
         TTextAttributes *__fastcall CurrText(void);
         void __fastcall GetFontNames(void);
         void __fastcall SetFileName(const AnsiString FileName);
         void __fastcall CheckFileSave(void);
public:  // Déclarations utilisateur
        virtual __fastcall TForm1(TComponent* Owner);

};
//----------------------------------------------------------------------------
class TCharsetObject : public TObject
{
public:
    int Charset;
    __fastcall TCharsetObject(int FCharset);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

le Main.h

// Borland C++ Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved

// (DO NOT EDIT: machine generated header) 'ReConst.pas' rev: 5.00

#ifndef ReConstHPP
#define ReConstHPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <Windows.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Reconst
{
//-- type declarations -------------------------------------------------------
//-- var, const, procedure ---------------------------------------------------
static const Word ENGLISH = 0x409;
static const Word GERMAN = 0x407;
static const Word FRENCH = 0x40c;
extern PACKAGE System::ResourceString _SUntitled;
#define Reconst_SUntitled System::LoadResourceString(&Reconst::_SUntitled)
extern PACKAGE System::ResourceString _SPercent_s;
#define Reconst_SPercent_s System::LoadResourceString(&Reconst::_SPercent_s)
extern PACKAGE System::ResourceString _SSaveChanges;
#define Reconst_SSaveChanges System::LoadResourceString(&Reconst::_SSaveChanges)
extern PACKAGE System::ResourceString _SConfirmation;
#define Reconst_SConfirmation System::LoadResourceString(&Reconst::_SConfirmation)
extern PACKAGE System::ResourceString _SNumberbetween;
#define Reconst_SNumberbetween System::LoadResourceString(&Reconst::_SNumberbetween)
extern PACKAGE System::ResourceString _SLcid;
#define Reconst_SLcid System::LoadResourceString(&Reconst::_SLcid)

} /* namespace Reconst */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Reconst;
#endif
#pragma option pop // -w-
#pragma option pop // -Vx

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // ReConst

le ReConst.hpp


je crois que c'est cette partie qui ne fonctionne pas car je l'ai prise d'un autre programme (RichEdit l'exemple de Borland 5) et j'ai simplement ajouté le fichier au projet.

mais je ne sais pas comment implémenter les fonctions 
merci d'avance

mercredi 23 février 2005 à 14:05:47 | Re : Implémentation de fonctions

Dvdmizo

il te manque les fonctions suivantes dans ton main.cpp :

TForm1::FileSaveClick(System::TObject *)
TForm1::SaveAsButtonClick(System::TObject *)
TForm1::FileNewClick(System::TObject *)


(ces fonction devait certainement se trouver dans  le fichier .cpp dans lequel est definie Form1 dans l'exemple que tu as utilisé )

'TCharsetObject::'
TCharsetObject::TCharsetObject(int)

pour ces erreurs là par contre je ne sais pas dans quel fichier se trouvent les déclarations mais elles ne sont pas dans ton source ...

DvdMizo
mercredi 23 février 2005 à 14:18:19 | Re : Implémentation de fonctions

Dvdmizo

au temps pour moi, j'avais mal vu...
la déclaration de la classe TCharsetObject est bien dans le fichier main.h
par contre elle n'est pas implémentée dans ton source....

DvdMizo


Cette discussion est classée dans : sender, void, fastcall, tobject, tform1


Répondre à ce message

Sujets en rapport avec ce message

Problème de socket à la connexion avec application Client/Serveur (Borland C++ Builder) [ par ThripS ] Bonjour, je me suis fait un début d'application client/serveur avec Borland C++ Builder mais à la connexion du client j'ai une erreur de socket peu im Créer un type de fichier [ par vez_from_hell ] bonjour je vais vs donner ma source et pourriez vous me dire comment je pourrais créer un extension de fichier et lorsque je vais cliquer sur ouvrir o Ouvrir une form deja existante [ par Rivosites ] Bonjour, Voici mon probleme, j'utilise Borland C++. J'ai cree un projet., dans celui ci j'ai 2 form. une pricipale Form1 et l'autre Form2. Je souhai Glisser déposer de fichier avec BCB 5 [ par fredcl ] Siute à une demande par mail de Chap71Voici un bout de code exemple:// dans le fichier .h par exemple class TFormMain : public TForm{   __published: / PROJET IRIS [ par gangstakilla93 ] Voici le programme que j'ai écrit, je n'arrive pas à afficher lire les données que j'ai envoyé sur le port parallele: //----------------------------- Sockets [ par faucheuse ] Bien le bonjour amis programmeurzz, J'etudie actuellement l'informatique et pour les besoins de mes etudes(et surtout pour mon plaisir) j'ai commencé Overload ou void* [ par CCJ ] Salut.Vaut-il mieu creer une fonction avec comme parametre un pointeur void et traiter chacun des type avec un overload de cette fonction ?Peutetre y


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,312 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales