Handling COMMDLG File Open Network Button Under Win32s

Last reviewed: January 5, 1995
Article ID: Q117825
The information in this article applies to:
  • Microsoft Win32s versions 1.1, 1.15, and 1.2

When you run a Win32-based application under Win32s on top of Windows 3.1 without a network, the File Open common dialog box still has a Network button.

Under Windows NT, the File Open common dialog box that appears when you call GetOpenFileName() has a Network button only when a network is present. The API (application programming interface) will either use the Network button in the dialog box template if it exists or dynamically add the button if it is not in the template and there is a network present. If there is no network present but the template contains a Network button, the button will be hidden.

The dialog box template that is included with the Windows Software Development Kit (SDK) does not have a Network button because Windows does not include a network. When the 16-bit Windows-based application is executed under Windows for Workgroups or under Windows NT, the Network button is dynamically added, because these operating systems have built-in networking.

The template that is included with the Win32 SDK has a Network button. If the Win32-based application is run under a non-networked Windows 3.1, the Network button is shown; however it is nonfunctional because there is no network. This happens because the COMMDLG.DLL that provides Windows 3.1 with the common dialog boxes does not recognize networks. Therefore, GetOpenFileName() does not remove the Network button from the template if there is no network.

One solution is to leave the button in the template, determine when you are running under Win32s, and include OFN_NONETWORKBUTTON in the OPENFILENAME structure when Win32s is present but there is no network present. Define a hook function that during WM_INITDIALOG checks the Flags field of the OPENFILENAME struct that lParam is pointing to. If OFN_NONETWORKBUTTON is used, call ShowWindow(GetDlgItem(hWnd, psh14), SW_HIDE).

Alternatively, if your application will most likely run on networked Windows 3.1 machines, you can install the COMMDLG.DLL that ships with Windows for Workgroups 3.11 on all machines, because it is a redistributable dynamic-link library (DLL). This DLL checks to see if a network is present and removes the Network button for you if it is not.


Additional reference words: 1.10 1.15 1.20
KBCategory: kbprg
KBSubcategory: W32s


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 5, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.