Solved

changing Control colours

Posted on 2000-04-05
14
214 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
Industry Leaders: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
Looking for VB6 code to read SQL table export it to ascii 8 47
Add and format columns in vb6 7 70
Protecting vb6 & .Net code Obfuscation 18 182
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

763 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