Skip to main content

I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

You can do this like:

   attach method self::MyWindowClosed to self::Closed

Or you can select the Closed event on the Window from the Properties page and place the event handler name there.


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

This give me an error back..

attach method self::MyWindowClosed to MyWindow::Closed

MyWindow is a second window that is closed...

After the second window is closed i will do something...


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

This give me an error back..

attach method self::MyWindowClosed to MyWindow::Closed

MyWindow is a second window that is closed...

After the second window is closed i will do something...


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

This is the errorcode:

COBCH852 : System error - unexpected error while generating managed code C:\\\\WPFWindows\\Window1.xaml.cbl 24 1 WPFWindows


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

Sorry, there was a problem with using the attach syntax when the event handler was for an object in a different project.

I was testing using VC 2.2 which will be released soon and has this problem fixed.

Try this syntax instead:

    invoke MyWindow::add_Closed(new EventHandler(self::MyWindowClosed))


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

Ok...

invoke MyWindow::add_Closed(new EventHandler(self::MyWindowClosed))

give me an error that he not founf the method...

Is this a bug in VC 2.1 and is this fixed in VC 2.2 ?

Or how must the method "MyWindowClosed" build?


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

No I tested this with 2.1 update 1 and it works fine.
Here is the example that I am using.

Here is the code for Window 1 which is in a WPF application project:

       class-id WPFWindows1.Window1 is partial
                 inherits type System.Windows.Window.

       working-storage section.
       01 mywindow2 type WPFWindows2.Window2.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent()
           goback.
       end method.

       method-id Window_Closed2.
       procedure division using by value sender as object e as type System.EventArgs.
          set self::txtParam::Text to mywindow2::myfield
       end method.

       method-id Button_Click.
       procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.
           set mywindow2 to new WPFWindows2.Window2
           invoke mywindow2::add_Closed(new EventHandler(self::Window_Closed2))
           *>attach method self::Window_Closed2 to mywindow2::Closed
           invoke mywindow2::Show
       end method.

       end class.

and the code for Windows 2 which is in a WPF library:

       class-id WPFWindows2.Window2 is partial
                 inherits type System.Windows.Window.

       working-storage section.
       01 myfield  string property.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent()
           set self::txtParam::Text to "Enter Name"
           goback.
       end method.

       method-id Button_Click.
       procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.
           set myfield to self::txtParam::Text
           invoke self::Close
       end method.

       end class.

I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

Thats nearly what I Need!

Many thanks Chris!


I have a c# code lite this:

MyWindow.Closed = new EventHandler(MyWindowClosed)

What Code is this in Visual Cobol?

 


#TranslatefomCtovisualcobol

Thats nearly what I Need!

Many thanks Chris!