HANDLE = HANDLE? - Progress vs .NET - in OEArchitect 10.2A

Posted by StefanFromGermany on 30-Oct-2012 01:48

Hello,

I'm new here...

I tried to handle .NET controls.

I know, that one can use "Controls:Item[iVariable]". But if I use e.g. panel, tabcontrol etc. it will be a couple of controls, that I want to manipulate (FONT or anything else).

Of course, I can cascade like this:

THIS-OBJECT:Controls:Item[iVariable]:Controls:Item[i1Variable]:Controls:Item[i2Variable]:Controls:Item[i3Variable].

Or hardcoding via name of control (e.g. Button3).

My idea was:

Use a TEMP-TABLE to handle every Control, that I want to manipulate...

DEFINE TEMP-TABLE ttControls NO-UNDO

     FIELD hObj AS HANDLE

     FIELD (whatever...)

in a loop that:

ttControls.hObj = Controls:ITEM[i]:Handle.

So I could use this HANDLE to change the FONT-Size, but not for a long time!

As i tried to handle other controls I became an error information:

** Incompatible data types in expression or assignment. (223)

Now my question(s):

Is HANDLE (Progress) not equal to .NET-handle?

Why did it worked one time? (not only "no error", but real function: I've seen the manipulation of FONT-size)

Is there any posibility to handle controls without a chain (cascade) like my first example?

thanks

kind regards

Stefan

My english is not the best, sorry....

All Replies

Posted by Admin on 30-Oct-2012 02:03

You can reference .NET objects in a "Progress.Lang.Object" temp-table column.

Don't get confused with the "Handle" property of .NET Controls. That actually returns the equivalent to the HWND property of Progress widgets.

But there may already be other solutions.... The Container Control has a Controls collection that you can iterate. Rather than a temp-table you might create your own "flat" Dictionary instance.

And for screen scaling based on the dpi value you can use the .NET built in methods (.NET was released 2002, not in the 1980's).

Posted by StefanFromGermany on 30-Oct-2012 09:32

Thank you for fast response.

I do not really understand, because I'm a beginner.

I tried to reference as you wrote:

FIELD hObj AS Progress.Lang.Object

when I want to "fill" the TEMP-TABLE I think I use:

ttControls.hObj = Controls:ITEM[i]:HANDLE.

no error, but error at:

ttControls.hObj:(whatever) -> there seems to be no posibility to manipulate.

I tried:

ttControls.hObj = Controls:ITEM[i]:AccessibilityObject.

same problem...

I think I understood something wrong

You wrote something about "Container Control". I do not really know, how the syntax would be. Some days ago I tried to use ist, because I've seen this at msdn, but failed.

My question is not only about FONT size. It was an example. I want to manipulate many things like position, maybe size, color and so on...

I planned to build an own class, which can manipulate the "frontend" with its controls. So I need to access every control in this form. That was my idea to handle via TEMP-TABLE

If it is possible to handle the whole Form as object in this other class, maybe I could access all the controls with recursion. Then I wouldn't need to handle with TEMP-TABLE.

Sorry, many questions and less knowledge...

I hope, you can help.

If you want, please give me some code snippets with your answer, so that I can understand, how to use it.

thank you very much.

Posted by Admin on 30-Oct-2012 09:38

ttControls.hObj = Controls:ITEM[i]:HANDLE.

 

It's as simple as

ttControl.hObject = Controls:Item[i] .

(otherwise you store a reference to the System.IntPtr which is the Handle and not the reference to the actual control).

ttControls.hObj:(whatever) -> there seems to be no posibility to manipulate.

 

CAST (ttControls.hObj, System.Windows.Forms.TextBox):.

Posted by StefanFromGermany on 31-Oct-2012 01:07

Thank you! That's it!

It works fine...

Later I will test, if it works, when I try to handle the whole FORM in the other CLASS.

Do you believe, that it would do? I think the syntax would be like that:

DEFINE VARIABLE oForm AS Progress.Lang.Object.


oForm = THIS-OBJECT.


CAST (oForm, System.Windows.Forms.):Controls:ITEM[i]: (whatever)

When it works (or not) I will give information, so that other user are informed too.

##############################################################################

     At least I want to say, that this community is very, very good. I'm happy about that!            

                           Thank you all and special thanks to Mike Fechner!

##############################################################################

Best regards

Stefan

Posted by Admin on 31-Oct-2012 01:33

CAST (oForm, System.Windows.Forms.):Controls:ITEM[i]: (whatever)

 

That should just work fine. By the way, you should also be able to drop the Item from the expression as Item is usually the default indexed property of collections:

CAST (oForm, System.Windows.Forms.Form):Controls[i]

And if oForm is already a variable of type System.Windows.Forms.Form then

oForm:Controls[i]

I've noticed that you are on 10.2A. Progress has added generic collection support in 10.2B. If you're starting with GUI for .NET, you should consider upgrading to 10.2B07 or 11.1.00.005

A lot has changed in those releases.

This thread is closed