 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ettienne Gilbert Guest
|
Posted: Fri Jul 22, 2005 2:41 pm Post subject: Default text & Icon for installing component |
|
|
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
|
Posted: Fri Jul 22, 2005 3:53 pm Post subject: Re: Default text & Icon for installing component |
|
|
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
|
Posted: Fri Jul 22, 2005 5:53 pm Post subject: Re: Default text & Icon for installing component |
|
|
"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.
Obviously so, since every other component has its own icon.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Jul 22, 2005 5:53 pm Post subject: Re: Default text & Icon for installing component |
|
|
"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
|
|
| Back to top |
|
 |
Ettienne Gilbert Guest
|
Posted: Tue Jul 26, 2005 7:13 am Post subject: Re: Default text & Icon for installing component |
|
|
Thanks Remy - component is working now.
|
|
| Back to top |
|
 |
|
|
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
|
|