Obj with custom preference dialog

From Vectorlab
Jump to: navigation, search


Object with a custom preference dialog:

by Charles Chandler, Januar 2007

PROCEDURE Example1;
CONST
	kObjOnInitXProperties = 5;
	kObjXPropPreference = 4;
	kOnObjPrefEventID = 4;
	kResetEventID = 3;
VAR
	theEvent, theButton :LONGINT;
	result :BOOLEAN;
BEGIN
	vsoGetEventInfo(theEvent, theButton);
	CASE theEvent OF

		{User has single-clicked the object's icon.}
		kObjOnInitXProperties: 
			BEGIN
				{This tells VW to pass the preference event back
				to this object, as the kOnObjPrefEventID event,
				instead of calling the built-in preference handler,
				which pops up the Object Properties dialog.}
				result := SetObjPropVS(kObjXPropPreference, TRUE);
			END;

		{User has clicked the Preferences button in the Mode bar, or
		double-clicked the object in the drawing (see example 9). This
		event will never happen if the kObjXPropPreference property is
		not set to TRUE in the initialization event (above).}
		kOnObjPrefEventID: 
			BEGIN
				{Typically this dialog accepts user input and uses SetRField
				to write the values to the object's record definition handle.}
				AlrtDialog('Custom Preference Dialog');
			END;

		{Object reset has been called.}
		kResetEventID: 
			BEGIN
				Rect(0, 0, 1, 1);
			END;

	END;
END;
RUN(Example1);

See also

Events