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 

"Type name expected" error with custom component

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





PostPosted: Wed May 24, 2006 7:14 pm    Post subject: "Type name expected" error with custom component Reply with quote



I have BDS2006 with Patch 2. I made a component, TMemoAutosize,
that is derived from TMemo. All the new component does is
publish the AutoSize property. I installed the component in the
tool palette.

Now I drop a TMemoAutosize on an SDI app. The header for the
main form of the app is

#ifndef SDIMainH
#define SDIMainH

// tons of includes
#include "MemoAutosize.h" // line A

class TSDIAppForm : public TForm
{

__published:
// lots of pointers
TMemoAutosize *MemoAutosize1; // line B
private:
//etc
};
extern TSDIAppForm *SDIAppForm;
#endif


When I try to compile the unit SDIMAIN.CPP, the compiler gives
the error

E2303 Type name expected

for line B above. I thought I could try commenting out line A
and putting in a forward declaration class TMemoAutosize;
in its place, but if I do the compiler adds a new copy of line A
right where the old (commented out) line is!

Any suggestions?

Thanks.
Greg
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed May 24, 2006 10:14 pm    Post subject: Re: "Type name expected" error with custom component Reply with quote



"Greg Reese" <kittythebulldog-1 (AT) yahoo (DOT) com> wrote in message
news:4474a9b7$1 (AT) newsgroups (DOT) borland.com...

Quote:
#include "MemoAutosize.h" // line A

What does the content of that file actually look like?


Gambit
Back to top
Greg Reese
Guest





PostPosted: Fri Jun 02, 2006 1:09 am    Post subject: Re: "Type name expected" error with custom component Reply with quote



Quote:
#include "MemoAutosize.h" // line A

What does the content of that file actually look like?

It looks like something it shouldn't look like! It was pulling
in an old version of code. That's fixed now and it's compiling.
Thank you.


The component doesn't seem to be working though.
What I would like to do is to have the memo fit itself to
whatever text I put in. (The text changes dynamically.) I
derived from TMemo and the only thing I did was set AutoSize
to true. The autosizing doesn't seem to work though. All I
get is a box of the design-time width and the height of one
line of text. Do I need to do anything more with AutoSize to
get it to work, e.g., Refresh(), Repaint() (neither of which
helped).

Thanks.
Greg
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Jun 02, 2006 3:44 am    Post subject: Re: "Type name expected" error with custom component Reply with quote

"Greg Reese" <kittythebulldog-1 (AT) yahoo (DOT) com> wrote in message
news:447f497e$1 (AT) newsgroups (DOT) borland.com...

Quote:
What I would like to do is to have the memo fit itself to
whatever text I put in. (The text changes dynamically.) I
derived from TMemo and the only thing I did was set
AutoSize to true. The autosizing doesn't seem to work
though. All I get is a box of the design-time width and
the height of one line of text.

That is by design. AutoSize in TMemo only effects the Height, never the
Width. You would have to resize the Width manually.


Gambit
Back to top
Greg Reese
Guest





PostPosted: Fri Jun 02, 2006 4:15 pm    Post subject: Re: "Type name expected" error with custom component Reply with quote

Quote:
What I would like to do is to have the memo fit itself to
whatever text I put in. (The text changes dynamically.) I
derived from TMemo and the only thing I did was set
AutoSize to true. The autosizing doesn't seem to work
though. All I get is a box of the design-time width and
the height of one line of text.

That is by design. AutoSize in TMemo only effects the Height, never the
Width. You would have to resize the Width manually.

That's okay, I can live with setting the width manually. The
problem is that the height isn't changing. Specifically, when
the memo appears its height has been changed from the design
height of several text lines to only one text line. The width
stays the same as the design width, as you said. How can I make
the height change automatically whenever I put new text in the
memo?

Thanks.
Greg
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Jun 03, 2006 12:02 am    Post subject: Re: "Type name expected" error with custom component Reply with quote

"Greg Reese" <kittythebulldog-1 (AT) yahoo (DOT) com> wrote in message
news:448056b0 (AT) newsgroups (DOT) borland.com...

Quote:
How can I make the height change automatically whenever
I put new text in the memo?

After digging into it further, the AutoSize functionality is specifically
designed to only size the component to the height of 1 line. That's
probably why TEdit sets AutoSize to true and TMemo sets it to False by
default. I don't see any readily available way to accomplish what you want,
other than to leave AutoSize to false and then override the virtual Change()
method to do the resizing every time the text changes. TCustomEdit uses
GetTextMetrics() to calculate the height of a line. You can also use
DrawText() to account for multiple lines.


Gambit
Back to top
Greg Reese
Guest





PostPosted: Mon Jun 05, 2006 5:53 pm    Post subject: Re: "Type name expected" error with custom component Reply with quote

"Remy Lebeau \(TeamB\)" <no.spam (AT) no (DOT) spam.com> wrote:
Quote:

"Greg Reese" <kittythebulldog-1 (AT) yahoo (DOT) com> wrote in message
news:448056b0 (AT) newsgroups (DOT) borland.com...

How can I make the height change automatically whenever
I put new text in the memo?

After digging into it further, the AutoSize functionality is specifically
designed to only size the component to the height of 1 line. That's
probably why TEdit sets AutoSize to true and TMemo sets it to False by
default. I don't see any readily available way to accomplish what you want,

Bummer.

Quote:
other than to leave AutoSize to false and then override the virtual Change()
method to do the resizing every time the text changes. TCustomEdit uses
GetTextMetrics() to calculate the height of a line. You can also use
DrawText() to account for multiple lines.

Okay, I'll give those a try. Thanks for looking into this, Remy.

Greg Reese
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.