Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetColor
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00700557
Message ID:
00883147
Views:
50
Hi Bob,

It will remember Custom Colors as long as you keep object reference. IOW, instantiate class once and then use it.
_SCREEN.AddProperty("oDlg", NEWOBJECT("GetColorEx", "GetColorExClass.fxp"))
? _SCREEN.oDlg.Getcolor(255)

? _SCREEN.oDlg.Getcolor()

RETURN
*-----------------------------------------------------------------------

* Put this code in GetColorExClass.prg
DEFINE CLASS GetColorEx AS form
	Left = 100   && Set Dialog Position by positioning the form
	Top = 100    && Set Dialog Position
	Name = "GetColorEx"
	DoCreate = .T.
	Visible = .F.
	lUserCancel = .F.

	ADD OBJECT oCDC AS OleControl WITH ;
		OleClass = "MsComDlg.CommonDialog"

	PROCEDURE oCDC.Init
		This.Flags = 2+1
		This.CancelError = .T. 	
	ENDPROC 	

	PROCEDURE Error
		LPARAMETERS nError, cMethod, nLine
		IF nError = 1429
			This.lUserCancel = .T.
		ENDIF
	ENDPROC 	

	PROCEDURE GetColor(tnInitColor)
                LOCAL lnColor 
		IF PCOUNT() > 0
			Thisform.oCDC.Color = tnInitColor
		ENDIF
		Thisform.lUserCancel = .F.
		Thisform.oCDC.ShowColor()
		IF Thisform.lUserCancel 
			lnColor = -1
		ELSE	
			lnColor = Thisform.oCDC.Color		
		ENDIF
		RETURN lnColor 
	ENDPROC 	

ENDDEFINE	


>Thanks for this, Sergey, from 2002. (Love those message archives <g>!)
>
>When I use GETCOLOR(), I can click on "Add to Custom Colors" and it works. When I call the dialog next time, the custom colors is still defined so I can re-use it.
>
>When I use the Common Dialog, clicking on "Add to Custom Colors" adds the color. But when I call the dialog next time, the custom color is no longer defined.
>
>Do you know how I can overcome this problem?
>
>Thanks again for the helpful code.
>
>-Bob
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform