Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reverse Video Problems on Text Boxes Linked To Numeric Fields

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
I have some text boxes with numeric control sources(fields) that I want to highlight in reverse video when they get focus. I use the following 2 lines in the Got Focus Event.

thisform.text1.selstart = 0
thisform.text1.sellength = 11

text1's .maxlength is set to 11.
text1 is also left justified.
The value in it is 1234567.89

When I run the form, the values after the decimal point are not highlighted in reverse video along with the rest of the value in the field. Why?
The 2nd mouse gets the cheese.
 
Hello.

If I've understood correctly, you try to select all the text on gotfocus(). But you have a property for this: SelectOnEntry. Place a .T. there, and a DODEFAULT() in the GotFocus Method. It should do the work.

But this method have a great disavantage: the highlight is lost when you begin to type. Another method follows:

In the init event of the form, place the line:
DECLARE INTEGER GetSysColor IN Win32api INTEGER

In the GotFocus Method of the texbox, place the lines:

This.BackColor = GetSysColor(2) && this is blue under Windows98 - standard display settings.
This.ForeColor = GetSysColor(5) this is white in the same condition.

In the LostFocus method, place the following lines:
This.ResetToDefault("BackColor")
This.ResetToDefault("ForeColor")

In this way, the textbox will be white-on-blue as long it has the focus.

Hope this helps.
Grigore Dolghin
 
Hi drosenkranz,

As Grigore said, read about the SelectOnEntry, SelectedForecolor, & SelectedBackcolor properties.

Grigore,

It's completely unnecessary to delve into the Windows API just for a color code. Use VFP's RGB() function.

THIS.BackColor=RGB(0,0,255) && blue
THIS.ForeColor=RGB(255,255,255) && white Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Hello, Jon

Yes, I know what the backcolor property does. But if the user change de color scheme of the display through the control panel, the colors set with backcolor=rgb(smth,smth,smth) will remain the same. Using the Windows API (which don't harm the application) guarantees the colors changing.

NB. I always said about the applications designed in _one_ backcolor (gray at one time) which, when the user changes the windows color scheme remains gray although the rest of Windows is green, that they (tha applications) are bad designed. It's one of the rules. If SO is changed in some way, the application should be aware of the change. Don't you think the same?

All the best,
Grigore Dolghin
 
Hi Grigore,

I wont discount your arguement, you definitely have a valid point. Having your app respect & respond to the user's windows-defined color choices is certainly added eye-candy for the user.

I've just got few questions about the code you posted above (using your color philosphy).

First, when inversing the color in the GotFocus, why did you use 2, which correlates to the color of the active window titlebar text, instead of 8, which correlates to the color of the active window text?

Second, when resetting the color in the lostfocus event, why did you use the ResetToDefault() method which sets the property back to the VFP default? Shouldnt you have:

This.BackColor = GetSysColor(5)
This.ForeColor = GetSysColor(8)

so that it would use the windows colors as defined by the user? Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Hello again Jon!

I'm very sorry, Jon. I didn't mean in any way to put you in the corner, and if my message are offensive in any way, I apologize.

1. I preffer blue under standard display settings because the selected items are blue by default in Windows. It is true that I've missed the parameter (I've have to use the 'Selected Items color' from Control Panel - I don't have C++ handy nor the .H file to consult the parameter right now). So, I'm sorry for my mistake, but, as I said, I preffer to use blue instead black (active window text) to give the impression the textbox is selected (as the first poster wants). From my point of view, blue (also the Title Bar Color) is enough.

2. Yes, you're right, I should use the API calls to restore the default Windows Colors. But the ResetToDefault does exactly the same thing, because the VFP default colors (if the ColorScheme Property - Windows Color Scheme is used, which I'm positive - I never seen a programmer to change it :), so, as I've said, the VFP default colors are the same[/] as the Windows Color Scheme. Anyway, if a programmer change the color scheme of a textbox, his application is not Windows Color Scheme compliant, which is not our case.

So, this is my point of view about this issue, and, again, if I've offenced you in any way, I apologize.

Thank you for involving
GrigoreDolghin
 
Wasnt offended.......I was just curious. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top