Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
gjmills10 Absent Member.
Absent Member.
1034 views

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.

0 Likes
4 Replies
Micro Focus Expert
Micro Focus Expert

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

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.
0 Likes
gjmills10 Absent Member.
Absent Member.

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

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.
0 Likes
RobertRedekop Trusted Contributor.
Trusted Contributor.

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

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.
0 Likes
DougP Outstanding Contributor.
Outstanding Contributor.

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

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
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.