Highlighted
Absent Member.
Absent Member.
878 views

[archive] Centering a floating window/subclassing.

[Migrated content. Thread originally posted on 13 May 2003]

Hello,
I am trying to center a floating window (display floating window...) over the main window even if it is not opened from the main window. The problem is that I have some dialogs and other programs that open themselves relative to the main window. This usually works ok, but (as the documentation says) when I pop up a floating window all newly created floating windows open up relative to the pop up window.

The upon phrase of the display floating window command does not appear to work (5.2.1) as documented. The set output window to ... also does not work, and I am assuming this is becuase my pop up windows are modal.

To get around this and some other problems with the runtime I have subclassed the runtime so I can execute win32 api commands. However, the handles that are returned from the display window command (display window handle is...) are not actual handles. Is it possible to convert them to a real handle? This would provide q quick and permanent solution to most of my problems (I have access to the main application window handle only).

What happens is:
main window opens window1 at line 10...ok!
window1 opens dialog at line 10...not ok! I want to open dialog relative to main window, not window1!


Thanks in advance,
Merlin
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Centering a floating window/subclassing.

Silly me, I attempted a complex solution (sublassing) for a simple problem ( centering ). I found out how to center a floating window a much simpler way. Here it is for anyone interested (code centers floating window over window that opens it) :

in working storage:

01 Parent-Lines unsigned-int.
01 Parent-Cols unsigned-int.
78 Window-Size-X value xxx. | insert value here
78 Window-Size-Y value yyy. | ditto
01 Display-Line signed-int.
01 Display-Col signed-int.

where you open the window:

inquire window lines in Parent-Lines.
inquire window size in Parent-Cols.
compute Display-Line = (Parent-Lines - Window-Size-Y) / 2.
compute Display-Col = (Parent-Cols - Window-Size-X) / 2.

display floating window
line Display-Line
pos Display-Col
size Window-Size-X
lines Window-Size-Y
...


Note to the forum maintainers, I would still like to resolve an actual handle from a handle returned from a display floating window statement! 🙂

Merlin
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Centering a floating window/subclassing.

Here is how to retrieve a windows handle for use in a non cobol application. The confusion comes because of the following:

01 my-handle handle.
display floating window
handle in my-handle.


this works instead:

01 my-handle unsigned-int.
display floating window.
inquire window system handle in my-handle.
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.