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 

Default text & Icon for installing component

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





PostPosted: Fri Jul 22, 2005 2:41 pm    Post subject: Default text & Icon for installing component Reply with quote



I've created (my first!) component - a THexEdit component derived from
TEdit. Idea is to allow user to only enter hexadecimal characters (0-9,
A-F,a-f). Will expand it as soon as the basics work OK.

Class declaration looks as follows:

class PACKAGE THexEdit : public TEdit
{
private:
Classes::TNotifyEvent FOnChange;
bool inChange;
char fill;
void __fastcall SetFill( char fill );
protected:
DYNAMIC void __fastcall Change(void);
virtual void __fastcall Loaded(void);
public:
__fastcall THexEdit(TComponent* Owner);
__published:
__property char Fill = {read = fill, write = SetFill, default = 'F'};
__property Classes::TNotifyEvent OnChange = {read=FOnChange,
write=FOnChange};
};

I'm rejecting non-hexadecimal characters in overloaded TCustomEdit::Change()
method - in these cases I also do not call user's OnChange event handler.
Everything seems to be working OK so far, but I cannot stop the Text
property defaulting to the component Name property when the component is
added to a form. I've overloaded the component's Loaded() method, as in...

void __fastcall THexEdit::Loaded(void)
{
TEdit::Loaded(); //TControl::Loaded() method
Text = "";
}

This cures the problem for run-time, but not design-time. What is the right
approach so that the Text property is cleared when component is added to
form?

Also, when I install the Component to the Palette (Component | Install
Component), there is no way to specify your own icon for the Palette. Is
this possible?

I'm still on BCB 5....

Many thanks
Ettienne


Back to top
Pete Fraser
Guest





PostPosted: Fri Jul 22, 2005 3:53 pm    Post subject: Re: Default text & Icon for installing component Reply with quote



The icon needs to have the same name as the package
HTH Pete

"Ettienne Gilbert" <ettienneg (AT) prism (DOT) co.za> wrote

Quote:
I've created (my first!) component - a THexEdit component derived from
TEdit. Idea is to allow user to only enter hexadecimal characters (0-9,
A-F,a-f). Will expand it as soon as the basics work OK.

Class declaration looks as follows:

class PACKAGE THexEdit : public TEdit
{
private:
Classes::TNotifyEvent FOnChange;
bool inChange;
char fill;
void __fastcall SetFill( char fill );
protected:
DYNAMIC void __fastcall Change(void);
virtual void __fastcall Loaded(void);
public:
__fastcall THexEdit(TComponent* Owner);
__published:
__property char Fill = {read = fill, write = SetFill, default = 'F'};
__property Classes::TNotifyEvent OnChange = {read=FOnChange,
write=FOnChange};
};

I'm rejecting non-hexadecimal characters in overloaded
TCustomEdit::Change()
method - in these cases I also do not call user's OnChange event handler.
Everything seems to be working OK so far, but I cannot stop the Text
property defaulting to the component Name property when the component is
added to a form. I've overloaded the component's Loaded() method, as in...

void __fastcall THexEdit::Loaded(void)
{
TEdit::Loaded(); //TControl::Loaded() method
Text = "";
}

This cures the problem for run-time, but not design-time. What is the
right
approach so that the Text property is cleared when component is added to
form?

Also, when I install the Component to the Palette (Component | Install
Component), there is no way to specify your own icon for the Palette. Is
this possible?

I'm still on BCB 5....

Many thanks
Ettienne





Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Jul 22, 2005 5:53 pm    Post subject: Re: Default text & Icon for installing component Reply with quote




"Ettienne Gilbert" <ettienneg (AT) prism (DOT) co.za> wrote


Quote:
I'm rejecting non-hexadecimal characters in
overloaded TCustomEdit::Change() method

Intercepting them as they are being typed would be better. Look at
overriding the KeyUp/Down() and/or KeyPress() methods instead. Setting the
Key parameter to 0 rejects the keystroke.

Quote:
What is the right approach so that the Text property is
cleared when component is added to form?

In the constructor, remove the csSetCaption flag from the component's
ControlStyle property.

Quote:
Also, when I install the Component to the Palette (Component | Install
Component), there is no way to specify your own icon for the Palette.

Yes, there is. You have to include the icon into the resources of the
package itself. Create a new .res file that includes a 24x24 bitmap, and
then name the bitmap the same name as your component class name, in all caps
("THEXEDIT" in this case). Then add the .res file to your package.

Quote:
Is this possible?

Obviously so, since every other component has its own icon.


Gambit



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Jul 22, 2005 5:53 pm    Post subject: Re: Default text & Icon for installing component Reply with quote


"Pete Fraser" <pete.fraser (AT) frasersoft (DOT) nospam.com> wrote

Quote:
The icon needs to have the same name as the package

No, the icon has to have the same name as the component itself, not the
package.


Gambit



Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Fri Jul 22, 2005 11:02 pm    Post subject: Re: Default text & Icon for installing component Reply with quote

At 17:53:11, 22.07.2005, Pete Fraser wrote:

Quote:
The icon needs to have the same name as the package

Pete, you quoted* 50 lines, and only added the text above. Please note
that this is a violation of the guidelines in

http://support.borland.com/entry.jspa?externalID=294 rule #1.

*Quoting is copying (automatically or manually) text from the previous
message into your own. Quoted lines are usually marked by one or more >
at the beginning of the line. Please don't quote entire messages, but
only just enough to give the reader a reference. More on proper quoting
can be found here:

http://blogs.teamb.com/rudyvelthuis/articles/7509.aspx
http://www.uwasa.fi/~ts/http/quote.html
http://alt-usage-english.org/posting_quotes.html

Thanks for your future compliance with Borland's guidelines.
--
Rudy Velthuis [TeamB] http://velthuis.homepage.t-online.de

"So I went to the dentist. He said "Say Aaah." I said "Why?"
He said "My dog's died.'" -- Tommy Cooper

Back to top
Ettienne Gilbert
Guest





PostPosted: Tue Jul 26, 2005 7:13 am    Post subject: Re: Default text & Icon for installing component Reply with quote


Thanks Remy - component is working now.


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.