How does MF INVOKE interface with windows?

Hi,

I'm using MF Dialog ListView control in windows 10 visual cobol 2.3.2. Through intelligent guesswork I've added: INVOKE my-listview-item-objref  "centered"  to the MF generated listview prog i.e. to centre a col rather than justify R/L. I'm enjoying getting to grips with objects and have some questions... 

1. Does MF invoke literally pass the message, "centered" to the object, or is some kind of translation going on?

2. Is there a list somewhere of other listview attributes I can change? And is this list somehow restricted/controlled by MF or do I have direct access to all aspects of the Window's objects? 

3. (Someone else asked this recently)... Is there a good summary somewhere of how windows objects work and how MF programmers can interact with them? My background is strong COBOL but not object oriented programming. I do though have some javascript experience. 

Many thanks,

Linden     

 

  • Verified Answer

    Hi Linden,

    I would strongly recommend that for any new GUI development projects that you should NOT use Dialog System and the native OO Class Libraries.

    We included Dialog System support in Visual COBOL for compatibility purposes for customers migrating from Net Express who had existing applications that used Dialog System.

    We recommend that for any new GUI development work that you instead use managed code templates based on .NET technologies such as Windows Forms (WinForms) or Windows Presentation Foundation (WPF). These use standard class libraries provided by Microsoft as part of the .NET Framework.

    The OO syntax in native COBOL is much harder to use and understand than is the equivalent in managed OO COBOL.

    The GUI Class Libraries in native COBOL are actually written in COBOL so when you are invoking the ListView class you are invoking a method of a COBOL class and not Windows directly. In Net Express these classes were fully covered in the product documentation. In Visual COBOL they are not but we do provide the old Help files from Net Express in the folder C:\Program Files (x86)\Micro Focus\Visual COBOL\help. The name of the file containing this information is nxrclr.chm. The actual source code to the GUI class library can be found in C:\Program Files (x86)\Micro Focus\Visual COBOL\cpylib\guicl.

    Again, I would highly recommend that you do not go down this road and instead take a look at the latest offerings in managed COBOL.

    Thanks.

  • Thank you Chris, that is so very helpful.

    I appreciate what you are saying and if I could easily migrate from Dialog I very gladly would but I'm on a big project with tight deadline. I am moving more and more control to callouts though so that migrating will be easier at some point. Alas though we still have a lot of logic in the native dialog code itself.

    A QUICK QUESTION .... meanwhile I'm trying to use listviews and have pretty much got to grips with i it but I can't see in the MF help nxrclr.chm,  'instance methods' list, a way to change the value of a column header? How can I do that?  

  • I understand your dilemma.

    The column header is added in the AddColumn method. In the example program this occurs in Add-List-Header section.when statement:

       EVALUATE Call-Function

           WHEN "ADD-HEADER"  

                PERFORM Add-List-Header

    is executed

    The code in this paragraph will return a ListViewHeaderItem object which is actually used to set the Header text. Look in the same docs for ListViewHederItem to see what methods it supports.

  • thanks, in my haste i missed the separate pages for listview / item / header.

    HOWEVER... in a quick " SetLabel" method test, I get error "240 obj ref not valid lsthdr" using code below. The justification code works so the obj ref is fine. The Term-field parameter is the one used in the original code above to set the col header in the first place so should also be fine.

                evaluate LVdats2-ITEM-ALIGN(k)

                  when "R"

                      INVOKE LVdats2-item-objref(k) "rightJustified"

                  when "C"

                      INVOKE LVdats2-item-objref(k) "centered"

                  when other    

                      INVOKE LVdats2-item-objref(k) "leftJustified"

                end-evaluate

                invoke LVdats2-item-objref(k) "SetLabel" using Term-Field

  • thanks, in my haste i missed the separate pages for listview / item / header.

    HOWEVER... in a quick " SetLabel" method test, I get error "240 obj ref not valid lsthdr" using code below. The justification code works so the obj ref is fine. The Term-field parameter is the one used in the original code above to set the col header in the first place so should also be fine.

                evaluate LVdats2-ITEM-ALIGN(k)

                  when "R"

                      INVOKE LVdats2-item-objref(k) "rightJustified"

                  when "C"

                      INVOKE LVdats2-item-objref(k) "centered"

                  when other    

                      INVOKE LVdats2-item-objref(k) "leftJustified"

                end-evaluate

                invoke LVdats2-item-objref(k) "SetLabel" using Term-Field

  • Verified Answer

    TERM-FIELD is a pic x data-item and the setLabel property is expecting an object. Create a CharArray object from your string and then pass the object in and it should work.

  • Hi again Chris,

    With a view to doing more outside of dialog... is it possible to get the object reference of dialog window elements (buttons, text boxes etc)? I would like to use the AbstractWindow class disable/enable methods and move all that logic into programs?

    Thanks,

    Linden