Regarding Windows

Question:

When I click the mouse outside the area of my floating window, the runtime doesn't return any event to my program. Why?

Answer:

This is normal behavior under Windows. Windows delivers the mouse message to the top-most window in which the mouse is located. If the mouse isn't clicked within the floating window, it never receives any indication that a mouse event occurred. The only way to receive such events is to capture the mouse, but that prevents the mouse from being used by any other application. Ordinarily, the mouse should be captured only when the user is marking or dragging some object on the screen.

Question:

How can I trap the CMD-CLOSE event when the user closes the application by selecting the Close option of the System Menu? I need to be able to close files and perform an orderly shutdown.

Answer:

Look at the QUIT-MODE runtime configuration variable. QUIT_MODE allows you to handle this event in a program-defined way, or in a variety of pre-defined ways.

Question:

I don't see any references to Dialog Boxes. How do I build one?

Answer:

Under ACUCOBOL-GT, a Dialog Box is simply a floating window. You can specify many options when creating the window, but the basic Dialog Box is declared with:

DISPLAY FLOATING WINDOW,
   LINES height, SIZE width,
   BOXED, HANDLE IN handle-data-item

Common additions include a TITLE and SYSTEM MENU. You can then populate the Dialog Box with DISPLAY control-type statements. Or a better alternative is to define a Screen Section group item that describes all the Dialog Box contents and then just DISPLAY that group item.

Question:

Which of the Windows Common Dialog Boxes can I create directly from ACUCOBOL-GT?

Answer:

Five are available via ACUCOBOL-GT library routines. The ChooseColor dialog box can be found in W$PALETTE. The PrintDialog setup box is available in WIN$PRINTER. The file Open and Save-as dialog boxes are available in C$OPENSAVEBOX. W$FONT has the ChooseFont dialog box. Other Windows Common Dialogs are not directly available, though they can be accessed indirectly through C.

Question:

How do I handle a dialog box that doesn't have any entry fields, for example a dialog box with only push buttons?

Answer:

All controls are handled in the same general fashion. This means that you can ACCEPT a push button just as you do an entry field. Push buttons are a little strange in that they don't have values, but they do provide a termination value, just as regular fields. The following is sample code for a simple dialog box that prompts for verification before terminating the application. The line and column numbers may need to be adjusted to improve appearance.

*Screen section
01 shutdown-screen.
   03 label  "This will end your application",
      line 2, column 3.
   03 push-button, ok-button, line 4, column 10.
   03 push-button, cancel-button, column 20.
*Procedure Division
display floating window,
   size 30, lines 5, 
   title "Application Shutdown",
   handle in shutdown-window.
display shutdown-screen.
perform, with test after,
      until key-status = 13 or 27
   accept shutdown-screen
     on exception key-status continue end-accept
end perform.
destroy shutdown-window.
if key-status = 13
   perform shutdown-windows.

Question:

I'd like to minimize my COBOL application when I switch tasks, but a child window is open, and I can't access the minimize button of the main application window. Why?

Answer:

The child window is a modal window. As long as a modal window is open, you cannot get to any other application window. To minimize the application, you must first close all child windows.

If the current window were a modeless window, you could switch to a different window without closing the first one. ACUCOBOL-GT Version 3.2 and later supports the creation of modeless windows.

Question:

I want to create a toolbar large enough to host bitmap buttons that are 36 pixels square. How do I do that?

Answer:

All you need to do to is to create a toolbar window that is tall enough to handle 36 pixels (or any height you want). When you create the bitmap buttons, be sure to specify the exact size of your buttons. For example, to handle 36-pixel square bitmap buttons, try creating a toolbar four lines high. Remember, you can use fractional line values to create a toolbar that is exactly the height you want. See Procedure Division Statements and Bitmap Buttons for more information about toolbars and bitmap buttons.