Jump to content
Developer Wiki and Function Reference Links ×

CreateLayout help


WhoCanDo

Recommended Posts

Hi,

Since BeginDialog is comming to its end, I want to try and convert my macros to CreateLayout but I can't find much help or examples.

With the below, what is the next step to identify which box is checked?

procedure test;

var

i, OI : integer;

DialogID : longint;

procedure Dialog_Handler (var a : longint; b : longint);

begin

end;

begin

DialogID := CreateLayout ('CHOOSE', False, 'OK', 'Cancel');

CreateStaticText (DialogID, 3, 'Choose !', 30);

SetFirstLayoutItem (DialogID, 3);

for i := 4 to 6 do

begin

CreateThreeStateCheckBox (DialogID, i, Concat (' ', i));

SetBelowItem (DialogID, i - 1, i, 0, 0);

end;

if (VerifyLayout (DialogID)) then

If (RunLayoutDialog (DialogID, Dialog_Handler) = 1) then

begin

SetThreeStateCheckBoxState (DialogID, 4, 1);

for i := 4 to 6 do

begin

GetThreeStateCheckBoxState (DialogID, i, OI);

message (OI);wait(0.5);clrmessage;

end;

end;

end;

run (test);

Link to comment

Message inside a dialog run will not work.

So, the way to get temp information from your dialog while it's running is to use the Debugger (but chances are big that VW will crash) or to put the info into text objects.

in short:

after you create your layout with CreateLayout, you need to create controls and set them on the correct place with SetFirstLayoutItem, SetBelowItem, SetrightItem, SetFirstGroupItem,... (but you already did that part correct)

Then you run the dialog with RunLayoutDialog.

This Function will call the Dialog_Handler Procedure.

In that Procedure, VW will tell you what control has been modified by the user (you called that Var a). At creation of the dialog, so as first, SetupDialogC will be called. In the SetupDialogC case, you can adjust your controls (visibility, enable, disable, check, uncheck,...)

And then you have the 1 case (user clicked OK button) and the 2 case (user clicked Cancel button).

procedure test;

var
i, OI : integer;
DialogID : longint;

procedure Dialog_Handler (var a : longint; b : longint);
begin
	case a of
		SetupDialogC:
		begin
			SetThreeStateCheckBoxState (DialogID, 4, 1);
		end;
		1:
		begin
			for i := 4 to 6 do
			begin
				{get the information from your dialog}
				GetThreeStateCheckBoxState (DialogID, i, OI);
				{this is temp, jus tto show the information}
				MoveTo(0,i*-2cm);
				CreateText(Concat(i,': ',OI));
			end;
		end;
	end;
end;

begin
DialogID := CreateLayout ('CHOOSE', False, 'OK', 'Cancel');
CreateStaticText (DialogID, 3, 'Choose !', 30);
SetFirstLayoutItem (DialogID, 3);
for i := 4 to 6 do
begin
	CreateThreeStateCheckBox (DialogID, i, Concat (' ', i));
	SetBelowItem (DialogID, i - 1, i, 0, 0);
end;
if (VerifyLayout (DialogID)) then If (RunLayoutDialog (DialogID, Dialog_Handler) = 1) then
begin
	{place the rest of your script here}
end;
end;
run (test);

Link to comment

Message inside a dialog run will not work.

So, the way to get temp information from your dialog while it's running is to use the Debugger (but chances are big that VW will crash) or to put the info into text objects.

VW will always crash if you attemp to open another window while a dialog is executing, so even the debugger will not work because it is also a window. The safest method I found is to "Write" the results to the output or open file.

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...