OpenEdge GUI for NET

balta

Member
Hello,

I am starting developing in OpenEdge GUI for .NET and i am trying to do a output parameter in a dialog.

Code:
        oForm = dynamic-new "hlg_0001"("abc").
        oForm:FormBorderStyle = System.Windows.Forms.FormBorderStyle:FixedDialog.
        oForm:MaximizeBox = FALSE.
        oForm:MinimizeBox = FALSE.
        oForm:ShowInTaskbar = FALSE.
        
        oForm:StartPosition = System.Windows.Forms.FormStartPosition:CenterParent.
        oForm:Text = "In Progress".
        
        //oForm:Show().
        WAIT-FOR oForm:ShowDialog( ).
        oForm:Dispose( ).

How i can i have a output param after close the dialog?

Thanks,
Baltazar
 

Osborne

Active Member
One option is to invoke/record an OK acceptance and if accepted set the parameter then.

Example 1:
Code:
DEFINE VARIABLE oDialogResult AS System.Windows.Forms.DialogResult NO-UNDO.
DEFINE VARIABLE oPrintDialog AS System.Windows.Forms.PrintDialog NO-UNDO.

oPrintDialog = NEW System.Windows.Forms.PrintDialog().
WAIT-FOR oPrintDialog:ShowDialog() SET oDialogResult.

IF Progress.Util.EnumHelper:AreEqual(oDialogResult,
                                     System.Windows.Forms.DialogResult:OK) THEN
   MESSAGE oPrintDialog:PrinterSettings:PrinterName VIEW-AS ALERT-BOX.
ELSE
   MESSAGE "Not accepted." VIEW-AS ALERT-BOX.

Example 2:
Code:
DEFINE VARIABLE buttonOk AS System.Windows.Forms.Button NO-UNDO.
DEFINE VARIABLE buttonCancel AS System.Windows.Forms.Button NO-UNDO.
DEFINE VARIABLE oForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE oDialogResult AS System.Windows.Forms.DialogResult NO-UNDO.

ASSIGN buttonOk = NEW System.Windows.Forms.Button()
       buttonCancel = NEW System.Windows.Forms.Button().

ASSIGN buttonOk:Location = NEW System.Drawing.Point(237, 332)
       buttonOk:Name     = "buttonOk"
       buttonOk:Size     = NEW System.Drawing.Size(75, 23)
       buttonOk:TabIndex = 0
       buttonOk:Text     = "&OK"
       buttonOk:DialogResult = System.Windows.Forms.DialogResult:OK.

ASSIGN buttonCancel:DialogResult = System.Windows.Forms.DialogResult:Cancel
       buttonCancel:Location     = NEW System.Drawing.Point(321, 332)
       buttonCancel:Name         = "buttonCancel"
       buttonCancel:Size         = NEW System.Drawing.Size(75, 23)
       buttonCancel:TabIndex     = 1
       buttonCancel:Text         = "&Cancel".

ASSIGN oForm                 = NEW Progress.Windows.Form()
       oForm:AcceptButton    = buttonOk
       oForm:CancelButton    = buttonCancel
       oForm:ClientSize      = NEW System.Drawing.Size(410, 369)
       oForm:FormBorderStyle = System.Windows.Forms.FormBorderStyle:FixedDialog
       oForm:MaximizeBox     = NO
       oForm:MinimizeBox     = NO
       oForm:Name            = "DialogForm"
       oForm:ShowInTaskbar   = NO
       oForm:StartPosition   = System.Windows.Forms.FormStartPosition:CenterParent
       oForm:Text            = "Dialog Box".
oForm:Controls:Add(buttonCancel).
oForm:Controls:Add(buttonOk).

WAIT-FOR oForm:ShowDialog() SET oDialogResult.

IF Progress.Util.EnumHelper:AreEqual(oForm:DialogResult,
                                     System.Windows.Forms.dialogResult:OK) THEN
   MESSAGE "OK was selected." VIEW-AS ALERT-BOX INFORMATION.
ELSE
IF Progress.Util.EnumHelper:AreEqual(oForm:DialogResult,
                                     System.Windows.Forms.dialogResult:Cancel) THEN
   MESSAGE "Cancel/Window close was selected." VIEW-AS ALERT-BOX INFORMATION.
 

balta

Member
Hello Osborne,

Thanks for your code.

In the second example, how can I return a "custom" value?

Thanks,
Baltazar
 

Osborne

Active Member
Previous post was incomplete. To obtain a parameter in the calling program two ideas:

Pass the handle/object of the calling procedure/class either via the constructor or a method/property to the called class, and when accepted run the internal procedure/method from the called class:
Code:
RUN <procedure> IN <proc handle> (<params>).

Or from the calling procedure/class call a method in the called class before you dispose the form. Even though ShowDialog() will close the form the instance is still available so you can call a method or a property for the "custom" value:
Code:
WAIT-FOR oForm:ShowDialog( ).
oForm:CustomValue.
// oForm:CustomValues(OUTPUT <params>).
oForm:Dispose( ).
 

balta

Member
Can you inform how you call a dialog?

I have created an example that 'teste1' calls 'teste2'

Can you please correct the code to show the output value?

(In the input param i put directly, i think that is correct).

Thanks a LOT for your help.
 

Attachments

  • teste1.cls
    5.4 KB · Views: 3
  • teste2.cls
    3.9 KB · Views: 3

Osborne

Active Member
I normally call a dialog box using the examples I posted in my first post, and see that in teste2 you have done similar so that is okay.

In teste1 you have the WAIT-FOR in the ShowModalDialog method and if you wanted values from that Dialog then this would be the workings:

Code:
DEFINE VARIABLE oTeste1 AS teste1 NO-UNDO.

oTeste1 = NEW teste1().
oTeste1:ShowModalDialog().
IF Progress.Util.EnumHelper:AreEqual(oTeste1:DialogResult,
                                     System.Windows.Forms.DialogResult:OK) THEN
   MESSAGE "Dialog Box okayed." VIEW-AS ALERT-BOX.
ELSE
   MESSAGE "Dialog Box cancelled." VIEW-AS ALERT-BOX.
oTeste1:Dispose().

Looking at teste1.cls can instantly see the reason for the errors you are having and the problem is in the btnDialog_Click method. You have defined oForm to what is effectively a "locked" class:
Code:
DEFINE VARIABLE oForm AS Progress.Windows.Form NO-UNDO.
The CustomValue method does not exist in the Progress.Windows.Form class nor can you add it. It should be:
Code:
DEFINE VARIABLE oForm AS teste2 NO-UNDO.
.
Now you do not require DYNAMIC-INVOKE and can call the CustomValue method in teste2.cls as normal:
Code:
oForm:CustomValue("params").
Make these two changes and everything should work fine.
 

balta

Member
Thanks.

I have finalized manage to do an output param.

1635505581503.png
It is possible to output a Temp Table?
The way that I am sending input param is the correct?

1635505661801.png
 

Osborne

Active Member
Yes, the sending of the input parameter is correct.

No problem outputting a Temp Table, and there are a number of ways.

The best option is to encapsulate the Temp Table into a single object and have access methods to work with the temp-table. This avoids passing the temp-table at all.

Another option is to output the Temp Table Buffer and access as you would a dynamic buffer:

Calling Prog:
Code:
DEFINE VARIABLE hTTBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hTT AS HANDLE NO-UNDO.

oForm:getTTHandle(OUTPUT hTT).
hTTBuffer = hTT:DEFAULT-BUFFER-HANDLE.
Called Prog:
Code:
METHOD PUBLIC VOID getTTHandle(OUTPUT pTT AS HANDLE):
   pTT = TEMP-TABLE ttExample:HANDLE.
END METHOD.
Both the above avoid having the Temp Table defined in both programs. Otherwise you require something similar to:

Calling Prog:
Code:
oForm:getTTs(OUTPUT TABLE ttExample).
Called Prog:
Code:
METHOD PUBLIC VOID getTTs(OUTPUT PARAMETER TABLE FOR ttExample):
END METHOD.
This will result in a copy of the Temp Tables so if you have 10000 in the called program the calling program will have the same 10000 meaning a total of 20000 Temp Table records. So you need to use REFERENCE-ONLY or BIND:


A rough class example where the Temp Tables are only created and stored in the called program:

Calling Prog:
Code:
DEFINE TEMP-TABLE ttExample NO-UNDO REFERENCE-ONLY
   FIELD field1 AS CHARACTER.

oForm:getTTs(OUTPUT TABLE ttExample BIND).
Called Prog:
Code:
DEFINE TEMP-TABLE ttExample NO-UNDO
   FIELD field1 AS CHARACTER.

METHOD PUBLIC VOID createTTs():
   CREATE ttExample.
   ASSIGN ttExample.field1 = "a".
END METHOD.

METHOD PUBLIC VOID getTTs(OUTPUT TABLE ttExample BIND):
END METHOD.
 

Osborne

Active Member
You can either set the method to be an extent or the best option is to make the method a VOID method instead:
Code:
METHOD PUBLIC VOID CustomValue (OUTPUT oValor1 AS CHAR, OUTPUT oValor2 AS CHAR):
   oValor1 = "abc".
   oValor2 = "33".
END METHOD.
Then the calling code passes defined variables for the multiple outputs:
Code:
oForm:CustomValues(OUTPUT vValor1,OUTPUT vValor2).
MESSAGE vValor1 vValor2 VIEW-AS ALERT-BOX.
 
Top