Question Replacing Treeview OCX with 64 bit .NET Tree View.

nix1016

New Member
Hi All,

This is probably something basic but I just need a hand with starting it off. We used to have a ABL screen with a TreeView OCX used in progress OE 10.1. We have recently upgrade to 11.5 64bit and therefore can no longer use the OCX as there is no 64 bit as far as I'm aware. I'm trying to replace it with a .Net TreeView but I'm not sure where to start.

I've managed to replace the Crystal Viewer successfully but that was mainly due to example codes that were already available in the KB (mainly http://knowledgebase.progress.com/articles/Article/000056268?q=.net+crystal&fs=Search&pn=1&l=en_US). That was also simpler to do because the form only had the crystal viewer on it. The current screen I'm working on has a number of other ABL controls and widgets that needs to remain along with the .Net Tree View. Is this possible to do?

I tried copying what I did for the crystal viewer by doing something like the below:

def var FormObjectRef as class Progress.Windows.Form NO-UNDO.
def var CFTreeView as class System.Windows.Forms.TreeView No-undo.

FormObjectRef = NEW Progress.Windows.Form().
CFTreeView = NEW System.Windows.Forms.TreeView().
FormObjectRef:Controls:Add(CFTreeView).

WAIT-FOR FormObjectRef:ShowDialog().​

This works for displaying it stand-alone but how can I incorporate it into an existing .w file?

Hopefully this makes sense. Thanks in advance!
 

Osborne

Active Member
What you need to do is embed the .w in a .NET form. The following are two basic examples using a class:

http://knowledgebase.progress.com/articles/Article/P145112
http://knowledgebase.progress.com/articles/Article/P190039

If you want the whole thing done in an existing .w then something along these lines:

1) As per the articles, change the Progress window settings to ensure the Progress window has not already been realized by viewing or loading an icon.

2) Define a window container, embed the Progress window to it and parent to your .NET form:
Code:
DEFINE VARIABLE WinContainer AS Progress.Windows.WindowContainer NO-UNDO.

WinContainer = NEW Progress.Windows.WindowContainer().
WinContainer:Size = NEW System.Drawing.Size(C-Win:WIDTH-PIXELS, C-Win:HEIGHT-PIXELS).
WinContainer:EmbeddedWindow = C-Win.
WinContainer:Parent = FormObjectRef.
WinContainer:Show().

3) If you have a button that quits the program then add an extra line to close the .NET form:
Code:
ON CHOOSE OF bClose IN FRAME f1 DO:
   APPLY "CLOSE" TO THIS-PROCEDURE.
   FormObjectRef:Close().
END.

4) Enable the .w as normal:
Code:
RUN enable_UI.
IF NOT THIS-PROCEDURE:PERSISTENT THEN
  /* WAIT-FOR CLOSE OF THIS-PROCEDURE. */ WAIT-FOR FormObjectRef:ShowDialog().
.
 

nix1016

New Member
Thanks for your reply.

The issue I have is that the .w which currently has the OCX is a browse .w file that is embedded into another frame .w which is a complex screen that has multiple folders/tabs calling different files. If I'm to use the .NET treeview, then do I need to embed the browse .w into a new .Net form which is then embedded into the frame .w or is that not possible and I would need to replace the entire frame .w with the .Net form? If the latter then it is probably not feasible as there is just too much to change.

Is there another option that I can go with? I had a look and found Pure4GLTV which is basically a clone of the MS Treeview OCX but it seems that it's built using adm2 and we're currently using adm1 so that doesn't seem feasible.

Also I'm not 100% sure that I can no longer still use the MS Treeview OCX, I simply assumed so after reading this post. However, when I open up the file in 64bit version 11.5 app builder, it gives me the error 'Specified ActiveX control is not registered or the .ocx file was moved from where it was registered'. But I can still see a CTreeview control (C:\windows\system32\dmocx.dll) from the list of OCX controls and once added to my browse .w file, it compiles without any issues. It is only when running, I'm getting errors saying that the methods are not available, i.e. 'Invalid component-handle referenced while processing method/statement:Notes', for a simple call such as chCFTreeView:TreeView:Nodes:Clear.
 

Osborne

Active Member
Is the browse.w file a Progress window, because if so you can embed more than one window to a single .NET form. You just create a window container for each window and parent to the .NET form. If not, and as you can not embed a .NET form on a standard Progress .w, then it seems as the though the main screen will require the .NET form and you embed browse.w as normal. Then a bit of extra workings to pass the .NET treeview control as a parameter to browse.w to allow that program to control it.
 

nix1016

New Member
The browse.w isn't a window container unfortunately, so I think we would have to embed the entire main screen in the .NET form. I think this is too much work to just replace just the treeview control... we'll probably have to have a look at other methods! Thanks for your help!
 
Top