Visible to Intel only — GUID: GUID-03979431-F725-4BF6-8430-0476266F3CC2
Visible to Intel only — GUID: GUID-03979431-F725-4BF6-8430-0476266F3CC2
Using Menus and Dialogs in SDI and MDI Fortran Windowing Applications
This section describes the following topics:
Creating the Menu
When you create a new SDI or MDI application, a default menu bar is created for you. The default menu bar contains many of the menu entries that are common to Windows applications. You can modify the default menu, or create a new menu, by using the Menu Editor, which is one of the Visual Studio Resource Editors. The Resource Editor is not available with the Visual Studio Shell.
To create a new menu resource (menu bar):
From the Insert menu, select Resource.
Select Menu as the resource type.
The menu bar consists of multiple menu names, where each menu name contains one or more items. You can use the Menu Editor to create submenus (select the pop-up property).
To edit an existing menu:
Double-click on the project .RC file.
Expand the Menu item in the list of resource types.
Double click on the menu name.
For more information about the menu resource editor, see the Visual C++ User's Guide section on Resource Editors.
Using the Menu
To use a menu bar in your Fortran application, you must load the menu resource and use it when creating the main window of the application. Code to do this is created automatically by the Fortran Windowing AppWizard. The code that loads the menu resource is:
ghMenu = LoadMenu(hInstance, LOC(lpszMenuName))
The returned menu handle is then used in the call to CreatWindowEx:
ghwndMain = CreateWindowEx( 0, lpszClassName, & lpszAppName, & INT(WS_OVERLAPPEDWINDOW), & CW_USEDEFAULT, & 0, & CW_USEDEFAULT, & 0, & NULL, & ghMenu, & hInstance, & NULL & )
Handling Menu Messages
Windows sends a WM_COMMAND message to the main window when the user selects an item from the menu. The wParam parameter to the WM_COMMAND message contains:
The low-order word specifies the identifier of the menu item
The high-order word specifies either 0 if the message is from a menu item, or 1 if the message is the result of an accelerator key. It is usually not important to distinguish between these two cases, but you must be careful to compare against only the low-order word as in the example below.
For example, the following code from the main window procedure generated by the Fortran Windowing AppWizard handles the WM_COMMAND messages from the File menu Exit item and the Help menu About item:
! WM_COMMAND: user command case (WM_COMMAND) select case ( IAND(wParam, 16#ffff ) ) case (IDM_EXIT) ret = SendMessage( hWnd, WM_CLOSE, 0, 0 ) MainWndProc = 0 return case (IDM_ABOUT) lpszName = "AboutDlg"C ret = DialogBoxParam(ghInstance,LOC(lpszName),hWnd,& LOC(AboutDlgProc), 0) MainWndProc = 0 return ...
For advanced techniques with using menus, refer to the online Platform SDK section on User Interface Services.
Using Dialogs in an SDI or MDI Application
A Fortran Windowing SDI or MDI application that uses dialogs has the choice of using:
Intel Visual Fortran Dialog routines
native Windows APIs for creating dialog boxes
For any particular dialog box, you should use either the Intel Visual Fortran Dialog routines or the native Windows dialog box APIs. For example, if you create a dialog box using Windows APIs, you cannot use the Intel Visual Fortran dialog routines to work with that dialog box.
You should note, for example, that the code generated by the Fortran Windows AppWizard uses the native Windows APIs to display the About dialog box.
For more information:
On using the Intel Visual Fortran Dialog routines, see Using Dialog Boxes for Application Controls Overview
On using the Windows APIs, see the online Platform SDK section on User Interface Services