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 

Button

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





PostPosted: Sun Apr 01, 2007 2:41 pm    Post subject: Button Reply with quote



Hi,

Is there a way that you can put two lines in the caption of a button?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Apr 02, 2007 12:01 am    Post subject: Re: Button Reply with quote



"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





PostPosted: Fri Apr 06, 2007 4:19 am    Post subject: Re: Button Reply with quote



Thanks Gambit. I'll give it a try.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students) 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.