Solved

changing Control colours

Posted on 2000-04-05
14
212 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…

773 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