Question Example Of A .net Form Placed On Top Of An Abl Window

I want to use .net with an existing ABL program that uses ABL windows. I have seen references to this being done in the documentation but only have seen code examples of the opposite (putting an ABL window on a .net form).

Does anyone have an example or can they point to one?

Thanks!
 

Osborne

Active Member
Just to be clear, do you want to use .NET controls in ABL windows or actually embed a .NET form in an ABL window? If the former, then the link ForEachInvoiceDelete posted provides good examples. If the latter though, it cannot be done.

It you want to embed a .NET form in an ABL window what is the reason? If it is for .NET controls to be available in ABL windows, then by embedding an ABL window in a .NET form and adding.NET controls to that form, from the users point of view it is the same as adding .NET controls to ABL Windows.
 
My goal is to use .net controls (a button for example) in an existing application that is based on ABL windows.
Is this possible? I have read that documentation before and I don't see an example, unless I am missing the obvious.
 

Osborne

Active Member
Yes, that is perfectly possible. A very basic example of a simple ABL window with a FILL-IN, that was initially created in the AppBuilder and being embedded in a .NET form with a .NET button added:
Code:
CREATE WIDGET-POOL.

DEFINE VARIABLE oButton AS System.Windows.Forms.Button NO-UNDO.
DEFINE VARIABLE oForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE oWindowContainer AS Progress.Windows.WindowContainer NO-UNDO.

DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.

DEFINE VARIABLE FILL-IN-1 AS CHARACTER FORMAT "X(256)":U
     LABEL "Fill 1"
     VIEW-AS FILL-IN
     SIZE 14 BY 1 NO-UNDO.

DEFINE FRAME DEFAULT-FRAME
     FILL-IN-1 AT ROW 1.71 COL 7 COLON-ALIGNED
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
         SIDE-LABELS NO-UNDERLINE THREE-D
         AT COL 1 ROW 1
         SIZE 100 BY 16.

CREATE WINDOW C-Win ASSIGN
       TITLE   = "ABL Window Embedded Into .NET Form"
       HEIGHT  = 16
       WIDTH   = 100
       THREE-D = yes.

ON CLOSE OF THIS-PROCEDURE
   RUN disable_UI.

MAIN-BLOCK:
DO ON ERROR   UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
   /* Create the .NET form. */
   oForm = NEW Progress.Windows.Form().
   oForm:ClientSize = NEW System.Drawing.Size(C-Win:WIDTH-PIXELS,C-Win:HEIGHT-PIXELS).
   oForm:Text = C-Win:TITLE.
   oForm:FormClosed:Subscribe("FormClosed").

   /* Create .NET button. */
   oButton = NEW System.Windows.Forms.Button().
   oButton:Location = NEW System.Drawing.Point(100,100).
   oButton:Text = ".NET Button".
   oButton:Click:Subscribe("NetButtonClick").
   oForm:Controls:Add(oButton).

   /* Create the WindowContainer, embedding the ABL window into it. */
   oWindowContainer = NEW Progress.Windows.WindowContainer().
   oWindowContainer:Size = NEW System.Drawing.Size(C-Win:WIDTH-PIXELS, C-Win:HEIGHT-PIXELS).
   oWindowContainer:EmbeddedWindow = C-Win.
   oWindowContainer:Parent = oForm.

   oWindowContainer:Show().
   oForm:Show().
   RUN enable_UI.
   IF NOT THIS-PROCEDURE:PERSISTENT THEN
     WAIT-FOR System.Windows.Forms.Application:Run(oForm).
END.

PROCEDURE disable_UI :
  IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
  THEN DELETE WIDGET C-Win.
  IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.

PROCEDURE enable_UI :
  DISPLAY FILL-IN-1
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  ENABLE FILL-IN-1
      WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
  VIEW C-Win.
END PROCEDURE.

PROCEDURE FormClosed :
   DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS System.EventArgs NO-UNDO.

   APPLY "CLOSE" TO THIS-PROCEDURE.
END PROCEDURE.

PROCEDURE NetButtonClick :
   DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS System.EventArgs NO-UNDO.

   MESSAGE ".NET button clicked - close form." VIEW-AS ALERT-BOX.
   oForm:Close().
END PROCEDURE.
 
Thank you for the code but this appears to be the opposite of what I am asking. This is a .net form with an ABL window in it. (or is there something I am not getting?)
I realize in theory they would look the same but if I suspect it would be easier to work the other way in an existing application.
Is what I am saying even possible?
 

Osborne

Active Member
No, to use .NET controls they have to be on a .NET form and cannot be placed on an ABL window. So the only way is to create a .NET form from the ABL window properties, which then hosts both the ABL window and the .NET controls.

In a way it is still the existing application, with the main difference being it now auto-creates a .NET form and embeds it's window onto it. The ABL window still exists - you still have the main workings such as VIEW C-Win. - it is just now being hosted in a .NET form which it auto-created itself.
 
Top