1. Win32Lib: Button Color

Is there a way to set a button color and have it stay that way?

I'm using setBackColor(myButt, Red )

and it draws it red until I click on another control, and it
returns to its normal gray color.

-=ck
"Programming in a state of EUPHORIA."

new topic     » topic index » view message » categorize

2. Re: Win32Lib: Button Color

cklester wrote:
> 
> Is there a way to set a button color and have it stay that way?
> 
> I'm using setBackColor(myButt, Red )
> 
> and it draws it red until I click on another control, and it
> returns to its normal gray color.

I didn't know that one could change the color of a standard 
PushButton control!

Can you show me some example code that does that because I can't
make it happen at all. As far I I know, ou need to have an Owner-Drawn
type of button.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib: Button Color

cklester wrote:
> 
> Is there a way to set a button color and have it stay that way?
> 
> I'm using setBackColor(myButt, Red )
> 

BTW, why do you want to change your butt to red? blink


-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib: Button Color

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Is there a way to set a button color and have it stay that way?
> > 
> > I'm using setBackColor(myButt, Red )
> > 
> 
> BTW, why do you want to change your butt to red? blink

That's easily done, but I, for one, prefer not to have a hand 
in the process :)

Irv

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib: Button Color

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Is there a way to set a button color and have it stay that way?
> > 
> > I'm using setBackColor(myButt, Red )
> > 
> > and it draws it red until I click on another control, and it
> > returns to its normal gray color.
> 
> I didn't know that one could change the color of a standard 
> PushButton control!
> 
> Can you show me some example code that does that because I can't
> make it happen at all. As far I I know, ou need to have an Owner-Drawn
> type of button.

Well, looks to be a trick of some sort... Check out this code:

--  code generated by Win32Lib IDE v0.18.14

 
include Win32Lib.ew
without warning

--------------------------------------------------------------------------------
--  Window Window1
constant Window1 = createEx( Window, "Window1", 0, Default, Default, 353, 237,
0, 0 )
constant PushButton2 = createEx( PushButton, "PushButton2", Window1, 120, 80,
88, 28, 0, 0 )
---------------------------------------------------------
--------------------------------------------------------------------------------
sequence colors
colors = { Red, Green, Blue, Yellow, Black }

atom color
color = 1

procedure PushButton2_onClick (integer self, integer event, sequence
params)--params is ()
color+=1
if color=6 then
	color=1
end if	
	setWindowBackColor(self,colors[color])
	clearWindow(self)
end procedure
setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick"))


WinMain( Window1,Normal )

-- end

I'm now just trying to use a bmp and mousetrap...

-=ck
"Programming in a state of EUPHORIA."

new topic     » goto parent     » topic index » view message » categorize

6. Re: Win32Lib: Button Color

Derek Parnell wrote:
> 
> cklester wrote:
> > 
> > Is there a way to set a button color and have it stay that way?
> > 
> > I'm using setBackColor(myButt, Red )
> > 
> 
> BTW, why do you want to change your butt to red? blink

It's not that I "want" to... just that I've been naughty.

That's a joke, people!

Sickos.

-=ck
"Programming in a state of EUPHORIA."

new topic     » goto parent     » topic index » view message » categorize

7. Re: Win32Lib: Button Color

irv mullins wrote:
> 
> Derek Parnell wrote:
> > cklester wrote:
> > > Is there a way to set a button color and have it stay that way?
> > > I'm using setBackColor(myButt, Red )
> > BTW, why do you want to change your butt to red? blink
> That's easily done, but I, for one, prefer not to have a hand 
> in the process :)

There'll be no end to the butt jokes.

-=ck
"Programming in a state of EUPHORIA."

new topic     » goto parent     » topic index » view message » categorize

8. Re: Win32Lib: Button Color

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
So what was the verdict on this? I would like to be able to do just
this.<br>
<br>
george<br>
<br>
Derek Parnell wrote:
<blockquote cite="mid359622274-1463792382-1089589004 at boing.topica.com"
 type="cite">


cklester wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Is there a way to set a button color and have it stay that way?

I'm using setBackColor(myButt, Red )

and it draws it red until I click on another control, and it
returns to its normal gray color.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I didn't know that one could change the color of a standard 
PushButton control!

Can you show me some example code that does that because I can't
make it happen at all. As far I I know, ou need to have an Owner-Drawn
type of button.

  </pre>
</blockquote>
</body>
</html>

new topic     » goto parent     » topic index » view message » categorize

9. Re: Win32Lib: Button Color

> So what was the verdict on this? I would like to be able to do just
> this.

The short of it?  It can be done, but there is no easy
simple way to code it.  Its not just a simple setting like
most things.  You'll have to make it owner drawn and
completely handle the graphics side yourself...


Don Phillips - aka Graebel
     National Instruments
     mailto: eunexus @ yahoo.com

new topic     » goto parent     » topic index » view message » categorize

10. Re: Win32Lib: Button Color

unknown wrote:
> 
> So what was the verdict on this? I would like to be able to do just
> this.<br>
> <br>
> george<br>
> <br>
> Derek Parnell wrote:
> <blockquote cite="mid359622274-1463792382-1089589004 at boing.topica.com"
>  type="cite">
> 
> 
> cklester wrote:
>     <pre wrap="">Is there a way to set a button color and have it stay that
>     way?
> 
> I'm using setBackColor(myButt, Red )
> 
> and it draws it red until I click on another control, and it
> returns to its normal gray color.
>     </pre>
>   </blockquote>
>   <pre wrap=""><!---->
> I didn't know that one could change the color of a standard 
> PushButton control!
> 
> Can you show me some example code that does that because I can't
> make it happen at all. As far I I know, ou need to have an Owner-Drawn
> type of button.

This effect happens because the clearWindow call drawns a colored rectangle
over the button area, but as soon as Windows gets any event for the button
it redraws the button 'correctly'.
 
There are two main ways to get colored buttons.
(1) Define it as an owner-drawn button and handle the special messages
 (meaning: You do all the graphic work, but you're told when and what to
 do).

(2) Simulate a button with a simple child window. You still get to 
  do all the graphics, and you must handle all the keyboard and
  mouse events too.

In short, its not simple or easy (yet). Maybe in a future release or if
somebody (hint, hint) implements a new type of control.
-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

11. Re: Win32Lib: Button Color

Derek Parnell wrote:
> This effect happens because the clearWindow call drawns a colored rectangle
> over the button area, but as soon as Windows gets any event for the button
> it redraws the button 'correctly'.
>  
> There are two main ways to get colored buttons.
> (1) Define it as an owner-drawn button and handle the special messages
>  (meaning: You do all the graphic work, but you're told when and what to
>  do).
> 
> (2) Simulate a button with a simple child window. You still get to 
>   do all the graphics, and you must handle all the keyboard and
>   mouse events too.

How about using the on paint event?

Below lies the signature of Lewis Townsend
Lewy T

new topic     » goto parent     » topic index » view message » categorize

12. Re: Win32Lib: Button Color

Lewis Townsend wrote:
> 
> Derek Parnell wrote:
> > This effect happens because the clearWindow call drawns a colored rectangle
> > over the button area, but as soon as Windows gets any event for the button
> > it redraws the button 'correctly'.
> >  
> > There are two main ways to get colored buttons.
> > (1) Define it as an owner-drawn button and handle the special messages
> >  (meaning: You do all the graphic work, but you're told when and what to
> >  do).
> > 
> > (2) Simulate a button with a simple child window. You still get to 
> >   do all the graphics, and you must handle all the keyboard and
> >   mouse events too.
> 
> How about using the on paint event?

I tried. Windows redraws the button while its depressed. Your app only gets
paint events when it is not depressed. Its all quite depressing really.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

13. Re: Win32Lib: Button Color

> > > This effect happens because the clearWindow call drawns a colored
> > > rectangle
> > > over the button area, but as soon as Windows gets any event for the button
> > > it redraws the button 'correctly'.
> > >  
> > > There are two main ways to get colored buttons.
> > > (1) Define it as an owner-drawn button and handle the special messages
> > >  (meaning: You do all the graphic work, but you're told when and what to
> > >  do).
> > > 
> > > (2) Simulate a button with a simple child window. You still get to 
> > >   do all the graphics, and you must handle all the keyboard and
> > >   mouse events too.
> > 
> > How about using the on paint event?
> 
> I tried. Windows redraws the button while its depressed. Your app only gets
> paint events when it is not depressed. Its all quite depressing really.

Nods, it wont work unless the control is completely owner-drawn.  If
alot of people would be interested in colored buttons, I could always
create some easy to use versions in xControls... its what its for after
all =)  It might take me awile to code them up, but send me email to
EuNexus at yahoo.com if this is something you would like to have added.


Don Phillips - aka Graebel
     National Instruments
     mailto: eunexus @ yahoo.com

new topic     » goto parent     » topic index » view message » categorize

14. Re: Win32Lib: Button Color

Don wrote:
> Nods, it wont work unless the control is completely owner-drawn.  If
> alot of people would be interested in colored buttons, I could always
> create some easy to use versions in xControls... its what its for after
> all =)  It might take me awile to code them up, but send me email to
> EuNexus at yahoo.com if this is something you would like to have added.

Or it can be built as a EuControl. It would certainly be a good idea if someone
created a powerful Button-control (xButton or EuButton). Possible features of
this button-control:
- different visual styles (flat, 3D, with/without border, ...)
- customizable colors (background-color, text-color, border-color, ...) and
fonts
- image AND text at the same time (text next to or under image)
- checkable button (button can be checked/unchecked)
- autoclick-feature (if autoclick is enabled, holding down the mousebutton on
the button will keep sending click-events)
- ...

Please post more features you would like to see for this advanced
button-control.

--
tommy online: http://users.pandora.be/tommycarlier
Euphoria Message Board: http://uboard.proboards32.com

new topic     » goto parent     » topic index » view message » categorize

15. Re: Win32Lib: Button Color

Tommy Carlier wrote:
> 
> Don wrote:
> > Nods, it wont work unless the control is completely owner-drawn.  If
> > alot of people would be interested in colored buttons, I could always
> > create some easy to use versions in xControls... its what its for after
> > all =)  It might take me awile to code them up, but send me email to
> > EuNexus at yahoo.com if this is something you would like to have added.
> 
> Or it can be built as a EuControl. It would certainly be a good idea if
> someone created
> a powerful Button-control (xButton or EuButton). Possible features of this
> button-control:
> - different visual styles (flat, 3D, with/without border, ...)
> - customizable colors (background-color, text-color, border-color, ...) and
> fonts
> - image AND text at the same time (text next to or under image)
> - checkable button (button can be checked/unchecked)
> - autoclick-feature (if autoclick is enabled, holding down the mousebutton on
> the button
> will keep sending click-events)
> - ...
> 
> Please post more features you would like to see for this advanced
> button-control.

That's all good stuff. I think Derek's idea about using a
child window is simple enough. There's also a win32lib demo
showing a "color button" that pops up a color selector dialog box.
It uses an XPM and is cleverly done. Check it out! :)

-=ck
"Programming in a state of EUPHORIA."

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu