Solved

changing Control colours

Posted on 2000-04-05
14
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 
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 200 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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