Button in Object Info

From Vectorlab
Jump to: navigation, search


Object that has a button on the Object Info palette:

by  Charles Chandler, Januar 2007

PROCEDURE Example3;
CONST
	kObjOnInitXProperties = 5;
	kResetEventID = 3;
	kObjXPropHasUIOverride = 8;
	kWidgetButton = 12;
	kObjOnObjectUIButtonHit = 35;
	buttonID_1 = 1234; {user-definable index}
VAR
	theEvent, theButton :LONGINT;
	result :BOOLEAN;
	sourceFieldNumber :INTEGER;
	buttonEventID :INTEGER;
	displayString :STRING;
	thisDoesNothing :LONGINT;
BEGIN
	vsoGetEventInfo(theEvent, theButton);
	CASE theEvent OF

		{User has single-clicked the object's icon.}
		kObjOnInitXProperties: 
			BEGIN
				{This tells VW to let the object decide what goes
				onto the Object Info palette.}
				result := SetObjPropVS(kObjXPropHasUIOverride, TRUE);

				{Now we manually add the "normal" parameters...}

				{One way is to use this single call to add all
				of the existing parameters.}
				result := vsoInsertAllParams;

				{Alternatively, you can use this to tack individual parameters 
				onto the end of the list one at a time. This way, you don't have 
				to use SetParameterVisibility in the reset event to hide parameters
				that you never want to see.}
				sourceFieldNumber := 1;
				displayString := 'My Great Field Name';
				result := vsoAppendParamWidget(sourceFieldNumber, displayString, thisDoesNothing);

				{Finally, we add the button.}
				displayString := 'My Great Button';
				result := vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing);
			END;

		{User has clicked a button in the Object Info palette.}
		kObjOnObjectUIButtonHit:
			BEGIN
				CASE theButton OF
					buttonID_1:
						BEGIN
							AlrtDialog('Custom Button Dialog');
						END;
				END;
			END;

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

	END;
END;
RUN(Example3);

See also

Events