How to Hide a Non-Visual Basic Window or IconLast reviewed: June 21, 1995Article ID: Q88476 |
The following information applies to:
SUMMARYOccasionally, it is desirable to hide a window from a Visual Basic application that is not owned by the Visual Basic application. For example, when using the GRAPH.VBX custom control provided with the Microsoft Professional Toolkit for Visual Basic version 1.0 for Windows and with the Professional Edition of Visual Basic version 2.0 for Windows, an icon appears at the bottom of the screen for the graphics server. This icon represents a program that is a support module for the graph control and so serves no direct purpose for the user. You can hide the icon by issuing two Windows API calls.
MORE INFORMATIONThe FindWindow and ShowWindow Windows APIs can be used to hide a window. FindWindow uses the title on the top of the window to get a handle that can then be used by ShowWindow. ShowWindow can perform several different operations. In this case it makes a window invisible. The following example hides the Graphics Server icon started by the Graph control. You can use this same technique to hide any window currently active in Windows.
Step-by-Step Example1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N)if Visual Basic is already running. Form1 is created by default. Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
Sub Command1_Click() Dim Handle As Integer Dim WindowName As String WindowName = "Graphics Server" Const SW_Hide = 0 Handle = FindWindow(0&, WindowName) X% = ShowWindow(Handle, SW_Hide) End Sub When you choose the Command1 button, the Graphics Server icon becomes invisible.
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |