Solved

changing Control colours

Posted on 2000-04-05
14
209 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now