Jump to content
Developer Wiki and Function Reference Links ×

Modern Dialogue Headache


Recommended Posts

{I have done plenty of classic custom dialog boxes. I like the procedures and I'm comfortable with screen co-ordinates .

However because these procedures have all been scrapped, I'm now trying to write a simple example script showing a

custom modern dialog into which real values a & b are entered in order to draw a rectangle (See below).

Once I've got this right, I can go on to do scripts for complex objects with many variables}

Procedure DialogTest;

Procedure SetUpDialog;

VAR

a,b:REAL;

ID: LONGINT;

Res:LONGINT;

BEGIN

ID:=CreateLayout('Parameters', False, 'OK', 'Cancel');

{Text fields}

CreateStaticText( ID, 05, 'Value-a', 15);

CreateStaticText( ID, 06, 'Value-b', 15);

{Box fields}

CreateEditReal( ID, 15, 1, 1.25, 10);

CreateEditReal( ID, 16, 1, 2.64, 10);

{Text layout}

SetFirstLayoutItem( ID, 05);

SetBelowItem( ID, 05, 06, 0, 0);

{Box layout}

SetRightItem( ID, 05, 15, 0, 0);

SetRightItem( ID, 06, 16, 0, 0);

Res:=RunLayoutDialog( ID, NIL);

END;

BEGIN

SetUpDialog;

{I now need to assign the field values entered for Value-a & Value-b

to the declared variables a & b.

The obvious step would be -

a:=GetEditReal(ID, 15, 1, true);

b:=GetEditReal(ID, 16, 1, true);

rect(0, 0, a, b);

END;

Run(DialogTest);

Dead simple and similar to the sort of script in version 2008.

However this does not work, and I have tried numerous workarounds with no success.

QUESTION: How do I put in this missing link?

Any constructive advice most welcome!}

Link to comment

I believe you are missing the procedure that drives the dialog in Res:= RunLayoutDialog( ID, NIL), which most likely will give you an error.

The following should get you going as you create more complicated dialogs.

Procedure DialogTest;

TYPE
U_RECT = STRUCTURE
	a: REAL;
	b: REAL;
END;

VAR
gRectObj: U_RECT;

FUNCTION SetUpDialog(rectObj: U_RECT): LONGINT;
VAR
	ID: LONGINT;
BEGIN
ID:= CreateLayout('Rect Dimensions',TRUE,'OK','Cancel');

{Text fields}
CreateStaticText( ID, 05, 'Value-a', 15);
CreateStaticText( ID, 06, 'Value-b', 15);

{Box fields}
CreateEditReal( ID, 15, 1, rectObj.a, 10);
CreateEditReal( ID, 16, 1, rectObj.b, 10);

{Text layout}
SetFirstLayoutItem( ID, 05);
SetBelowItem( ID, 05, 06, 0, 0);

{Box layout}
SetRightItem( ID, 05, 15, 0, 0);
SetRightItem( ID, 06, 16, 0, 0);

SetHelpText(ID, 1,'Click to accept values');
SetHelpText(ID, 2,'Click to cancel operation');
SetHelpText(ID, 15,'Enter width');
SetHelpText(ID, 16,'Enter height');

SetUpDialog:= ID;
END;

FUNCTION GetRect(VAR rectObj: U_RECT): BOOLEAN;
VAR
	a,b: REAL;
	ID,dlogResult: LONGINT;

	PROCEDURE DriveDialog(VAR item:LONGINT; data:LONGINT);
	VAR
		i,choiceNo: INTEGER;
		foundName: BOOLEAN;
	BEGIN
	CASE item OF
		SetupDialogC:
			BEGIN
			END;
		1: {OK}
			BEGIN
			IF GetEditReal(ID,15,1,a) THEN
				rectObj.a:= a;
			IF GetEditReal(ID,16,1,b) THEN
				rectObj.b:= b;
			END;
		2: {Cancel}
			BEGIN
			END;
		END;
	END;

BEGIN
GetRect:= FALSE;
ID:= SetUpDialog(rectObj);
IF VerifyLayout(ID) THEN
	BEGIN
	dlogResult:= RunLayoutDialog(ID,DriveDialog);
	IF dlogResult = 1 THEN
		GetRect:= TRUE;
	END
ELSE
	AlrtDialog('Cannot create the dialog');
END;

BEGIN
gRectObj.a:= 1.25;
gRectObj.b:= 2.64;
IF GetRect(gRectObj) THEN
BEGIN
Rect(0,0,gRectObj.a,gRectObj.b);
END;
END;
Run(DialogTest);

Link to comment

Many thanks for that, Miguel.

Just what I was needing to get started.

Much appreciated:-)

The user manuals seem to be ok on examples of standalone boxes, but one that actually works in practice is quite another matter.

This gives me what I need to get going on a box for multiple inputs, when I'm scripting windows, spiral staircases etc.

The old custom boxes work fine in VW2013, but i'll have to upgrade sooner or later.

Again many thanks for your help.

Gridbuff

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...