Can I trap a window minimize/maximize event from system menu in upper right?

I need to call a c# user control when a COBOL window is minimized or maximized.  The window action works correctly, but I can't find an event or message that I can trap.

  • I believe you can. You assign an event procedure to the window.
    01 EVENT-STATUS.
    03 EVENT-TYPE PIC X(4) COMP-X.
    03 EVENT-WINDOW-HANDLE USAGE HANDLE OF WINDOW.
    03 EVENT-CONTROL-HANDLE USAGE HANDLE.
    03 EVENT-CONTROL-ID PIC XX COMP-X.
    03 EVENT-DATA-1 USAGE SIGNED-SHORT.
    03 EVENT-DATA-2 USAGE SIGNED-LONG.
    03 EVENT-ACTION PIC X COMP-X.

    When an event occurs, you can obtain the value of event-action. That should contain:
    78 ACTION-MINIMIZE VALUE 20.
    78 ACTION-MAXIMIZE VALUE 21.
    78 ACTION-RESTORE VALUE 22.
    Based on the value, you then call your C# routine.
  • I had looked at all this in the documentation, but couldn't figure out how to make it work together. It didn't work as you suggested, but it worked well enough that I could get it done.

    There was already an event procedure assigned to the window, but it was hiding in a CPY file. I checked EVENT-ACTION and its value was zero. So I checked EVENT-TYPE, and its value was 4114 (NTF-RESIZED), which means that EVENT-DATA-1 and EVENT-DATA-2 contained the new height and width of the window. I'd already written a call to C# for when the user manually resizes the window by dragging, which also generates a NTF-RESIZED event. So with the window dimensions, I don't need to separately handle minimize/maximize/restore. I just need to pass the dimensions to C#, where I can resize the user control to the new size available in the COBOL window.

    Shjerpe, thank you for the nudge in the right direction. It would be interesting to know how the ACTIONs could work as you suggested. It may help someone in the future.
  • I believe these action values refer to the ACTION keyword in the DISPLAY/MODIFY verbs for the windows. You can programatically do these 3 actions using these values, but they are NOT events.
  • Yes, Robert is correct. There are four window events available to your progam, CMD-CLOSE, CMD-ACTIVATE, NTF-RESIZED, and NTF-CLOSE. See the documentation here for details:

    documentation.microfocus.com/.../BKININEVENIN6.2.html