# setting position of color picker



## shannen (Jul 25, 2003)

Hi all,
Does anybody know how I can get the PickColor control to start-up at a specified position? I tried setting the value in the following ways (psuedo code):
ColorPickerInfo.placeWhere=kAtSpecifiedOrigin;
ColorPickerInfo.dialogOrigin.v = 10;
ColorPickerInfo.dialogOrigin.h = 10;

Also, from the documentation, it mentioned that the dialogOrigin structure is suppose to contain the position of the dialog when it returns. Apparently, the debugging information that I got did not contain this. Appreciate for all help rendered and thank you very much once again


----------



## shannen (Jul 29, 2003)

Hi all,
Is everybody clueless to my problem? I really appreciate if anyone could help me with any types of possible solution. Thank you very much once again


----------



## Arden (Jul 29, 2003)

Does it work?  If not, it might be saying that it starts at that distance from the default, which I believe is right next to the window you're selecting from.  I'm not sure how to get it to behave correctly.


----------



## shannen (Jul 30, 2003)

ai....sad to say, it does not work and tt't y i badly needed help on this. in fact, it does not even come out on the side of the window. it appears in the center of the screen, just like setting the placeWhere flag to the center. HELPPPPPP


----------



## tjw (Jul 31, 2003)

I'm not familiar with Carbon, but I did find this: http://developer.apple.com/documentation/Carbon/Reference/Color_Picker_Manager/index.html


----------



## shannen (Jul 31, 2003)

Thanks for the link provided. that was the exact one that i used to reference and came up with the stated code but it failed to work....oh my god!!!! i am so helpless........


----------



## tjw (Jul 31, 2003)

Can you attach the code in question so i/we could play with it?


----------



## shannen (Jul 31, 2003)

Hi,
The following is the function that I wrote to prompt the ColorPicker dialog. The input parameter is the color that I wanted the dialog to pick. Everything works except for the position setting. Thank you all so much.

>>>>>>>>>>>>>>>>>>>>
 */
bool CDialogs:romptObjectTimebarColor( ::CColor& ioColor )
{
	bool theUserSelected = false;

	::CColor theStateColor = ioColor;
	CMRGBColor theColor = { theStateColor.GetRed( ) * 256, theStateColor.GetGreen( ) * 256, theStateColor.GetBlue( ) * 256 };
	NPMColor thePMColor = { NULL, theColor }; 

long theVal;
::Gestalt(gestaltColorPickerVersion, &theVal );
	// Initialize the color picker
	NColorPickerInfo theInfo;
	theInfo.theColor = thePMColor;
	theInfo.dstProfile = NULL;
	//theInfo.placeWhere = kCenterOnMainScreen;
	theInfo.placeWhere = kAtSpecifiedOrigin;
	theInfo.dialogOrigin.v = 0;
	theInfo.dialogOrigin.h = 0;
	theInfo.pickerType = 0;
	theInfo.eventProc = NULL;
	theInfo.colorProc = NULL;
	theInfo.colorProcData = 0;

	short theR;
	short theG;
	short theB;

	// Run the color picker and if there wansn't an err, then set the color
	if ( ( NPickColor( &theInfo ) == noErr ) && ( theInfo.newColorChosen ) )
	{
		theR = theInfo.theColor.color.rgb.red / 256;
		theG = theInfo.theColor.color.rgb.green / 256;
		theB = theInfo.theColor.color.rgb.blue / 256;
		ioColor = ::CColor( theR, theG, theB );
		theUserSelected = true;
	}
	return theUserSelected;
}


----------



## wiz (Jul 31, 2003)

do u mind formatting it please enclose it in [ code ]...[/ code ] tags


----------



## shannen (Aug 1, 2003)

sure i can but why is there a need? Pardon me for my ignorance. Is it some devt tools specific stuff? I am using code warrior. Let me know how you want me to enclose it? (every line ?) thanks again


----------



## wiz (Aug 1, 2003)

the whole block of text but hey np... it's pretty neat


----------



## shannen (Aug 4, 2003)

oh gosh...seems like this is not an easy problem....its been a week.... :'(


----------

