 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
BJ Guest
|
Posted: Sun Apr 01, 2007 2:41 pm Post subject: Button |
|
|
Hi,
Is there a way that you can put two lines in the caption of a button? |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Apr 02, 2007 12:01 am Post subject: Re: Button |
|
|
"BJ" <caophong (AT) gmail (DOT) com> wrote in message
news:460f703a$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Is there a way that you can put two lines in the caption of a
button? |
Yes, but not at design-time, unless you write (or find) and install a
new component for that.
To do what you ask, you need to change the Button's window style to
include the BS_MULTILINE flag, and then you can use line breaks in
your Caption string.
The best way to handle that is to derive a new class from the Button
and then override the CreateParams() method, ie:
class TMyButton : public TButton
{
protected:
virtual void __fastcall CreateParams(TCreateParams &Params);
};
void __fastcall TMyButton::CreateParams(TCreateParams &Params)
{
TButton::CreateParams(Params);
Params.Style |= BS_MULTILINE;
}
If you do not derive a new class, then you will have to use
Get/SetWindowLong(), and also subclass the standard Button's
WindowProc property, ie:
private:
TWndMethod OldButtonWndProc;
void __fastcall ButtonWndProc(TMessage &Message);
void __fastcall SetButtonStyle(TButton *Button);
__fastcall TForm1::TForm1(TCompoent *Owner)
: TForm(Owner)
{
OldButtonWndProc = Button1->WindowProc;
Button1->WindowProc = ButtonWndProc;
SetButtonStyle(Button1);
}
void __fastcall TForm1::ButtonWndProc(TMessage &Message)
{
OldButtonWndProc(Message);
if( Message.Msg == CM_RECREATEWND )
SetButtonStyle(Button1);
}
void __fastcall TForm1::SetButtonStyle(TButton *Button)
{
long style = GetWindowLong(Button->Handle, GWL_STYLE);
if( (style & BS_MULTILINE) == 0 )
SetWindowLong(Button->Handle, GWL_STYLE, style |
BS_MULTILINE);
}
Gambit |
|
| Back to top |
|
 |
BJ Guest
|
Posted: Fri Apr 06, 2007 4:19 am Post subject: Re: Button |
|
|
Thanks Gambit. I'll give it a try. |
|
| 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
|
|