BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax errors - simple component

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
JD
Guest





PostPosted: Fri Nov 21, 2003 9:58 am    Post subject: Syntax errors - simple component Reply with quote




I want to install a StringGrid decendant to the pallette but I'm
getting compile errors. May I have some help please?

I have no clue what to do with this error

[C++ Error] MGrid.cpp(21): E2188 Expression syntax

I presume that all I need to do is add a semicolon but I don't
understand this error

[C++ Error] MGrid.cpp(35): E2379 Statement missing ;

//--------------------------------------------------------------
#include <vcl.h>

#pragma hdrstop

#include "MGrid.h"
#pragma package(smart_init)
//--------------------------------------------------------------
static inline void ValidCtrCheck(TMGrid *)
{
new TMGrid(NULL);
}
//--------------------------------------------------------------
__fastcall TMGrid::TMGrid(TComponent* Owner) : TStringGrid(Owner)
{
public: //<<<<<<<<<<-------- line 21
void __fastcall MoveRow( int FromIndex, int ToIndex )
{
inherited::MoveRow( FromIndex, ToIndex );
}
void __fastcall InsertRow( int Index )
{
++RowCount;
inherited::MoveRow( RowCount - 1, Index );
}
void __fastcall DeleteRow( int Index )
{
inherited::DeleteRow( Index );
}
} // <<<<<<<<<<<<<------------- line 35
//--------------------------------------------------------------
namespace Mgrid
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TMGrid)};
RegisterComponents("IDEAtum", classes, 0);
}
}
//--------------------------------------------------------------


#ifndef MGridH
#define MGridH
//--------------------------------------------------------------
#include #include <Classes.hpp>
#include <Controls.hpp>
#include <Grids.hpp>
//--------------------------------------------------------------
class PACKAGE TMGrid : public TStringGrid
{
private:
protected:
public:
__fastcall TMGrid(TComponent* Owner);
__published:
};
//--------------------------------------------------------------
#endif

Back to top
Cactus
Guest





PostPosted: Fri Nov 21, 2003 11:23 am    Post subject: Re: Syntax errors - simple component Reply with quote





Quote:
I have no clue what to do with this error

[C++ Error] MGrid.cpp(21): E2188 Expression syntax
//--------------------------------------------------------------
__fastcall TMGrid::TMGrid(TComponent* Owner) : TStringGrid(Owner)
{
public: //<<<<<<<<<<-------- line 21
void __fastcall MoveRow( int FromIndex, int ToIndex )
{
inherited::MoveRow( FromIndex, ToIndex );
}
} // <<<<<<<<<<<<<------------- line 35
//--------------------------------------------------------------


.............. >_<

"public" never occur in function.
use for "class" declare only.



Back to top
Liz Albin
Guest





PostPosted: Fri Nov 21, 2003 11:30 am    Post subject: Re: Syntax errors - simple component Reply with quote



On 21 Nov 2003 02:58:46 -0700, JD wrote:

Quote:
public: //<<<<<<<<<<-------- line 21

Shouldn't appear in a function.
--
liz

Back to top
Timothy H. Buchman
Guest





PostPosted: Fri Nov 21, 2003 2:51 pm    Post subject: Re: Syntax errors - simple component Reply with quote

"JD" <nospam (AT) nospam (DOT) com> wrote


Apparently you're trying to expose a MoveRow method by creating a
descendant of TStringGrid. If you want to use the word inherited in
CPB, you have to write a typedef for it. For authors not coming from
Delphi, it's more common just to write the name of the class. But you
could write your code like this. Note in each case that most of the
lines were written by the IDE:

Header:
typedef TCustomGrid inherited;
class PACKAGE TMGrid : public TStringGrid
{
private:
protected:
public:
__fastcall TMGrid(TComponent* Owner);
void __fastcall MoveRow( int FromIndex, int ToIndex );
__published:
};


Code File:
__fastcall TMGrid::TMGrid(TComponent* Owner)
: TStringGrid(Owner)
{
}
void __fastcall TMGrid::MoveRow( int FromIndex, int ToIndex )
{
inherited::MoveRow( FromIndex, ToIndex );
}

--
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenterD O Torg
Search .borland message archive on http://www.tamaracka.com/search.htm

Back to top
chris
Guest





PostPosted: Fri Nov 21, 2003 3:14 pm    Post subject: Re: Syntax errors - simple component Reply with quote


"Timothy H. Buchman" <tbuchmanREMOVE(at)PLEASEcitycenter D O To r g> a écrit
dans le message de news: [email]3fbe2721 (AT) newsgroups (DOT) borland.com[/email]...
Quote:
"JD" <nospam (AT) nospam (DOT) com> wrote in message
news:3fbdefe6$1 (AT) newsgroups (DOT) borland.com...

Apparently you're trying to expose a MoveRow method by creating a
descendant of TStringGrid. If you want to use the word inherited in
CPB, you have to write a typedef for it. For authors not coming from
Delphi, it's more common just to write the name of the class. But you
could write your code like this. Note in each case that most of the
lines were written by the IDE:

Header:
typedef TCustomGrid inherited;
class PACKAGE TMGrid : public TStringGrid
{
private:
protected:
public:
__fastcall TMGrid(TComponent* Owner);
void __fastcall MoveRow( int FromIndex, int ToIndex );
__published:
};


Code File:
__fastcall TMGrid::TMGrid(TComponent* Owner)
: TStringGrid(Owner)
{
}
void __fastcall TMGrid::MoveRow( int FromIndex, int ToIndex )
{
inherited::MoveRow( FromIndex, ToIndex );
}


It will be better to put the typedef inside the class.

Doing this will allow you to redefine inherited in other files without
conflicts....

--
chris



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Nov 21, 2003 8:36 pm    Post subject: Re: Syntax errors - simple component Reply with quote


"JD" <nospam (AT) nospam (DOT) com> wrote


Quote:
I want to install a StringGrid decendant to the pallette but
I'm getting compile errors. May I have some help please?

You are trying to declare functions inside of other functions. You can't do
that. You are supposed to declare your new methods in the header file and
them implement them separately in the .cpp file. Do not try to do
everything inside the constructor code. For example:

--- MGrid.h ---

#ifndef MGridH
#define MGridH
//--------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <Grids.hpp>
//--------------------------------------------------------------
class PACKAGE TMGrid : public TStringGrid
{
typedef TStringGrid inherited;
private:
protected:
public:
__fastcall TMGrid(TComponent* Owner);
void __fastcall MoveRow( int FromIndex, int ToIndex );
void __fastcall InsertRow( int Index );
void __fastcall DeleteRow( int Index );
__published:
};
//--------------------------------------------------------------
#endif


--- MGrid.cpp ---

//--------------------------------------------------------------
#include <vcl.h>

#pragma hdrstop

#include "MGrid.h"
#pragma package(smart_init)
//--------------------------------------------------------------
static inline void ValidCtrCheck(TMGrid *)
{
new TMGrid(NULL);
}
//--------------------------------------------------------------
__fastcall TMGrid::TMGrid(TComponent* Owner)
: TStringGrid(Owner)
{
}
//--------------------------------------------------------------
void __fastcall TMGrid::MoveRow( int FromIndex, int ToIndex )
{
inherited::MoveRow( FromIndex, ToIndex );
}
//--------------------------------------------------------------
void __fastcall TMGrid::InsertRow( int Index )
{
// this statement will not work
// ++RowCount;

RowCount = RowCount + 1;
inherited::MoveRow( RowCount - 1, Index );
}
//--------------------------------------------------------------
void __fastcall TMGrid::DeleteRow( int Index )
{
inherited::DeleteRow( Index );
}
//--------------------------------------------------------------
namespace Mgrid
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TMGrid)};
RegisterComponents("IDEAtum", classes, 0);
}
}
//--------------------------------------------------------------



Gambit



Back to top
JD
Guest





PostPosted: Sun Nov 23, 2003 9:44 am    Post subject: Re: Syntax errors - simple component Reply with quote


"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:
Quote:
[...] For example:

Thanks for the help. I did manage to get most of it but I was
stuck with the typedef for inherited. Using TCustomGrid kept
causing a compiler error but it's handled and on my palette.
Now that that's over, I feel like I should have known how :-d

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.