Skip to Content

How to detect if a computer has more than one monitor and use any of them?

Estimated Reading Time: 1 Minutes

These days you often find end users to have more than one monitor for one reason or another.

If you need your application to leverage all the monitor space available on many monitors instead of just crunching all the windows on a single default monitor you may use the C$MONITOR library routine.

One of the main usages of that library routine is to tell you how many monitors your application has available to use.

    CALL "C$MONITOR" USING CMONITOR-GET-NO-MONITOR
                           monitorCount
                          [mainMonitor]
                    GIVING returnCode

Then your display window statements may indicate on which monitor you want to create that window.

    display standard window background-low
            screen line 41
            screen column 91
            screen-index ws-scr-index
            ...
            title "Screen"
            handle window-handle
            .

Furthermore, you may get detailed information of the monitor you want to use, in order to know the size of it to position your window on a specific place for instance.


    CALL "C$MONITOR" USING CMONITOR-GET-MONITOR-INFO
                           monitorIndex
                           CMONITOR-DATA
                    GIVING returnCode

Furthermore, you may get detailed information of the monitor you want to use, in order to know the size of it to position your window on a specific place for instance.

You may download the following sample program that demonstrates both functions of the C$MONITOR library routine.
Compile it like this:

   iscc -sp="%iscobol%sampleisdef" monitortest.cbl
Run it like this:
   iscrun MONITORTEST
How to detect if a computer has more than one monitor and use any of them?
  • Attached Files
  • monitortest.cbl (5.09 KB) 10