Solved

MaskEdit Colors

Posted on 1998-06-16
15
193 Views
Last Modified: 2010-05-03
When I disable a mask edit box its background color is much darker than a textbox background color when it is disabled.  Is there any way to change the disabled background color of a masked edit box?
0
Comment
Question by:paulca
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1463421
Probably the only way is to use SendMessage API to change those settings.

0
 

Author Comment

by:paulca
ID: 1463422
Can you give me code for that SendMessage API please?
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463423
What do you currently have your Masked Edit's Background color set to?
The background color shouldn't change depending on the enabled property.
Set the background color to &H80000005& (Window Background)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:clifABB
ID: 1463424
What do you currently have your Masked Edit's Background color set to?
The background color shouldn't change depending on the enabled property.
Set the background color to &H80000005& (Window Background)
Also, set the foreground color to &H80000008& (Window Text)

(You could also set the background to white and the foreground to black, but this isn't proper Windows etiquette.)

I submit this as a comment.  If it solves your problem, let me know and I'll resubmit it as an answer.
0
 

Author Comment

by:paulca
ID: 1463425
The problem is when the masked edit box is disabled.  I have both masked edit boxes and text boxes on my form.  When the text boxes are disabled the background color is white and the text is gray but when the masked edit box os disabled, the background color is gray and the text is another shade of gray. It looks out of place and the text is difficult to see when the masked edit box os disabled.  Is there any way to have the masked edit box background color white when it is DISABLED?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 40 total points
ID: 1463426
paula,
Try this work around:

In the form's declare area:
Dim Mdisabled as Boolean

When you want to disable the maskbox, do not set enabled  to false, instead, put this code:

MaskEdBox1.Text = "028485"
MDisAbled = True

In the maskbox's gotFocus event, add
If MDisAbled = True Then Text2.SetFocus
' text 2 can bu any other control receive focus after the editbox, which is not disabled.

When you want to enable the masked box, add:
MaskEdBox1.Text = vbBlack '(or the color of your choice)
MDisAbled = False

Regards
Dalin    
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463427
paulca:
Did you check you Background and Forground colors?  Make sure they are as I specified in my comment.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463428
paulca,
Sorry, I left a line of code:
When you want to disable the maskbox, change the ForeColor:

MaskEdBox1.ForeColor = &H80000011

You don't need:
MaskEdBox1.Text = "028485" (this was for me to test)

Regards
Dalin
0
 
LVL 4

Expert Comment

by:zsi
ID: 1463429
Is it me or does Dalin's answer make absolutely no sense what-so-ever?
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463430
Both, sir!

I observed the same thing. When you disable the maskedBox, the backcolor become gray. Have not seen any other way to avoid that, so my anser is:
when the maskbox need to be disabled, change the forecolor to gray (just like the regular text box), and not allow it to receive focus.

When I test it, it works. comapred to a disabled regular textbox, the backcolor is the same, forecolor is the same, and it does not receive focus.

The might be better solution, but I have not thought a better one yet.

let me know whick part does not make sense?
regards
Dalin


0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463431
I'm curious.  Masked edit works fine on my machine.  It enables/disables just like the text box.

Dalin:
BTW, aside from the line you noticed yourself, this line also doesn't make sense:
MaskEdBox1.Text = vbBlack '(or the color of your choice)
0
 
LVL 4

Expert Comment

by:zsi
ID: 1463432
Dalin,

What doesn't make sense to me is the following:

A) How setting the .Text property to a color will have any effect other than making the Edit box *display* the long value of that color (I am referring to "MaskEdBox1.Text = vbBlack '(or the color of your choice) ";
2) How your answer could so closely resemble the concepts of another one that was posted two hours before yours; and
D) How you could have checked this code when it is apparent (by the capitalization of the mDiSaBlEd (or is it MdIsAbLeD?)  variable) that the code was not even entered into the VB IDE.

Unless, of course, you have syntax checking disabled.  

Which would make things much clearer to me.  :)
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463433
Thanks, guys, for point out the error in vbBlack, this meant to be:
When you want to enable the masked box, add:
    MaskEdBox1.forecolort = vbBlack '(or the color of your choice)
    MDisAbled = False

This is the part I added after I test the disabled part.  Sorry for all the careless.

Zsi. I did not see the answer two hours ago, appearent I am have the same problem as the questioner... The backcolor is different when disabled, even the forecolor...

Just to Clear the mess,  let me post again:

n the form's declare area:
    Dim Mdisabled as Boolean

    When you want to disable the maskbox, do not set enabled  to false, instead, put this code:
 MaskEdBox1.ForeColor = &H80000011
 Mdisabled = True

 In the maskbox's gotFocus event, add
    If Mdisabled = True Then Text2.SetFocus
    ' text 2 can be any other control receive focus after the editbox, which is not disabled.

    When you want to enable the masked box, add:
    MaskEdBox1.forecolor = vbBlack '(or the color of your choice)
    MDisAbled = False

0
 

Author Comment

by:paulca
ID: 1463434
Excellent answer.  It worked perfectly.  Thanks!!!
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463435
Apparently paulca forgot to grade.  :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 76
Validating VB6 Function 19 65
Run code from text file in vb 1 73
How to measure sizes and angles in scanned images ? 3 76
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

828 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