Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

changing Control colours

Posted on 2000-04-05
14
Medium Priority
?
220 Views
Last Modified: 2010-05-02
Hi,

This question has 2 parts :-

(1)I'm writing a GUI where I set the BackColor property of a text-box to yellow when it gets focus & back to white again when it loses it. This works fine except for when you start typing text in the box which comes out black with a grey back-ground around the text - it's the grey background I'm trying to get rid of; any ideas please?

(2)Similarly, when a check-box or radio-button gets focus, I would like to set only the little square box where the tick goes to be yellow when it gains focus, but setting the BackColor property in this case colours every part of the control EXCEPT the little square box. Any ideas for this too?

Many thanks.
0
Comment
Question by:gizz
  • 5
  • 4
  • 4
  • +1
14 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2686812
What version of VB are you using?
0
 

Author Comment

by:gizz
ID: 2686814
VB6
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2686929
I do not see the same effect of the gray background surrounding the text:

Private Sub Text1_GotFocus()
    Text1.BackColor = vbInfoBackground
End Sub

Private Sub Text1_LostFocus()
    Text1.BackColor = vbWhite
End Sub

What color mode is your system set to?
8 bit, 16 bit, 24 bit, etc.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 32

Expert Comment

by:Erick37
ID: 2687070
Unfortunately, the checkbox uses bitmaps to display the little checks, so it is not possible to change the color.  You would have to either make your own control or find a third party control which supports this.
0
 

Author Comment

by:gizz
ID: 2687071
Adjusted points from 100 to 200
0
 

Author Comment

by:gizz
ID: 2687072
Sorry, I don't know how to check my color mode & second when I used vbInfoBackground this gives an annoying white background effect around the text. But really I need to use true yellow as vbInfoBackground does not stand out enough. By the way I increased the points to 200. Thanks.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2687086
Control Panel->Display->Settings
0
 

Author Comment

by:gizz
ID: 2687137
Thanks Eric37 for info about check-boxes. As for monitor color mode, I'm still not sure about this - I'm using 256 colors, small fonts, 1024/768 pixels, 75 hertz refresh frequency - hope that helps. Cheers.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2687147
256 colors

Ok... is your yellow background colour a dithered colour?
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 800 total points
ID: 2687168
OK....

What happens if you set your text box bacground colour to &H0000FFFF&

Text1.BackColor = &HFFFF&

I tried 256 colours and I get the same effect for dithered colours. Solid colours, like the one above work fine.

So - use solid colours if you must have 256 colours.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2687222
have you tried using a boolean variable to set the background and maintain it with the key down event??

Dim color As Boolean


Private Sub Text1_GotFocus()
    color = True
    Text1.BackColor = vbYellow
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    If color = True Then
        Text1.BackColor = vbYellow
    Else
        Text1.BackColor = vbWhite
    End If
End Sub

Private Sub Text1_LostFocus()
    color = False
    Text1.BackColor = vbWhite
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2687629
Change from 256 colors, to HiColor (16 bit) and see if the problem goes away.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2687828
Also confirm you are using the standard TextBox, not the windowless Textbox.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2689044
Thanks gizz! Very generous!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question