Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Unable to set background color of an SWT Button
Unable to set background color of an SWT Button [message #454216] Tue, 19 April 2005 08:41 Go to next message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
Hello,


I have Eclipse 3.0.1 under windows XP.
I have created a simple SWT Shell (window), with the help of the Visual
Editor Plugin.


By using the setBackground(...) method, I can easily change the
background of a label. But when I do the same to a button, it just
ignores me.


Is that normal? Is it a bug? A missing feature which will be available
in a later version? Or is it that the OS Look and Feel prevails for
this?


In any case... is there a workaround for this limitation? I could
change the whole OS Look and Feel, but this is too radical, and also in
my application I will need to have buttons of different colors
depending on its functionality.

The only workaround I can think of is to do like Swing does and write my
own button component from scratch. That looks too much like a brute force
approach.

Thanks for your help,


Luis.
Re: Unable to set background color of an SWT Button [message #454236 is a reply to message #454216] Tue, 19 April 2005 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Hello Luis,
This is currently not possible on windows and there is bug report filed
in bugzilla.

-chhil
Luis wrote:
> Hello,
>
> I have Eclipse 3.0.1 under windows XP. I have created a simple SWT Shell
> (window), with the help of the Visual Editor Plugin.
>
> By using the setBackground(...) method, I can easily change the
> background of a label. But when I do the same to a button, it just
> ignores me.
>
> Is that normal? Is it a bug? A missing feature which will be available
> in a later version? Or is it that the OS Look and Feel prevails for this?
>
> In any case... is there a workaround for this limitation? I could change
> the whole OS Look and Feel, but this is too radical, and also in my
> application I will need to have buttons of different colors depending on
> its functionality.
> The only workaround I can think of is to do like Swing does and write my
> own button component from scratch. That looks too much like a brute
> force approach.
>
> Thanks for your help,
>
> Luis.
>
Re: Unable to set background color of an SWT Button [message #454283 is a reply to message #454236] Tue, 19 April 2005 15:51 Go to previous messageGo to next message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
Thank you, now this makes a lot of sense.

I have been searching in eclipse bugzilla but could not find the bug (I got
too 200 hits for "button background swt windows").

Could you give me the bug number?

Regards,
Luis.

"Chhil" <aaa@domain.invalid> wrote in message
news:d438nb$el6$1@news.eclipse.org...
> Hello Luis,
> This is currently not possible on windows and there is bug report filed
> in bugzilla.
>
> -chhil
> Luis wrote:
> > Hello,
> >
> > I have Eclipse 3.0.1 under windows XP. I have created a simple SWT Shell
> > (window), with the help of the Visual Editor Plugin.
> >
> > By using the setBackground(...) method, I can easily change the
> > background of a label. But when I do the same to a button, it just
> > ignores me.
> >
> > Is that normal? Is it a bug? A missing feature which will be available
> > in a later version? Or is it that the OS Look and Feel prevails for
this?
> >
> > In any case... is there a workaround for this limitation? I could change
> > the whole OS Look and Feel, but this is too radical, and also in my
> > application I will need to have buttons of different colors depending on
> > its functionality.
> > The only workaround I can think of is to do like Swing does and write my
> > own button component from scratch. That looks too much like a brute
> > force approach.
> >
> > Thanks for your help,
> >
> > Luis.
> >
Re: Unable to set background color of an SWT Button [message #454287 is a reply to message #454283] Tue, 19 April 2005 16:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

https://bugs.eclipse.org/bugs/show_bug.cgi?id=23837

-chhil
Re: Unable to set background color of an SWT Button [message #454493 is a reply to message #454236] Fri, 22 April 2005 15:27 Go to previous messageGo to next message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
Hello,

I did a quick test in C# with MS Visual Studio 2003 and I was able to change
the background color of a Windows button:

System.Windows.Forms.Button but;
but=new System.Windows.Forms.Button();
but.BackColor = System.Drawing.Color.Aquamarine;

With the code above you can get a nice aquamarine button in Windows.
I am pretty sure that, unlike Swing, C# and .NET do not emulate buttons but
use the standard Windows ones. That is, as far as I understand, that code
eventually invokes the standard Windows system GUI primitives.
So I don't understand why the bug appears as "WONTFIX"
.....?



"Chhil" <aaa@domain.invalid> wrote in message
news:d438nb$el6$1@news.eclipse.org...
> Hello Luis,
> This is currently not possible on windows and there is bug report filed
> in bugzilla.
>
> -chhil
> Luis wrote:
> > Hello,
> >
> > I have Eclipse 3.0.1 under windows XP. I have created a simple SWT Shell
> > (window), with the help of the Visual Editor Plugin.
> >
> > By using the setBackground(...) method, I can easily change the
> > background of a label. But when I do the same to a button, it just
> > ignores me.
> >
> > Is that normal? Is it a bug? A missing feature which will be available
> > in a later version? Or is it that the OS Look and Feel prevails for
this?
> >
> > In any case... is there a workaround for this limitation? I could change
> > the whole OS Look and Feel, but this is too radical, and also in my
> > application I will need to have buttons of different colors depending on
> > its functionality.
> > The only workaround I can think of is to do like Swing does and write my
> > own button component from scratch. That looks too much like a brute
> > force approach.
> >
> > Thanks for your help,
> >
> > Luis.
> >
Re: Unable to set background color of an SWT Button [message #454505 is a reply to message #454493] Sat, 23 April 2005 19:34 Go to previous messageGo to next message
Emil Crumhorn is currently offline Emil CrumhornFriend
Messages: 169
Registered: July 2009
Senior Member
Unless it's doable on all platforms that SWT supports, chaning the button
color won't be added even if it's doable on Windows. It doesn't surprise me
that C# lets you do it if it's in the windows API.

If you don't care about cross-platform compatability for you app (or you
only do the needed calls if you're on Windows), you can just make the
necessary SendMessage calls on the win32 OS api that SWT comes with.

Here's some API info regarding themes and changing them:
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp

And a google search on "win32 changing button color" will get you more info.

Hope that helps,
Emil

"Luis" <lcrespom@gmail.com> wrote in message
news:d4b589$jqs$1@news.eclipse.org...
> Hello,
>
> I did a quick test in C# with MS Visual Studio 2003 and I was able to
> change
> the background color of a Windows button:
>
> System.Windows.Forms.Button but;
> but=new System.Windows.Forms.Button();
> but.BackColor = System.Drawing.Color.Aquamarine;
>
> With the code above you can get a nice aquamarine button in Windows.
> I am pretty sure that, unlike Swing, C# and .NET do not emulate buttons
> but
> use the standard Windows ones. That is, as far as I understand, that code
> eventually invokes the standard Windows system GUI primitives.
> So I don't understand why the bug appears as "WONTFIX"
> ....?
>
>
>
> "Chhil" <aaa@domain.invalid> wrote in message
> news:d438nb$el6$1@news.eclipse.org...
>> Hello Luis,
>> This is currently not possible on windows and there is bug report filed
>> in bugzilla.
>>
>> -chhil
>> Luis wrote:
>> > Hello,
>> >
>> > I have Eclipse 3.0.1 under windows XP. I have created a simple SWT
>> > Shell
>> > (window), with the help of the Visual Editor Plugin.
>> >
>> > By using the setBackground(...) method, I can easily change the
>> > background of a label. But when I do the same to a button, it just
>> > ignores me.
>> >
>> > Is that normal? Is it a bug? A missing feature which will be available
>> > in a later version? Or is it that the OS Look and Feel prevails for
> this?
>> >
>> > In any case... is there a workaround for this limitation? I could
>> > change
>> > the whole OS Look and Feel, but this is too radical, and also in my
>> > application I will need to have buttons of different colors depending
>> > on
>> > its functionality.
>> > The only workaround I can think of is to do like Swing does and write
>> > my
>> > own button component from scratch. That looks too much like a brute
>> > force approach.
>> >
>> > Thanks for your help,
>> >
>> > Luis.
>> >
>
>
Re: Unable to set background color of an SWT Button [message #454587 is a reply to message #454505] Mon, 25 April 2005 08:45 Go to previous messageGo to next message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
But wait, this bug is a bug precisely in Windows!
As far as I know, the button background color DOES change in other OSs.

According to Chhil's reply:
"This is currently not possible on windows and there is bug report
filed"
And I have seen the bug report (id 23837), and it is reported as a Windows
bug.

Anyway, thank you for the info on the SendMessage call: I can always check
the OS before making the call, that way my code can still be portable.


"Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
news:d4e83m$9m4$1@news.eclipse.org...
> Unless it's doable on all platforms that SWT supports, chaning the button
> color won't be added even if it's doable on Windows. It doesn't surprise
me
> that C# lets you do it if it's in the windows API.
>
> If you don't care about cross-platform compatability for you app (or you
> only do the needed calls if you're on Windows), you can just make the
> necessary SendMessage calls on the win32 OS api that SWT comes with.
>
> Here's some API info regarding themes and changing them:
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp
>
> And a google search on "win32 changing button color" will get you more
info.
>
> Hope that helps,
> Emil
>
> "Luis" <lcrespom@gmail.com> wrote in message
> news:d4b589$jqs$1@news.eclipse.org...
> > Hello,
> >
> > I did a quick test in C# with MS Visual Studio 2003 and I was able to
> > change
> > the background color of a Windows button:
> >
> > System.Windows.Forms.Button but;
> > but=new System.Windows.Forms.Button();
> > but.BackColor = System.Drawing.Color.Aquamarine;
> >
> > With the code above you can get a nice aquamarine button in Windows.
> > I am pretty sure that, unlike Swing, C# and .NET do not emulate buttons
> > but
> > use the standard Windows ones. That is, as far as I understand, that
code
> > eventually invokes the standard Windows system GUI primitives.
> > So I don't understand why the bug appears as "WONTFIX"
> > ....?
> >
> >
> >
> > "Chhil" <aaa@domain.invalid> wrote in message
> > news:d438nb$el6$1@news.eclipse.org...
> >> Hello Luis,
> >> This is currently not possible on windows and there is bug report
filed
> >> in bugzilla.
> >>
> >> -chhil
> >> Luis wrote:
> >> > Hello,
> >> >
> >> > I have Eclipse 3.0.1 under windows XP. I have created a simple SWT
> >> > Shell
> >> > (window), with the help of the Visual Editor Plugin.
> >> >
> >> > By using the setBackground(...) method, I can easily change the
> >> > background of a label. But when I do the same to a button, it just
> >> > ignores me.
> >> >
> >> > Is that normal? Is it a bug? A missing feature which will be
available
> >> > in a later version? Or is it that the OS Look and Feel prevails for
> > this?
> >> >
> >> > In any case... is there a workaround for this limitation? I could
> >> > change
> >> > the whole OS Look and Feel, but this is too radical, and also in my
> >> > application I will need to have buttons of different colors depending
> >> > on
> >> > its functionality.
> >> > The only workaround I can think of is to do like Swing does and write
> >> > my
> >> > own button component from scratch. That looks too much like a brute
> >> > force approach.
> >> >
> >> > Thanks for your help,
> >> >
> >> > Luis.
> >> >
> >
> >
>
>
Re: Unable to set background color of an SWT Button [message #454594 is a reply to message #454587] Mon, 25 April 2005 13:10 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Luis, please reopen 23837 with a link to the MSDN or a patch to fix the
problem on Windows but don't reopen the bug report unless there is enough
information to fix it. Thanks!

"Luis" <lcrespom@gmail.com> wrote in message
news:d4iarq$k7t$1@news.eclipse.org...
> But wait, this bug is a bug precisely in Windows!
> As far as I know, the button background color DOES change in other OSs.
>
> According to Chhil's reply:
> "This is currently not possible on windows and there is bug report
> filed"
> And I have seen the bug report (id 23837), and it is reported as a Windows
> bug.
>
> Anyway, thank you for the info on the SendMessage call: I can always check
> the OS before making the call, that way my code can still be portable.
>
>
> "Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
> news:d4e83m$9m4$1@news.eclipse.org...
> > Unless it's doable on all platforms that SWT supports, chaning the
button
> > color won't be added even if it's doable on Windows. It doesn't surprise
> me
> > that C# lets you do it if it's in the windows API.
> >
> > If you don't care about cross-platform compatability for you app (or you
> > only do the needed calls if you're on Windows), you can just make the
> > necessary SendMessage calls on the win32 OS api that SWT comes with.
> >
> > Here's some API info regarding themes and changing them:
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp
> >
> > And a google search on "win32 changing button color" will get you more
> info.
> >
> > Hope that helps,
> > Emil
> >
> > "Luis" <lcrespom@gmail.com> wrote in message
> > news:d4b589$jqs$1@news.eclipse.org...
> > > Hello,
> > >
> > > I did a quick test in C# with MS Visual Studio 2003 and I was able to
> > > change
> > > the background color of a Windows button:
> > >
> > > System.Windows.Forms.Button but;
> > > but=new System.Windows.Forms.Button();
> > > but.BackColor = System.Drawing.Color.Aquamarine;
> > >
> > > With the code above you can get a nice aquamarine button in Windows.
> > > I am pretty sure that, unlike Swing, C# and .NET do not emulate
buttons
> > > but
> > > use the standard Windows ones. That is, as far as I understand, that
> code
> > > eventually invokes the standard Windows system GUI primitives.
> > > So I don't understand why the bug appears as "WONTFIX"
> > > ....?
> > >
> > >
> > >
> > > "Chhil" <aaa@domain.invalid> wrote in message
> > > news:d438nb$el6$1@news.eclipse.org...
> > >> Hello Luis,
> > >> This is currently not possible on windows and there is bug report
> filed
> > >> in bugzilla.
> > >>
> > >> -chhil
> > >> Luis wrote:
> > >> > Hello,
> > >> >
> > >> > I have Eclipse 3.0.1 under windows XP. I have created a simple SWT
> > >> > Shell
> > >> > (window), with the help of the Visual Editor Plugin.
> > >> >
> > >> > By using the setBackground(...) method, I can easily change the
> > >> > background of a label. But when I do the same to a button, it just
> > >> > ignores me.
> > >> >
> > >> > Is that normal? Is it a bug? A missing feature which will be
> available
> > >> > in a later version? Or is it that the OS Look and Feel prevails for
> > > this?
> > >> >
> > >> > In any case... is there a workaround for this limitation? I could
> > >> > change
> > >> > the whole OS Look and Feel, but this is too radical, and also in my
> > >> > application I will need to have buttons of different colors
depending
> > >> > on
> > >> > its functionality.
> > >> > The only workaround I can think of is to do like Swing does and
write
> > >> > my
> > >> > own button component from scratch. That looks too much like a brute
> > >> > force approach.
> > >> >
> > >> > Thanks for your help,
> > >> >
> > >> > Luis.
> > >> >
> > >
> > >
> >
> >
>
>
Re: Unable to set background color of an SWT Button [message #454677 is a reply to message #454594] Wed, 27 April 2005 10:53 Go to previous messageGo to next message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
Hi,

I have been looking both MSDN and the source code of
org.eclipse.swt.widgets.Button and org.eclipse.swt.internal.win32.OS.
(Link to MDSN information about Windows Buttons:
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/shellcc/platform/commctls/buttons/buttontypesandstyles. asp)

Apparently some buttons in windows allow for a change in the background
color and some others don't. Specifically, only the ones of type
"BS_OWNERDRAW" allow for that. As the name implies, the application has to
draw the inside of the button, and that is what SWT does with arrow buttons
but not with the other ones.

So probably fixing the bug for arrow buttons would be relatively easy, while
providing the same functionality for the rest of the SWT button types would
require a bigger change in the code. Anyway that is not a crazy idea since
this is what .net does with all buttons.

In summary: I think there is enough information to fix the bug, but the fix
is not a simple one. Do you think that the provided information is enough?
Also, given the amount of work required for the fix, it may be a very
low-priority bug...

Regards,

Luis.


"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:d4iqcr$8l9$1@news.eclipse.org...
> Luis, please reopen 23837 with a link to the MSDN or a patch to fix the
> problem on Windows but don't reopen the bug report unless there is enough
> information to fix it. Thanks!
>
> "Luis" <lcrespom@gmail.com> wrote in message
> news:d4iarq$k7t$1@news.eclipse.org...
> > But wait, this bug is a bug precisely in Windows!
> > As far as I know, the button background color DOES change in other OSs.
> >
> > According to Chhil's reply:
> > "This is currently not possible on windows and there is bug report
> > filed"
> > And I have seen the bug report (id 23837), and it is reported as a
Windows
> > bug.
> >
> > Anyway, thank you for the info on the SendMessage call: I can always
check
> > the OS before making the call, that way my code can still be portable.
> >
> >
> > "Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
> > news:d4e83m$9m4$1@news.eclipse.org...
> > > Unless it's doable on all platforms that SWT supports, chaning the
> button
> > > color won't be added even if it's doable on Windows. It doesn't
surprise
> > me
> > > that C# lets you do it if it's in the windows API.
> > >
> > > If you don't care about cross-platform compatability for you app (or
you
> > > only do the needed calls if you're on Windows), you can just make the
> > > necessary SendMessage calls on the win32 OS api that SWT comes with.
> > >
> > > Here's some API info regarding themes and changing them:
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp
> > >
> > > And a google search on "win32 changing button color" will get you more
> > info.
> > >
> > > Hope that helps,
> > > Emil
> > >
> > > "Luis" <lcrespom@gmail.com> wrote in message
> > > news:d4b589$jqs$1@news.eclipse.org...
> > > > Hello,
> > > >
> > > > I did a quick test in C# with MS Visual Studio 2003 and I was able
to
> > > > change
> > > > the background color of a Windows button:
> > > >
> > > > System.Windows.Forms.Button but;
> > > > but=new System.Windows.Forms.Button();
> > > > but.BackColor = System.Drawing.Color.Aquamarine;
> > > >
> > > > With the code above you can get a nice aquamarine button in Windows.
> > > > I am pretty sure that, unlike Swing, C# and .NET do not emulate
> buttons
> > > > but
> > > > use the standard Windows ones. That is, as far as I understand, that
> > code
> > > > eventually invokes the standard Windows system GUI primitives.
> > > > So I don't understand why the bug appears as "WONTFIX"
> > > > ....?
> > > >
> > > >
> > > >
> > > > "Chhil" <aaa@domain.invalid> wrote in message
> > > > news:d438nb$el6$1@news.eclipse.org...
> > > >> Hello Luis,
> > > >> This is currently not possible on windows and there is bug report
> > filed
> > > >> in bugzilla.
> > > >>
> > > >> -chhil
> > > >> Luis wrote:
> > > >> > Hello,
> > > >> >
> > > >> > I have Eclipse 3.0.1 under windows XP. I have created a simple
SWT
> > > >> > Shell
> > > >> > (window), with the help of the Visual Editor Plugin.
> > > >> >
> > > >> > By using the setBackground(...) method, I can easily change the
> > > >> > background of a label. But when I do the same to a button, it
just
> > > >> > ignores me.
> > > >> >
> > > >> > Is that normal? Is it a bug? A missing feature which will be
> > available
> > > >> > in a later version? Or is it that the OS Look and Feel prevails
for
> > > > this?
> > > >> >
> > > >> > In any case... is there a workaround for this limitation? I could
> > > >> > change
> > > >> > the whole OS Look and Feel, but this is too radical, and also in
my
> > > >> > application I will need to have buttons of different colors
> depending
> > > >> > on
> > > >> > its functionality.
> > > >> > The only workaround I can think of is to do like Swing does and
> write
> > > >> > my
> > > >> > own button component from scratch. That looks too much like a
brute
> > > >> > force approach.
> > > >> >
> > > >> > Thanks for your help,
> > > >> >
> > > >> > Luis.
> > > >> >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Unable to set background color of an SWT Button [message #454679 is a reply to message #454677] Wed, 27 April 2005 13:23 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Please add this information to the bug report but don't reopen it. This is
the same conclusion that I came to a while back.

If fixing the button requires owner draw, then we aren't really interested
at this time. Owner draw has all kinds of bad problems associated with it
that don't seem worth it. Setting the background color of a control in this
day and age is dicy anways given the advent of themes and theme managers.

"Luis" <lcrespom@gmail.com> wrote in message
news:d4nr69$ghi$1@news.eclipse.org...
> Hi,
>
> I have been looking both MSDN and the source code of
> org.eclipse.swt.widgets.Button and org.eclipse.swt.internal.win32.OS.
> (Link to MDSN information about Windows Buttons:
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/shellcc/platform/commctls/buttons/buttontypesandstyles. asp)
>
> Apparently some buttons in windows allow for a change in the background
> color and some others don't. Specifically, only the ones of type
> "BS_OWNERDRAW" allow for that. As the name implies, the application has to
> draw the inside of the button, and that is what SWT does with arrow
buttons
> but not with the other ones.
>
> So probably fixing the bug for arrow buttons would be relatively easy,
while
> providing the same functionality for the rest of the SWT button types
would
> require a bigger change in the code. Anyway that is not a crazy idea since
> this is what .net does with all buttons.
>
> In summary: I think there is enough information to fix the bug, but the
fix
> is not a simple one. Do you think that the provided information is enough?
> Also, given the amount of work required for the fix, it may be a very
> low-priority bug...
>
> Regards,
>
> Luis.
>
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:d4iqcr$8l9$1@news.eclipse.org...
> > Luis, please reopen 23837 with a link to the MSDN or a patch to fix the
> > problem on Windows but don't reopen the bug report unless there is
enough
> > information to fix it. Thanks!
> >
> > "Luis" <lcrespom@gmail.com> wrote in message
> > news:d4iarq$k7t$1@news.eclipse.org...
> > > But wait, this bug is a bug precisely in Windows!
> > > As far as I know, the button background color DOES change in other
OSs.
> > >
> > > According to Chhil's reply:
> > > "This is currently not possible on windows and there is bug
report
> > > filed"
> > > And I have seen the bug report (id 23837), and it is reported as a
> Windows
> > > bug.
> > >
> > > Anyway, thank you for the info on the SendMessage call: I can always
> check
> > > the OS before making the call, that way my code can still be portable.
> > >
> > >
> > > "Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
> > > news:d4e83m$9m4$1@news.eclipse.org...
> > > > Unless it's doable on all platforms that SWT supports, chaning the
> > button
> > > > color won't be added even if it's doable on Windows. It doesn't
> surprise
> > > me
> > > > that C# lets you do it if it's in the windows API.
> > > >
> > > > If you don't care about cross-platform compatability for you app (or
> you
> > > > only do the needed calls if you're on Windows), you can just make
the
> > > > necessary SendMessage calls on the win32 OS api that SWT comes with.
> > > >
> > > > Here's some API info regarding themes and changing them:
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp
> > > >
> > > > And a google search on "win32 changing button color" will get you
more
> > > info.
> > > >
> > > > Hope that helps,
> > > > Emil
> > > >
> > > > "Luis" <lcrespom@gmail.com> wrote in message
> > > > news:d4b589$jqs$1@news.eclipse.org...
> > > > > Hello,
> > > > >
> > > > > I did a quick test in C# with MS Visual Studio 2003 and I was able
> to
> > > > > change
> > > > > the background color of a Windows button:
> > > > >
> > > > > System.Windows.Forms.Button but;
> > > > > but=new System.Windows.Forms.Button();
> > > > > but.BackColor = System.Drawing.Color.Aquamarine;
> > > > >
> > > > > With the code above you can get a nice aquamarine button in
Windows.
> > > > > I am pretty sure that, unlike Swing, C# and .NET do not emulate
> > buttons
> > > > > but
> > > > > use the standard Windows ones. That is, as far as I understand,
that
> > > code
> > > > > eventually invokes the standard Windows system GUI primitives.
> > > > > So I don't understand why the bug appears as "WONTFIX"
> > > > > ....?
> > > > >
> > > > >
> > > > >
> > > > > "Chhil" <aaa@domain.invalid> wrote in message
> > > > > news:d438nb$el6$1@news.eclipse.org...
> > > > >> Hello Luis,
> > > > >> This is currently not possible on windows and there is bug
report
> > > filed
> > > > >> in bugzilla.
> > > > >>
> > > > >> -chhil
> > > > >> Luis wrote:
> > > > >> > Hello,
> > > > >> >
> > > > >> > I have Eclipse 3.0.1 under windows XP. I have created a simple
> SWT
> > > > >> > Shell
> > > > >> > (window), with the help of the Visual Editor Plugin.
> > > > >> >
> > > > >> > By using the setBackground(...) method, I can easily change the
> > > > >> > background of a label. But when I do the same to a button, it
> just
> > > > >> > ignores me.
> > > > >> >
> > > > >> > Is that normal? Is it a bug? A missing feature which will be
> > > available
> > > > >> > in a later version? Or is it that the OS Look and Feel prevails
> for
> > > > > this?
> > > > >> >
> > > > >> > In any case... is there a workaround for this limitation? I
could
> > > > >> > change
> > > > >> > the whole OS Look and Feel, but this is too radical, and also
in
> my
> > > > >> > application I will need to have buttons of different colors
> > depending
> > > > >> > on
> > > > >> > its functionality.
> > > > >> > The only workaround I can think of is to do like Swing does and
> > write
> > > > >> > my
> > > > >> > own button component from scratch. That looks too much like a
> brute
> > > > >> > force approach.
> > > > >> >
> > > > >> > Thanks for your help,
> > > > >> >
> > > > >> > Luis.
> > > > >> >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Unable to set background color of an SWT Button [message #454690 is a reply to message #454679] Wed, 27 April 2005 14:02 Go to previous message
Luis is currently offline LuisFriend
Messages: 20
Registered: July 2009
Junior Member
Done!

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:d4o3v2$ssb$1@news.eclipse.org...
> Please add this information to the bug report but don't reopen it. This
is
> the same conclusion that I came to a while back.
>
> If fixing the button requires owner draw, then we aren't really interested
> at this time. Owner draw has all kinds of bad problems associated with it
> that don't seem worth it. Setting the background color of a control in
this
> day and age is dicy anways given the advent of themes and theme managers.
>
> "Luis" <lcrespom@gmail.com> wrote in message
> news:d4nr69$ghi$1@news.eclipse.org...
> > Hi,
> >
> > I have been looking both MSDN and the source code of
> > org.eclipse.swt.widgets.Button and org.eclipse.swt.internal.win32.OS.
> > (Link to MDSN information about Windows Buttons:
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/shellcc/platform/commctls/buttons/buttontypesandstyles. asp)
> >
> > Apparently some buttons in windows allow for a change in the background
> > color and some others don't. Specifically, only the ones of type
> > "BS_OWNERDRAW" allow for that. As the name implies, the application has
to
> > draw the inside of the button, and that is what SWT does with arrow
> buttons
> > but not with the other ones.
> >
> > So probably fixing the bug for arrow buttons would be relatively easy,
> while
> > providing the same functionality for the rest of the SWT button types
> would
> > require a bigger change in the code. Anyway that is not a crazy idea
since
> > this is what .net does with all buttons.
> >
> > In summary: I think there is enough information to fix the bug, but the
> fix
> > is not a simple one. Do you think that the provided information is
enough?
> > Also, given the amount of work required for the fix, it may be a very
> > low-priority bug...
> >
> > Regards,
> >
> > Luis.
> >
> >
> > "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> > news:d4iqcr$8l9$1@news.eclipse.org...
> > > Luis, please reopen 23837 with a link to the MSDN or a patch to fix
the
> > > problem on Windows but don't reopen the bug report unless there is
> enough
> > > information to fix it. Thanks!
> > >
> > > "Luis" <lcrespom@gmail.com> wrote in message
> > > news:d4iarq$k7t$1@news.eclipse.org...
> > > > But wait, this bug is a bug precisely in Windows!
> > > > As far as I know, the button background color DOES change in other
> OSs.
> > > >
> > > > According to Chhil's reply:
> > > > "This is currently not possible on windows and there is bug
> report
> > > > filed"
> > > > And I have seen the bug report (id 23837), and it is reported as a
> > Windows
> > > > bug.
> > > >
> > > > Anyway, thank you for the info on the SendMessage call: I can always
> > check
> > > > the OS before making the call, that way my code can still be
portable.
> > > >
> > > >
> > > > "Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
> > > > news:d4e83m$9m4$1@news.eclipse.org...
> > > > > Unless it's doable on all platforms that SWT supports, chaning the
> > > button
> > > > > color won't be added even if it's doable on Windows. It doesn't
> > surprise
> > > > me
> > > > > that C# lets you do it if it's in the windows API.
> > > > >
> > > > > If you don't care about cross-platform compatability for you app
(or
> > you
> > > > > only do the needed calls if you're on Windows), you can just make
> the
> > > > > necessary SendMessage calls on the win32 OS api that SWT comes
with.
> > > > >
> > > > > Here's some API info regarding themes and changing them:
> > > > >
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/dnwxp/html/xptheming.asp
> > > > >
> > > > > And a google search on "win32 changing button color" will get you
> more
> > > > info.
> > > > >
> > > > > Hope that helps,
> > > > > Emil
> > > > >
> > > > > "Luis" <lcrespom@gmail.com> wrote in message
> > > > > news:d4b589$jqs$1@news.eclipse.org...
> > > > > > Hello,
> > > > > >
> > > > > > I did a quick test in C# with MS Visual Studio 2003 and I was
able
> > to
> > > > > > change
> > > > > > the background color of a Windows button:
> > > > > >
> > > > > > System.Windows.Forms.Button but;
> > > > > > but=new System.Windows.Forms.Button();
> > > > > > but.BackColor = System.Drawing.Color.Aquamarine;
> > > > > >
> > > > > > With the code above you can get a nice aquamarine button in
> Windows.
> > > > > > I am pretty sure that, unlike Swing, C# and .NET do not emulate
> > > buttons
> > > > > > but
> > > > > > use the standard Windows ones. That is, as far as I understand,
> that
> > > > code
> > > > > > eventually invokes the standard Windows system GUI primitives.
> > > > > > So I don't understand why the bug appears as "WONTFIX"
> > > > > > ....?
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Chhil" <aaa@domain.invalid> wrote in message
> > > > > > news:d438nb$el6$1@news.eclipse.org...
> > > > > >> Hello Luis,
> > > > > >> This is currently not possible on windows and there is bug
> report
> > > > filed
> > > > > >> in bugzilla.
> > > > > >>
> > > > > >> -chhil
> > > > > >> Luis wrote:
> > > > > >> > Hello,
> > > > > >> >
> > > > > >> > I have Eclipse 3.0.1 under windows XP. I have created a
simple
> > SWT
> > > > > >> > Shell
> > > > > >> > (window), with the help of the Visual Editor Plugin.
> > > > > >> >
> > > > > >> > By using the setBackground(...) method, I can easily change
the
> > > > > >> > background of a label. But when I do the same to a button, it
> > just
> > > > > >> > ignores me.
> > > > > >> >
> > > > > >> > Is that normal? Is it a bug? A missing feature which will be
> > > > available
> > > > > >> > in a later version? Or is it that the OS Look and Feel
prevails
> > for
> > > > > > this?
> > > > > >> >
> > > > > >> > In any case... is there a workaround for this limitation? I
> could
> > > > > >> > change
> > > > > >> > the whole OS Look and Feel, but this is too radical, and also
> in
> > my
> > > > > >> > application I will need to have buttons of different colors
> > > depending
> > > > > >> > on
> > > > > >> > its functionality.
> > > > > >> > The only workaround I can think of is to do like Swing does
and
> > > write
> > > > > >> > my
> > > > > >> > own button component from scratch. That looks too much like a
> > brute
> > > > > >> > force approach.
> > > > > >> >
> > > > > >> > Thanks for your help,
> > > > > >> >
> > > > > >> > Luis.
> > > > > >> >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:tree layout
Next Topic:How to check System Clipboard
Goto Forum:
  


Current Time: Tue Apr 16 08:37:34 GMT 2024

Powered by FUDForum. Page generated in 0.43407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top