Absent Member.
Absent Member.
1490 views

How to get a dialog object's object-reference?

Jump to solution

Hi,

How can I get the MF Dialog push-button object-reference so that i can disable the button from a Visual COBOL program?

e.g. in the program:

INVOKE my-button-objref "disable" 

Dialog lets me define objref fields in the datablock but only has functions, MOVE-OBJECT-ID and MOVE-OBJECT-HANDLE which are different things?

The invoke disable itself works - i tested it by changing the code in a listview prog where it sets focus to the next object in a callback after tab key is pressed. I changed 'setFocus' to 'disable' and it worked fine.

Thanks,

Linden 

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
1 Solution

Accepted Solutions
Absent Member.
Absent Member.

That's correct it is a handle at the OS level.

It would be constant during that GUI's Controls lifetime. You can use CALLOUTs or RETC as mechanisms for going to app logic in COBOL.

See CUSTVOC supplied with product for an example on using vocabularies as mentioned by Andrés.

View solution in original post

0 Likes
9 Replies
Absent Member.
Absent Member.

I would NOT mix Dialog System and Visual Cobol!

This guarantees problems ...

In what I have tested to at least ...

AciveX / OLE / Custom Controls ...

Best Regards

Bernd Riemke

0 Likes
Absent Member.
Absent Member.

Well thanks for responding Bernd but for now I'm stuck with a dialog visual cobol project and I'm not about to redevelop years of work! (wish i could get rid of dialog tbh but don't have enough time)

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
Absent Member.
Absent Member.

Hi Linden,

What you can do is something like:-

BUTTON-SELECTED

    MOVE-OBJECT-HANDLE PB2 MAINHWIN

    CALLOUT "DISABLEEXITBUTTON" 0 $NULL

in your dialog. Then in the COBOL code:-

          invoke button "fromHandle" using mainhwin

              returning ws-button

          invoke ws-button "disable"

          invoke ws-button "destroyproxy" returning ws-button

You create an instance of the button from the Windows handle and then when finished with the object you issue a destroyproxy when finalizes the instance of the button but not the underlying GUI object.

Regards

David

0 Likes
Absent Member.
Absent Member.

Thank you David. Could you explain something for me as I'm rather confused! (I have limited knowledge of object programming as is apparent)...

(1) does MOVE-OBJECT-HANDLE move the window handle or the object handle (the dialog help says object)? When I was working with this previously it seemed to be the window handle?

(2) if window then how does invoke button know which button to create the button proxy for (and hence which object-ref to return in ws-button)?

(3) the help for the button class doesn't mention fromHandle or disable as methods in the docs here... "C:\Program Files (x86)\Micro Focus\Visual COBOL\help\nxrclr.chm"

- is there a full list somewhere of all the messages i can send to the objects?

(4) I'm looking to control all objects in this way e.g. entry fields, check boxes, buttons etc - presumably the setFocus, disable, enable etc methods apply to all the object types?

OVERALL  I WANT TO... put the handle for each object into a handle store in the data-block in my WINDOW-CREATED dialog so that I can control everything from a program. Dialog conditional processing is very limited and i want to debug more easily in visual cobol.

Thanks in advance,

Linden  

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
Absent Member.
Absent Member.

Hi Linden,

MOVE-OBJECT-HANDLE will give you the Windows handle (HWND) to the object you specify.  It may be confusing but at the API level you will get a Windows handle to a Button. When I refer to a Windows handle (HWND) it is NOT the handle to the containing Window.

Remember "Inheritance" in an Object Programming environment. So......

button ----- > inherits from  (referred to as superclass in docs)

    gadget -----> inherits from

           AbstractWindow ------> Inherits from

                   Guibase

If you look in docs for Guibase in the "Class Methods" you should find "fromHandle".

"disable" is documented under "AbstractWindow":-

----

Makes this object insensitive to mouse and keyboard events. Some controls change in appearance when disabled.

---

Unfortunately there is a steep learning curve but you do start to get used to it quite quickly.

Regards

David

0 Likes
Absent Member.
Absent Member.

Hi lindenr,

first you must to set the compiler directive: $SET mfoo

and it's simple by adding the following copy files to your program before the IDENTIFICATION DIVISION:

      COPY "dslang.cpy".

      COPY "cblproto.cpy".

and in the WORKING-STORAGE SECTION add the copy generated by your Dialog System (File -> Generate -> Vocabulary Copy Book)

      copy "[screenset-name].cpy".

then you can do almost everything you do in a Dialog System:

like:

ENABLE-OBJECT

DISABLE-OBJECT

INVOKE-MESSAGE-BOX

REFRESH-OBJECT

CLEAR-OBJECT

and so on.

I hope this help you.

regards,

Andrés Mauricio Heredia G.
Software Engineer
EMA HOLDINGS S.A.S
Cali - Colombia

0 Likes
Absent Member.
Absent Member.

Hi David and Andrés,

Thank you so much, really appreciate all this help.

OK David I think you're saying Window's handle as in it belongs to the win op system? And it's a window's handle for the button itself?

Can you just confirm it should be OK to save all the object handles in eg ABC-WIN dialog's WINDOW-CREATED and that they remain constant until ABC-WIN is deleted? i.e. I can use callouts to my heart's content to control everything!?

Thanks again,

Linden

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
Absent Member.
Absent Member.

That's correct it is a handle at the OS level.

It would be constant during that GUI's Controls lifetime. You can use CALLOUTs or RETC as mechanisms for going to app logic in COBOL.

See CUSTVOC supplied with product for an example on using vocabularies as mentioned by Andrés.

View solution in original post

0 Likes
Absent Member.
Absent Member.

GREAT, THANK YOU - my button disable test is now working.

All the best,

Linden

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.