Jump to content
Developer Wiki and Function Reference Links ×

Where do you put AddChoice to load CreatePullDownMenu?


WhoCanDo

Recommended Posts

Hi,

 

Where do you put AddChoice to load CreatePullDownMenu?

 

If I put it here, while Creating the Dialog layout, it doesn't work..
procedure CreateDialog1Layout;
  begin
  StanDialog1 := CreateLayout ('Handrail ID', False, 'OK', 'Cancel');
  AddChoice (StanDialog1, 7, ' ', 0);
  AddChoice (StanDialog1, 7, 'R', 1);
  AddChoice (StanDialog1, 7, 'L', 2);

 

If I put it here, after Creating the Dialog layout, it doesn't work..
CreateDialog1Layout;
AddChoice (StanDialog1, 7, ' ', 0);
AddChoice (StanDialog1, 7, 'R', 1);
AddChoice (StanDialog1, 7, 'L', 2);
If (RunLayoutDialogN (StanDialog1, GetCodeDialog1Results, True) = 1 { OK }) then

 

If I put it here, it duplicates the list repeatedly while picking or filling in other Edit boxes..
procedure GetDialog1Results (var Item : longint; Data : longint);
begin
AddChoice (StanDialog1, 7, ' ', 0);
AddChoice (StanDialog1, 7, 'R', 1);
AddChoice (StanDialog1, 7, 'L', 2);
Case Item of SetupDialogC: GetDialog1Events;

Link to comment

You want it in your dialog handler, GetDialog1Results (which is a bit of a misleading name, as this procedure runs every time you have a dialog event).

 

You generally initialize a pulldown in the SetupDialogC case, which is an event that runs before the dialog displays.

 

Otherwise item will correspond to the selected control. You can also dynamically add and remove items during any event, for example if the selection of one pulldown affects another, like record / field.

Link to comment

The old Dialog method was easier to understand, but harder to setup, than the new, so I've not completely grasped the process yet.

 

This is how I have formatted mine, so where to you put AddChoice?

 

1. Set up Dialog layout.

2. Get Dialog results.

        procedure GetEvents;
          begin
          GetItemText (StanDialog1, 5, Code);

          end;

    begin

    SetupDialog;
    Case Item of SetupDialogC: GetEvents;
      1  : GetCodeDialog1Events;
      2  : ; { Cancel }
      end; { Case }
    end;

3. Do something with the results

 

Link to comment

In the example, where does GetItemText (StanDialog1, 5, Code); etc. happen? How do you get the events/results?

 

I have been shown to create a sub-procedure GetDialogEvents to Dialog_Handler and use it as follows.

 

  Case Item of SetupDialogC: GetDialogEvents;
    1  : GetDialogEvents; { OK }
    2  : ; { Cancel }
    end; { Case }

Link to comment

Forgive me if I'm over-explaining, but the your formatting is a little confusing, so I thought breaking down the handler might be of assistance.

 

This is how I would format those statements:

Case Item of
    SetupDialogC: 
        AddChoices;
    1: {ID of ok button}
        GetDialogEvents;
    2: { ID of Cancel button }
end; { Case }

Item is generally the id of the item the user interacts with, but the dialog will also raise a setup id before the dialog displays and a set-down id after the dialog closes. Setup / Set-down are also where you might get / set any saved settings for dialog position or values.

 

The case statement is just a condensed if/then syntax. In your code, if the dialog is in setup, run AddChoices. If the user clicks OK, (presumable) save dialog values to global variables. Do nothin if the user clicks cancel.

 

Each response in the case statement does not need to be a separate procedure, though it can be if the code is more clear to you. Functionally, it is the same as Begin {procedure code} End;

  • Like 1
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...