Unwanted Dithering in option button 
Author Message
 Unwanted Dithering in option button

Quote:
> Attached is a small jpg file that has a cutout of
> two OptionButtons on my form...  I have not been
> able to identify a way to prevent the dithering effect
> that causes the color to go from a solid to ... well,
> the picture shows it best...  Its like they evenly space
> white and red dots instead of permitting a 'truer'
> color as the background color when the item is being
> shown as the selected item...  What can I do, short
> of replacing the option button with an image or picture
> box?

What bit depth are you running at?  It may simply be the case that the
display can't handle the 'truer' colour as you put it.  To make sure the
colour will display properly your system should be set to 24 or 32-bit
colour however 15 and 16 bit colour will also suffice with a slight tonal
difference.  Also if you're running at a lower bit depth then you can ask
windows to include your colour as part of the application's palette, I think
if you just set an image containing the colours you want to display as the
.Palette property of the form then this will do it for you.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: http://www.*-*-*.com/




Mon, 28 Feb 2005 06:27:38 GMT  
 Unwanted Dithering in option button

Quote:
> difference.  Also if you're running at a lower bit depth then you can ask
> windows to include your colour as part of the application's palette, I
think
> if you just set an image containing the colours you want to display as the
> .Palette property of the form then this will do it for you.

I'm running 16 bit depth.  I have tried it at every resolution and depth...
My target resolution is goint to be 800x600, in which it looks foul.
It looks ok at 1600*1200 but thats just because the dots are so small
you don't discern them...  I'll try the Palette trick.

Thanks,

D.



Mon, 28 Feb 2005 05:48:19 GMT  
 Unwanted Dithering in option button

Quote:
> I'm running 16 bit depth.  I have tried it at every resolution and
depth...
> My target resolution is goint to be 800x600, in which it looks foul.
> It looks ok at 1600*1200 but thats just because the dots are so small
> you don't discern them...  I'll try the Palette trick.

I've had a look at it here and it is indeed doing the same thing so it looks
like it's just a 'feature' of the control.  If this is the case then you
have a few ways around it;  The first is to subclass the control and do the
painting yourself.  The second is to write the control from scratch which
may not be as bad as it may sound and give you far more flexibility.  The
third is to look into the command button window messages, there's most
likely a message to set the down state and similarly the up state so some
playing about there could help, again thought I'd subclass the control to
make sure you don't get odd redraws that look out of place.
Of course the fourth option is just to live with it, it's really up to you
how detrimental it is to your application.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Mon, 28 Feb 2005 10:18:23 GMT  
 Unwanted Dithering in option button
I've been all over it today...  I decided to take the route of deisgning
my own control from scratch to mimic the behavior of the option button
as far as I needed it to...  That part worked just fine...  Using
DrawEdge and my own color constants, along with a few events and props
I have successfully mimiced an OptionButton...  The usercontrol at design
time contained no controls, no colors...etc.  At run time it looks exactly
like an OptionButton(but better because the true colors are not messed
with).

The problem now is that I'm stuck with VB5, the only licensed VB product
we have at work, and under VB 5 the Usercontrol does not play nice with
the Control object type...

I have a Collection object which I add controls to at runtime.  Any control
in this collection gets special things done to it, like: a drop shadow is
drawn, I also use the colleciton to know that I am validating information
contained inside the controls...

A little more background.  I draw all the forms from a single 'master'
form which contains one of each type of control at design time that I
may need to duplicate at runtime.  The net effect is a lean EXE, 198k
for (so far) 15 forms of functionality.

on to the problem...

I add TextBoxes, Comboboxes, listboxes, optionbuttons, and checkboxes
to the custom Collection.  Now, having added the new custom control to
the collection, I get a type mismatch when this sort of code is run:

Dim xControl as control
for each xControl in ControlsColleciton
    if not(typeof xControl is Label) then 'Type Mismatch on UserControl
        if xControl.tag = "True" then
           'Do Something...
        endif
    endif
next

So, I removed the usercontrol from the picture...

I wound out the day with a net -0- improvement...  I'm not sure what I can
do
in VB5 to get what I want out of it...  I' have a subclasser built and ready
to go, but was hoping not to have to go that far...  If I do, I suppose I'll
have to subclass the WM_PAINT message for the .hWnd of the usercontrol????
Then
do my own Drawing, depending on if the value is vbUnChecked, and if so,
DrawEdge
on the Rect of the OptionButton, then Paint my own color inside, and
finally,
place the text (Caption) in last???

Does that sound right?

For those who don't know what I'm after, I want the down state of the Option
Button to show in a reasonable (non-dithered) color...  Any color other than
gray seems to present a really ugly white/[color] patterned background, and
it makes the text (caption) barely readable.

D?



Quote:
> > I'm running 16 bit depth.  I have tried it at every resolution and
> depth...
> > My target resolution is goint to be 800x600, in which it looks foul.
> > It looks ok at 1600*1200 but thats just because the dots are so small
> > you don't discern them...  I'll try the Palette trick.

> I've had a look at it here and it is indeed doing the same thing so it
looks
> like it's just a 'feature' of the control.  If this is the case then you
> have a few ways around it;  The first is to subclass the control and do
the
> painting yourself.  The second is to write the control from scratch which
> may not be as bad as it may sound and give you far more flexibility.  The
> third is to look into the command button window messages, there's most
> likely a message to set the down state and similarly the up state so some
> playing about there could help, again thought I'd subclass the control to
> make sure you don't get odd redraws that look out of place.
> Of course the fourth option is just to live with it, it's really up to you
> how detrimental it is to your application.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/





Mon, 28 Feb 2005 14:39:22 GMT  
 Unwanted Dithering in option button
Hi,

What you are seeing is normal operation of the "Graphical" Style of the
Option and CheckBox Contols.
They dither the default Down Picture (Caption) most likely to provide extra
feedback of its state.

This dithering is *very* easy to get around by providing your own
DownPicture and Picture bitmaps.

If you are using only caption text, you could use an intermediary hidden
PictureBox to draw the required Caption on, then assign that to the
Option/CheckBox.

David
lilchips.com


Quote:
> I've been all over it today...  I decided to take the route of deisgning
> my own control from scratch to mimic the behavior of the option button
> as far as I needed it to...  That part worked just fine...  Using
> DrawEdge and my own color constants, along with a few events and props
> I have successfully mimiced an OptionButton...  The usercontrol at design
> time contained no controls, no colors...etc.  At run time it looks exactly
> like an OptionButton(but better because the true colors are not messed
> with).

> The problem now is that I'm stuck with VB5, the only licensed VB product
> we have at work, and under VB 5 the Usercontrol does not play nice with
> the Control object type...

> I have a Collection object which I add controls to at runtime.  Any
control
> in this collection gets special things done to it, like: a drop shadow is
> drawn, I also use the colleciton to know that I am validating information
> contained inside the controls...

> A little more background.  I draw all the forms from a single 'master'
> form which contains one of each type of control at design time that I
> may need to duplicate at runtime.  The net effect is a lean EXE, 198k
> for (so far) 15 forms of functionality.

> on to the problem...

> I add TextBoxes, Comboboxes, listboxes, optionbuttons, and checkboxes
> to the custom Collection.  Now, having added the new custom control to
> the collection, I get a type mismatch when this sort of code is run:

> Dim xControl as control
> for each xControl in ControlsColleciton
>     if not(typeof xControl is Label) then 'Type Mismatch on UserControl
>         if xControl.tag = "True" then
>            'Do Something...
>         endif
>     endif
> next

> So, I removed the usercontrol from the picture...

> I wound out the day with a net -0- improvement...  I'm not sure what I can
> do
> in VB5 to get what I want out of it...  I' have a subclasser built and
ready
> to go, but was hoping not to have to go that far...  If I do, I suppose
I'll
> have to subclass the WM_PAINT message for the .hWnd of the usercontrol????
> Then
> do my own Drawing, depending on if the value is vbUnChecked, and if so,
> DrawEdge
> on the Rect of the OptionButton, then Paint my own color inside, and
> finally,
> place the text (Caption) in last???

> Does that sound right?

> For those who don't know what I'm after, I want the down state of the
Option
> Button to show in a reasonable (non-dithered) color...  Any color other
than
> gray seems to present a really ugly white/[color] patterned background,
and
> it makes the text (caption) barely readable.

> D?



> > > I'm running 16 bit depth.  I have tried it at every resolution and
> > depth...
> > > My target resolution is goint to be 800x600, in which it looks foul.
> > > It looks ok at 1600*1200 but thats just because the dots are so small
> > > you don't discern them...  I'll try the Palette trick.

> > I've had a look at it here and it is indeed doing the same thing so it
> looks
> > like it's just a 'feature' of the control.  If this is the case then you
> > have a few ways around it;  The first is to subclass the control and do
> the
> > painting yourself.  The second is to write the control from scratch
which
> > may not be as bad as it may sound and give you far more flexibility.
The
> > third is to look into the command button window messages, there's most
> > likely a message to set the down state and similarly the up state so
some
> > playing about there could help, again thought I'd subclass the control
to
> > make sure you don't get odd redraws that look out of place.
> > Of course the fourth option is just to live with it, it's really up to
you
> > how detrimental it is to your application.
> > Hope this helps,

> >     Mike

> >  -- EDais --

> >  - Microsoft Visual Basic MVP -
> > WWW: Http://EDais.earlsoft.co.uk/





Mon, 28 Feb 2005 22:55:50 GMT  
 Unwanted Dithering in option button
What interface are you using when you add the usercontrol to the
collection?  The following works just fine in VB5....

  Dim oCol As Collection
  Set oCol = New Collection

  ' add some controls to the collection...
  oCol.Add Command1
  oCol.Add Option1
  oCol.Add UserControl1

  Dim xControl As Control

  ' enumerate the collection....
  For Each xControl In oCol
    If Not (TypeOf xControl Is Label) Then
      Debug.Print TypeName(xControl)
    End If
  Next

  ' test the controls collection also....
  For Each xControl In Controls
    If Not (TypeOf xControl Is Label) Then
      Debug.Print TypeName(xControl)
    End If
  Next

BTW, as another option for drawing option buttons, you can use the
Marlett font.  Have a look at the Option Button demo at
http://www.mvps.org/vbvision/  for an example.

HTH,
Bryan
____________________________________________________________
New Vision Software            "When the going gets weird,"
Bryan Stafford                   "the weird turn pro."

Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



Quote:
>I've been all over it today...  I decided to take the route of deisgning
>my own control from scratch to mimic the behavior of the option button
>as far as I needed it to...  That part worked just fine...  Using
>DrawEdge and my own color constants, along with a few events and props
>I have successfully mimiced an OptionButton...  The usercontrol at design
>time contained no controls, no colors...etc.  At run time it looks exactly
>like an OptionButton(but better because the true colors are not messed
>with).

>The problem now is that I'm stuck with VB5, the only licensed VB product
>we have at work, and under VB 5 the Usercontrol does not play nice with
>the Control object type...

>I have a Collection object which I add controls to at runtime.  Any control
>in this collection gets special things done to it, like: a drop shadow is
>drawn, I also use the colleciton to know that I am validating information
>contained inside the controls...

>A little more background.  I draw all the forms from a single 'master'
>form which contains one of each type of control at design time that I
>may need to duplicate at runtime.  The net effect is a lean EXE, 198k
>for (so far) 15 forms of functionality.

>on to the problem...

>I add TextBoxes, Comboboxes, listboxes, optionbuttons, and checkboxes
>to the custom Collection.  Now, having added the new custom control to
>the collection, I get a type mismatch when this sort of code is run:

>Dim xControl as control
>for each xControl in ControlsColleciton
>    if not(typeof xControl is Label) then 'Type Mismatch on UserControl
>        if xControl.tag = "True" then
>           'Do Something...
>        endif
>    endif
>next

>So, I removed the usercontrol from the picture...

>I wound out the day with a net -0- improvement...  I'm not sure what I can
>do
>in VB5 to get what I want out of it...  I' have a subclasser built and ready
>to go, but was hoping not to have to go that far...  If I do, I suppose I'll
>have to subclass the WM_PAINT message for the .hWnd of the usercontrol????
>Then
>do my own Drawing, depending on if the value is vbUnChecked, and if so,
>DrawEdge
>on the Rect of the OptionButton, then Paint my own color inside, and
>finally,
>place the text (Caption) in last???

>Does that sound right?

>For those who don't know what I'm after, I want the down state of the Option
>Button to show in a reasonable (non-dithered) color...  Any color other than
>gray seems to present a really ugly white/[color] patterned background, and
>it makes the text (caption) barely readable.

>D?



>> > I'm running 16 bit depth.  I have tried it at every resolution and
>> depth...
>> > My target resolution is goint to be 800x600, in which it looks foul.
>> > It looks ok at 1600*1200 but thats just because the dots are so small
>> > you don't discern them...  I'll try the Palette trick.

>> I've had a look at it here and it is indeed doing the same thing so it
>looks
>> like it's just a 'feature' of the control.  If this is the case then you
>> have a few ways around it;  The first is to subclass the control and do
>the
>> painting yourself.  The second is to write the control from scratch which
>> may not be as bad as it may sound and give you far more flexibility.  The
>> third is to look into the command button window messages, there's most
>> likely a message to set the down state and similarly the up state so some
>> playing about there could help, again thought I'd subclass the control to
>> make sure you don't get odd redraws that look out of place.
>> Of course the fourth option is just to live with it, it's really up to you
>> how detrimental it is to your application.
>> Hope this helps,

>>     Mike

>>  -- EDais --

>>  - Microsoft Visual Basic MVP -
>> WWW: Http://EDais.earlsoft.co.uk/





Mon, 28 Feb 2005 23:15:39 GMT  
 Unwanted Dithering in option button
I'm gonna shake this tree today and see what falls out.

Thanks,

D.


Quote:
> Hi,

> What you are seeing is normal operation of the "Graphical" Style of the
> Option and CheckBox Contols.
> They dither the default Down Picture (Caption) most likely to provide
extra
> feedback of its state.

> This dithering is *very* easy to get around by providing your own
> DownPicture and Picture bitmaps.

> If you are using only caption text, you could use an intermediary hidden
> PictureBox to draw the required Caption on, then assign that to the
> Option/CheckBox.

> David
> lilchips.com



> > I've been all over it today...  I decided to take the route of deisgning
> > my own control from scratch to mimic the behavior of the option button
> > as far as I needed it to...  That part worked just fine...  Using
> > DrawEdge and my own color constants, along with a few events and props
> > I have successfully mimiced an OptionButton...  The usercontrol at
design
> > time contained no controls, no colors...etc.  At run time it looks
exactly
> > like an OptionButton(but better because the true colors are not messed
> > with).

> > The problem now is that I'm stuck with VB5, the only licensed VB product
> > we have at work, and under VB 5 the Usercontrol does not play nice with
> > the Control object type...

> > I have a Collection object which I add controls to at runtime.  Any
> control
> > in this collection gets special things done to it, like: a drop shadow
is
> > drawn, I also use the colleciton to know that I am validating
information
> > contained inside the controls...

> > A little more background.  I draw all the forms from a single 'master'
> > form which contains one of each type of control at design time that I
> > may need to duplicate at runtime.  The net effect is a lean EXE, 198k
> > for (so far) 15 forms of functionality.

> > on to the problem...

> > I add TextBoxes, Comboboxes, listboxes, optionbuttons, and checkboxes
> > to the custom Collection.  Now, having added the new custom control to
> > the collection, I get a type mismatch when this sort of code is run:

> > Dim xControl as control
> > for each xControl in ControlsColleciton
> >     if not(typeof xControl is Label) then 'Type Mismatch on UserControl
> >         if xControl.tag = "True" then
> >            'Do Something...
> >         endif
> >     endif
> > next

> > So, I removed the usercontrol from the picture...

> > I wound out the day with a net -0- improvement...  I'm not sure what I
can
> > do
> > in VB5 to get what I want out of it...  I' have a subclasser built and
> ready
> > to go, but was hoping not to have to go that far...  If I do, I suppose
> I'll
> > have to subclass the WM_PAINT message for the .hWnd of the
usercontrol????
> > Then
> > do my own Drawing, depending on if the value is vbUnChecked, and if so,
> > DrawEdge
> > on the Rect of the OptionButton, then Paint my own color inside, and
> > finally,
> > place the text (Caption) in last???

> > Does that sound right?

> > For those who don't know what I'm after, I want the down state of the
> Option
> > Button to show in a reasonable (non-dithered) color...  Any color other
> than
> > gray seems to present a really ugly white/[color] patterned background,
> and
> > it makes the text (caption) barely readable.

> > D?



> > > > I'm running 16 bit depth.  I have tried it at every resolution and
> > > depth...
> > > > My target resolution is goint to be 800x600, in which it looks foul.
> > > > It looks ok at 1600*1200 but thats just because the dots are so
small
> > > > you don't discern them...  I'll try the Palette trick.

> > > I've had a look at it here and it is indeed doing the same thing so it
> > looks
> > > like it's just a 'feature' of the control.  If this is the case then
you
> > > have a few ways around it;  The first is to subclass the control and
do
> > the
> > > painting yourself.  The second is to write the control from scratch
> which
> > > may not be as bad as it may sound and give you far more flexibility.
> The
> > > third is to look into the command button window messages, there's most
> > > likely a message to set the down state and similarly the up state so
> some
> > > playing about there could help, again thought I'd subclass the control
> to
> > > make sure you don't get odd redraws that look out of place.
> > > Of course the fourth option is just to live with it, it's really up to
> you
> > > how detrimental it is to your application.
> > > Hope this helps,

> > >     Mike

> > >  -- EDais --

> > >  - Microsoft Visual Basic MVP -
> > > WWW: Http://EDais.earlsoft.co.uk/





Tue, 01 Mar 2005 00:41:01 GMT  
 Unwanted Dithering in option button
ok,

so on formload, I tell it to Load an array of PicBoxes...
    1 to (2*(NumOfCheckBoxes))-1
meaning, if there are three check boxes, I load PicBox(1) to (5)
[already having index (0) in the form at design time.]

I pass that to my Fn that draws the images, and assign a Picture
and a DownPicture to each OptButton, building the picture with
the appropriate light or dark color, using the caption from the OptBtn.
Then I set the Caption to "", and loop through the rest...

It's an amazing waste of memory to load all those PB's but I can't
find a way around it...  If I unload them I think the images will be invalid
when the option button wants to use them, ... is that right?

I would have thought that the option button would store it with
its own DC, not share the one from the picture box.

D?


Quote:
> I'm gonna shake this tree today and see what falls out.

> Thanks,

> D.



> > Hi,

> > What you are seeing is normal operation of the "Graphical" Style of the
> > Option and CheckBox Contols.
> > They dither the default Down Picture (Caption) most likely to provide
> extra
> > feedback of its state.

> > This dithering is *very* easy to get around by providing your own
> > DownPicture and Picture bitmaps.

> > If you are using only caption text, you could use an intermediary hidden
> > PictureBox to draw the required Caption on, then assign that to the
> > Option/CheckBox.

> > David
> > lilchips.com



> > > I've been all over it today...  I decided to take the route of
deisgning
> > > my own control from scratch to mimic the behavior of the option button
> > > as far as I needed it to...  That part worked just fine...  Using
> > > DrawEdge and my own color constants, along with a few events and props
> > > I have successfully mimiced an OptionButton...  The usercontrol at
> design
> > > time contained no controls, no colors...etc.  At run time it looks
> exactly
> > > like an OptionButton(but better because the true colors are not messed
> > > with).

> > > The problem now is that I'm stuck with VB5, the only licensed VB
product
> > > we have at work, and under VB 5 the Usercontrol does not play nice
with
> > > the Control object type...

> > > I have a Collection object which I add controls to at runtime.  Any
> > control
> > > in this collection gets special things done to it, like: a drop shadow
> is
> > > drawn, I also use the colleciton to know that I am validating
> information
> > > contained inside the controls...

> > > A little more background.  I draw all the forms from a single 'master'
> > > form which contains one of each type of control at design time that I
> > > may need to duplicate at runtime.  The net effect is a lean EXE, 198k
> > > for (so far) 15 forms of functionality.

> > > on to the problem...

> > > I add TextBoxes, Comboboxes, listboxes, optionbuttons, and checkboxes
> > > to the custom Collection.  Now, having added the new custom control to
> > > the collection, I get a type mismatch when this sort of code is run:

> > > Dim xControl as control
> > > for each xControl in ControlsColleciton
> > >     if not(typeof xControl is Label) then 'Type Mismatch on
UserControl
> > >         if xControl.tag = "True" then
> > >            'Do Something...
> > >         endif
> > >     endif
> > > next

> > > So, I removed the usercontrol from the picture...

> > > I wound out the day with a net -0- improvement...  I'm not sure what I
> can
> > > do
> > > in VB5 to get what I want out of it...  I' have a subclasser built and
> > ready
> > > to go, but was hoping not to have to go that far...  If I do, I
suppose
> > I'll
> > > have to subclass the WM_PAINT message for the .hWnd of the
> usercontrol????
> > > Then
> > > do my own Drawing, depending on if the value is vbUnChecked, and if
so,
> > > DrawEdge
> > > on the Rect of the OptionButton, then Paint my own color inside, and
> > > finally,
> > > place the text (Caption) in last???

> > > Does that sound right?

> > > For those who don't know what I'm after, I want the down state of the
> > Option
> > > Button to show in a reasonable (non-dithered) color...  Any color
other
> > than
> > > gray seems to present a really ugly white/[color] patterned
background,
> > and
> > > it makes the text (caption) barely readable.

> > > D?



> > > > > I'm running 16 bit depth.  I have tried it at every resolution and
> > > > depth...
> > > > > My target resolution is goint to be 800x600, in which it looks
foul.
> > > > > It looks ok at 1600*1200 but thats just because the dots are so
> small
> > > > > you don't discern them...  I'll try the Palette trick.

> > > > I've had a look at it here and it is indeed doing the same thing so
it
> > > looks
> > > > like it's just a 'feature' of the control.  If this is the case then
> you
> > > > have a few ways around it;  The first is to subclass the control and
> do
> > > the
> > > > painting yourself.  The second is to write the control from scratch
> > which
> > > > may not be as bad as it may sound and give you far more flexibility.
> > The
> > > > third is to look into the command button window messages, there's
most
> > > > likely a message to set the down state and similarly the up state so
> > some
> > > > playing about there could help, again thought I'd subclass the
control
> > to
> > > > make sure you don't get odd redraws that look out of place.
> > > > Of course the fourth option is just to live with it, it's really up
to
> > you
> > > > how detrimental it is to your application.
> > > > Hope this helps,

> > > >     Mike

> > > >  -- EDais --

> > > >  - Microsoft Visual Basic MVP -
> > > > WWW: Http://EDais.earlsoft.co.uk/





Tue, 01 Mar 2005 07:15:50 GMT  
 Unwanted Dithering in option button

Quote:
> so on formload, I tell it to Load an array of PicBoxes...
>     1 to (2*(NumOfCheckBoxes))-1
> meaning, if there are three check boxes, I load PicBox(1) to (5)
> [already having index (0) in the form at design time.]

> I pass that to my Fn that draws the images, and assign a Picture
> and a DownPicture to each OptButton, building the picture with
> the appropriate light or dark color, using the caption from the OptBtn.
> Then I set the Caption to "", and loop through the rest...

> It's an amazing waste of memory to load all those PB's but I can't
> find a way around it...  If I unload them I think the images will be
invalid
> when the option button wants to use them, ... is that right?

> I would have thought that the option button would store it with
> its own DC, not share the one from the picture box.

The DC takes little memory to store, it's the DDB selected into it that's
the killer, but yes it does retain it's own DC and that's what you'd draw to
if you were sub-classing the control.  You can get the DC of the control by
called GetDC() on it's .hWnd property but remember to pair it up with a call
to ReleaseDC() when you're done to keep Windows happy.
And yes, this picture box method is a _very_ messy and memory dependant way
of accomplishing a simple task.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/




Tue, 01 Mar 2005 07:32:35 GMT  
 Unwanted Dithering in option button
Hi,

You only require one PictureBox, that's all.  It is not shared.  It's
basically your "canvas".
It is only used on Form_Load to create the DownPicture and Picture bitmaps
for the Option/Check Controls.
Once you have copied a bitmap over to an Option/CheckBox, you can Cls the
PictureBox Control and draw the next caption/bitmap.
The PictureBox only serves as a method of creating a bitmap allowing you to
customize the current Font and Color as opposed to creating "hard-coded"
pre-drawn bitmaps.
In other words, you could create pre-drawn bitmaps for the DownPicture and
Picture, but they would not follow the any Scheme changes (color or font).

Basically you would:

- Add a PictureBox and set its properties at design time:

  Picture1.AutoRedraw = True
  Picture1.Visible = False

- In your Form_Load or initialize:

  Picture1.CurrentX = ((Picture1.ScaleWidth - Picture1.TextWidth("Button1"))
\ 2)
  Picture1.CurrentY = ((Picture1.ScaleHeight -
Picture1.TextHeight("Button1")) \ 2)
  Picture1.Print "Button1"

  Option1.DownPicture = Picture1.Image
  Option1.Picture = Picture1.Image

  Picture1.Cls
  ...

David
lilchips.com


Quote:
> ok,

> so on formload, I tell it to Load an array of PicBoxes...
>     1 to (2*(NumOfCheckBoxes))-1
> meaning, if there are three check boxes, I load PicBox(1) to (5)
> [already having index (0) in the form at design time.]

> I pass that to my Fn that draws the images, and assign a Picture
> and a DownPicture to each OptButton, building the picture with
> the appropriate light or dark color, using the caption from the OptBtn.
> Then I set the Caption to "", and loop through the rest...

> It's an amazing waste of memory to load all those PB's but I can't
> find a way around it...  If I unload them I think the images will be
invalid
> when the option button wants to use them, ... is that right?

> I would have thought that the option button would store it with
> its own DC, not share the one from the picture box.

> D?



> > I'm gonna shake this tree today and see what falls out.

> > Thanks,

> > D.



> > > Hi,

> > > What you are seeing is normal operation of the "Graphical" Style of
the
> > > Option and CheckBox Contols.
> > > They dither the default Down Picture (Caption) most likely to provide
> > extra
> > > feedback of its state.

> > > This dithering is *very* easy to get around by providing your own
> > > DownPicture and Picture bitmaps.

> > > If you are using only caption text, you could use an intermediary
hidden
> > > PictureBox to draw the required Caption on, then assign that to the
> > > Option/CheckBox.

> > > David
> > > lilchips.com



> > > > I've been all over it today...  I decided to take the route of
> deisgning
> > > > my own control from scratch to mimic the behavior of the option
button
> > > > as far as I needed it to...  That part worked just fine...  Using
> > > > DrawEdge and my own color constants, along with a few events and
props
> > > > I have successfully mimiced an OptionButton...  The usercontrol at
> > design
> > > > time contained no controls, no colors...etc.  At run time it looks
> > exactly
> > > > like an OptionButton(but better because the true colors are not
messed
> > > > with).

> > > > The problem now is that I'm stuck with VB5, the only licensed VB
> product
> > > > we have at work, and under VB 5 the Usercontrol does not play nice
> with
> > > > the Control object type...

> > > > I have a Collection object which I add controls to at runtime.  Any
> > > control
> > > > in this collection gets special things done to it, like: a drop
shadow
> > is
> > > > drawn, I also use the colleciton to know that I am validating
> > information
> > > > contained inside the controls...

> > > > A little more background.  I draw all the forms from a single
'master'
> > > > form which contains one of each type of control at design time that
I
> > > > may need to duplicate at runtime.  The net effect is a lean EXE,
198k
> > > > for (so far) 15 forms of functionality.

> > > > on to the problem...

> > > > I add TextBoxes, Comboboxes, listboxes, optionbuttons, and
checkboxes
> > > > to the custom Collection.  Now, having added the new custom control
to
> > > > the collection, I get a type mismatch when this sort of code is run:

> > > > Dim xControl as control
> > > > for each xControl in ControlsColleciton
> > > >     if not(typeof xControl is Label) then 'Type Mismatch on
> UserControl
> > > >         if xControl.tag = "True" then
> > > >            'Do Something...
> > > >         endif
> > > >     endif
> > > > next

> > > > So, I removed the usercontrol from the picture...

> > > > I wound out the day with a net -0- improvement...  I'm not sure what
I
> > can
> > > > do
> > > > in VB5 to get what I want out of it...  I' have a subclasser built
and
> > > ready
> > > > to go, but was hoping not to have to go that far...  If I do, I
> suppose
> > > I'll
> > > > have to subclass the WM_PAINT message for the .hWnd of the
> > usercontrol????
> > > > Then
> > > > do my own Drawing, depending on if the value is vbUnChecked, and if
> so,
> > > > DrawEdge
> > > > on the Rect of the OptionButton, then Paint my own color inside, and
> > > > finally,
> > > > place the text (Caption) in last???

> > > > Does that sound right?

> > > > For those who don't know what I'm after, I want the down state of
the
> > > Option
> > > > Button to show in a reasonable (non-dithered) color...  Any color
> other
> > > than
> > > > gray seems to present a really ugly white/[color] patterned
> background,
> > > and
> > > > it makes the text (caption) barely readable.

> > > > D?



> > > > > > I'm running 16 bit depth.  I have tried it at every resolution
and
> > > > > depth...
> > > > > > My target resolution is goint to be 800x600, in which it looks
> foul.
> > > > > > It looks ok at 1600*1200 but thats just because the dots are so
> > small
> > > > > > you don't discern them...  I'll try the Palette trick.

> > > > > I've had a look at it here and it is indeed doing the same thing
so
> it
> > > > looks
> > > > > like it's just a 'feature' of the control.  If this is the case
then
> > you
> > > > > have a few ways around it;  The first is to subclass the control
and
> > do
> > > > the
> > > > > painting yourself.  The second is to write the control from
scratch
> > > which
> > > > > may not be as bad as it may sound and give you far more
flexibility.
> > > The
> > > > > third is to look into the command button window messages, there's
> most
> > > > > likely a message to set the down state and similarly the up state
so
> > > some
> > > > > playing about there could help, again thought I'd subclass the
> control
> > > to
> > > > > make sure you don't get odd redraws that look out of place.
> > > > > Of course the fourth option is just to live with it, it's really
up
> to
> > > you
> > > > > how detrimental it is to your application.
> > > > > Hope this helps,

> > > > >     Mike

> > > > >  -- EDais --

> > > > >  - Microsoft Visual Basic MVP -
> > > > > WWW: Http://EDais.earlsoft.co.uk/





Tue, 01 Mar 2005 08:24:10 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. How can I dither bitmaps on button control in VB4

2. Option group/option button

3. Option Group/Option Button

4. Option Button - 2 buttons selected at once.

5. Working with an Option Button Array and Checkbox Button Array

6. Option Button Syntax on a Form

7. comboBox/option button?

8. Option buttons /Groups - Any other ActiveX Controls

9. Option buttons - using vba to determine selection - Help

10. How hide menuitens like tools options or disable com-add ins button

11. GroupName Property for Option Buttons

12. option buttons on the user form

 

 
Powered by phpBB® Forum Software