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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color picker problem

Status
Not open for further replies.

jhonny03

Programmer
Oct 28, 2015
23
PH
i have problem on color picker which is
when cancel was press the chosen color was white..it is maybe
that is the default color..

what i want is that when cancel was pressed then no changes on the
current color chosen.
 
Escape means -1. In other words, you may need to check the return value, and provide a default if it's -1.
 
The default colour is black, which is zero.

If you choose white, the value is 16777215.

If you press Cancel or hit ESC, the value is -1.

The confusion arises because GETCOLOR() returns a 24-bit value, and (2^24) = 1 = 16777215. On that basis, -1 is the same as white. So, you can explicitly set, say, _SCREEN.Backcolor to -1, and it will appear as white. But this isn't really a problem, as you will always explicitly test for -1 to see if GETCOLOR() was cancelled.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
thanks for the reply guys..
is it possible to code it?

getcolo()
if cancel was pressed then
gray color
endif
 
tnx mike..
another thing..
is there a possible way to dissable white color to be chosen
by the user?
 
If they select white, then present a messagebox telling it's an illegal color, and present the color picker once more.
 
If you want to want to prevent them selecting white in the first place (rather than displaying a message to say it's an illegal value), you could create your own custom colour picker. Make it an ordinary VFP modal form, with a shape for each permitted colour, and a pair of buttons for OK and Cancel. When the user clicks on one of the shapes, save the corresponding numeric code in a form property, and then return that value when the form is closed.

You might well decide that's too much trouble, and also that it would have the disadvantage of a non-standard appearance. But it might be better than the alternative, that is, permitting the user to make a choice and then turning round and saying that the choice is illegal - which is a UI no-no, in my humble o.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top