Embedding .Net form in Progress window

Posted by tbergman on 09-Sep-2014 08:13

Progress 11.3 We have Progress GUI application that we have not had the time or resources to rewrite using .Net Forms. We have used .Net forms for new features but keep wanting to use some .Net controls in some of our exiting ABL windows. I know this is unsupported but decided to give it a try. Using a form with FormBorderStyle set to none, and the WinApi calls setParent and MoveWindow, I've been able to get this basically working in a small test environment. The one remaining known problem is that when I focus on the .Net form that's embedded in the ABL window, the ABL window appears inactive. This may not be a fatal flaw but it is distracting. I have two questions. 1) Is there a way I can get the ABL Window to retain its active appearance even when focus is now on the embedded .Net form? 2) Has anyone else done this and what other pitfalls am I likely to encounter? IOW, am I wasting my time for some as yet undiscovered reason? Thanks

All Replies

Posted by tbergman on 09-Sep-2014 08:48

As is usual for me, 10 minutes after I posted this I came up with a, seemingly working, solution for question #1. Sometimes I just have to write something up before the lights go on. I just embedded a .Net user control instead of a form. I'd still like to know if anyone else has pursued this and their experience. Thanks, Tom

Posted by Peter Judge on 09-Sep-2014 09:08

Aka PSDN = the rubber duck debugger :) (http://en.wikipedia.org/wiki/Rubber_duck_debugging)
 
[collapse]
From: tbergman [mailto:bounce-tbergman@community.progress.com]
Sent: Tuesday, 09 September, 2014 09:49
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Embedding .Net form in Progress window
 
Reply by tbergman
As is usual for me, 10 minutes after I posted this I came up with a, seemingly working, solution for question #1. Sometimes I just have to write something up before the lights go on. I just embedded a .Net user control instead of a form. I'd still like to know if anyone else has pursued this and their experience. Thanks, Tom
Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Mike Fechner on 09-Sep-2014 10:27

Hi Thomas,
 
we do that frequently in the WinKit. For Grids, Ribbons, Tab Folders, Buttons, Trees, …
 
We simply overlay the WindowContainer control with the other controls. The challence is keeping the state (enabled, etc.) and tab order etc. in sync. For the latter we have written a handler, that allows definition of mixed tab order between ABL widgets and .NET Controls and vice versa.
 

Posted by tbergman on 09-Sep-2014 12:13

Hi Mike,

Maybe I'm confused (probably?) but isn't Winkit and the Progress window container used in order to put ABL widgets and frames into a .Net form?

I'm planning on the opposite. .Net components in a ABL window. There is no .net form.

Thanks,

Tom

Posted by Mike Fechner on 09-Sep-2014 13:53

Well every ABL window deserves a facelift by embedding it.

First you embed the ABL Window in the WindowContainer and put that Window Container on the Form. Then you overlay the Window Container (alas the ABL Window) with other .NET Controls. Show me the user who can tell the difference...

Posted by PeterWokke on 10-Sep-2014 02:57

Hello Mike,

How to embed an ABL Window in the WindowContainer and put it an a Form.

From the PSDOE you can create a form and drop a WindowContainer on it.

Can you embed the ABL window after you put the WindowContainer on the form too.?

Regards,

Peter

Posted by Mike Fechner on 10-Sep-2014 03:03

You cannot embed in the Visual Designer.
 
It’s all done at runtime. The GUI for .NET docs are pretty good in explaining the process.
 
Let me know, if you have questions (or are interested in a demo of the WinKit J ).

 

Posted by PeterWokke on 11-Sep-2014 01:37

The GUI for .NET docs are explaining how to add a window to MDIChildForm into a MDI container.

And to embed the window into a Window container and set the parent to the form.

In the example they use CREATE WINDOW hWin.

And add this hWin.

It does not explain how I get my SmartWindow sales/wo_order.w into this.

Do I have to start it persistent set to get the window handle and forward that into the Window Container?

Or is there an other way to set a window handle to sales/wo_order.w

Kind regards,

Peter Wokke

Posted by Mike Fechner on 11-Sep-2014 01:59

Hi Peter – preferably you’d start SmartWindow persistent.
 
You instantiate a .NET Form that contains the WindowContainer Control and pass the ABL Windows’s Handle to the WindowContainer’s Handle property.
 
Only challenge: You need to do this before the ABL Window realized.
 
src/adm2/custom/containrcustom.i is typically a good place to do that.
 
Any I trust that you have a local copy of the ADM2 source code in your application anyway!
Von: PeterWokke [mailto:bounce-PeterWokke@community.progress.com]
Gesendet: Donnerstag, 11. September 2014 08:38
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] Embedding .Net form in Progress window
 
Reply by PeterWokke

The GUI for .NET docs are explaining how to add a window to MDIChildForm into a MDI container.

And to embed the window into a Window container and set the parent to the form.

In the example they use CREATE WINDOW hWin.

And add this hWin.

It does not explain how I get my SmartWindow sales/wo_order.w into this.

Do I have to start it persistent set to get the window handle and forward that into the Window Container?

Or is there an other way to set a window handle to sales/wo_order.w

Kind regards,

Peter Wokke

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by PeterWokke on 11-Sep-2014 02:33

Hi Mike,

Only challenge: You need to do this before the ABL Window realized.

This means you have to delay the initializeObject?

I have no clue how to adjust the src/adm2/custom/containrcustom.i  to realize this.

Hope you can help me on this.

Regards,

Peter

Posted by Mike Fechner on 11-Sep-2014 02:38

You don’t need to delay initalizeObject.

When you put the code in containrCustom.i (in the main block of the include) – you are typically executing the code prior to initializeObject.

Posted by PeterWokke on 11-Sep-2014 05:22

Hi Mike ,

In the main of containrCustom.i you should set the following code:

/* create handle to get the Container handle first */

 DEFINE VARIABLE hWindow         AS HANDLE     NO-UNDO.

 {get ContainerHandle hWindow}.

/* Create the form. */

MainForm = NEW Progress.Windows.Form( ).

MainForm:Text = "Embedded Window Sample".

MainForm:Menu = MainMenu.

MainForm:ClientSize = NEW Size(hWindow:WIDTH-PIXELS, hWindow:HEIGHT-PIXELS).

MainForm:FormClosed:Subscribe( "Window_FormClosed" ).

MainForm:Show( ).

/* Create the WindowContainer, embedding the window into it. */

WinContainer = NEW Progress.Windows.WindowContainer( ).

WinContainer:Size = NEW Size( hWindow:WIDTH-PIXELS, hWindow:HEIGHT-PIXELS ).

WinContainer:EmbeddedWindow = hWindow.

WinContainer:Parent = MainForm.

WinContainer:Show( ).

Application:Run(MainForm).

/* Delete the embedded window after the main form closes. */

PROCEDURE Window_FormClosed:

 DEFINE INPUT PARAMETER sender AS System.Object.

 DEFINE INPUT PARAMETER e AS System.EventArgs.

 DELETE WIDGET hWindow.

END PROCEDURE.

Question where do I set the required using settings?

In the definition settings of the this Includefile?

USING System.Windows.Forms.* FROM ASSEMBLY.

USING System.Drawing.* FROM ASSEMBLY.

USING Progress.Windows.* FROM ASSEMBLY.

USING Progress.Util.* FROM ASSEMBLY.

Regards,

Peter

Posted by Mike Fechner on 11-Sep-2014 06:19

“Question where do I set the required using settings?

In the definition settings of the this Includefile?”

 
No – that would be way too late. The USING’s need to be before any DEFINE and executable statements.

The AppBuilder features a new section in the Procedure Settings  dialog for that purpose.

Posted by PeterWokke on 11-Sep-2014 07:16

Hi Mike,

I found the Declarative statements section.

If I set the using statements in this section of the Include file Progress will put it on the proper place when compiling.

Even if the include is set at an other location in the structured procedure.

Thank you kindly

Peter.  

Posted by PeterWokke on 11-Sep-2014 08:04

Hi Mike and Tom,

I am running to another question.

Container is also creating visual objects like frames and browsers.

The embedding should only be done on containers of type WINDOW.

The embedding should be done conditional if I am correct?

if hContainerHandle:type = "WINDOW":U  then do:

end.

Are there other container type that could be embedded too?

Regards,

Peter

Posted by Mike Fechner on 11-Sep-2014 11:28

Rather than using the runtime checks, there are also preprocessor variables generated by the AppServer, so that this can become a compile time check.

“Are there other container type that could be embedded too?”

According to the Progress docs, only Windows can be embedded.
 
In the WinKit, we’d also embed SmartFrames, SmartViewers or SmartBrowsers separately, so that we can replace the ugly grey Progress TabFolder with a shiny .NET one.
 
But you need very good understanding about how the screen initialization in the ADM2 works as you’d have to customize a lot of that. This is how it may look when you’re done:

http://www.consultingwerk.de/showpic.php?file=uploads%2Fpics%2FOrder_Maintenance_Redesigned.png&width=800m&height=600m&bodyTag=%3Cbody%20bgcolor%3D%22black%22%3E&wrap=%3Ca%20href%3D%22javascript%3Aclose%28%29%3B%22%3E%20%7C%20%3C%2Fa%3E&md5=641643f5246f9433d4a0be956a18266b

 

Posted by PeterWokke on 12-Sep-2014 02:50

Hi Mike,

You refer to implement it within a pre-compile block like this.

&IF "{&ADM-CONTAINER}":U NE "":U &THEN

    &IF "{&ADM-CONTAINER}":U = "WINDOW":U &THEN

     /* implement the embeding over here */

    &ENDIF

&ENDIF

Thanks Peter

Posted by PeterWokke on 12-Sep-2014 03:00

Mike,

For embed SmartFrames, SmartViewers or SmartBrowsers you have to deal with the reposition en resize object procedures to get the .Net form at the proper location and size within the window where they are placed. That is what you main that needs to be customized.

Regards,

Peter

Posted by tbergman on 12-Sep-2014 05:36

After embedding one of our GUI windows in a window container I lost, as expected, the menu bar and menu items. I'm wondering if anyone has a utility to convert an ABL menu into the .Net equivalent? It's a rather large menu and any head start on converting would make life much easier. Thanks, Tom

Posted by jmls on 12-Sep-2014 05:41

there was something on the old communities site - I know, because I
wrote it ;) It took an menu bar handle and created a .net menu from
it.

I'll see if I can find it.

Julian


On 12 September 2014 11:37, tbergman
wrote:
> RE: Embedding .Net form in Progress window
> Reply by tbergman
> After embedding one of our GUI windows in a window container I lost, as
> expected, the menu bar and menu items. I'm wondering if anyone has a utility
> to convert an ABL menu into the .Net equivalent? It's a rather large menu
> and any head start on converting would make life much easier. Thanks, Tom
> Stop receiving emails on this subject.
>
> Flag this post as spam/abuse.



--
Julian Lyndon-Smith
IT Director,
dot.r
http://www.dotr.com

Posted by tbergman on 12-Sep-2014 09:11

Hi Julian,

If you can find this it will be greatly appreciated.

Thanks,

Tom

Posted by RWEBSTER on 12-Sep-2014 10:19

Fairly sure this is the thread?

community.progress.com/.../1603.aspx

(Well, it's *a* thread in which Julian creates .Net Ultra menus from and existing window.)

Posted by Peter Judge on 12-Sep-2014 11:55

There's also this community.progress.com/.../1194.adding-an-abl-wrapper-to-a-net-control.aspx  where I demo creating a Ultra menu from code/dynamically. Assuming you know  how to read a ABL menu, it shouldn't be too hard to convert. There's a FetchData() method in the MyToolbarsManager which populates a set of temp-tables, which you should be able to populate.

-- peter

Posted by Mike Fechner on 12-Sep-2014 15:27

It depends on what you need. In the WinKit we don’t just relocate the Smart Frames, Viewers and Browsers.
 
We reparent them so that they become a true parent of the .NET TabFolder pages.
Von: PeterWokke [mailto:bounce-PeterWokke@community.progress.com]
Gesendet: Freitag, 12. September 2014 10:01
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] Embedding .Net form in Progress window
 
Reply by PeterWokke

Mike,

For embed SmartFrames, SmartViewers or SmartBrowsers you have to deal with the reposition en resize object procedures to get the .Net form at the proper location and size within the window where they are placed. That is what you main that needs to be customized.

Regards,

Peter

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by thomas.rothlisberger on 20-Oct-2014 18:31

I have another question on embedding windows. I am using an mdicontainer as the main window and embed .net forms into the mdicontainer. I noticed that the close button (X) is at the far right. Is there a way the have this button next to the name of the form.

Regards

Thomas

Posted by thomas.rothlisberger on 20-Oct-2014 21:29

In regards to my previous question, I have figured out that it is a property of the ultra tabbed mdi manager that I am using. there is a property called ultraTabbedMdiManager.TabGroupSettings.CloseButtonLocation that can be set to 'Tab'. However it doesn't seem to get the close button inside the tab. Any idea what else needs to be set.

Regards

Thomas

This thread is closed