Hey All,
The test below works for me in Windows 98, but apparently doesn't work in
Windows XP. Does anyone know how to hide/show all open windows?
Thanks in advance,
Ron
I'm using VB5.
Printable View
Hey All,
The test below works for me in Windows 98, but apparently doesn't work in
Windows XP. Does anyone know how to hide/show all open windows?
Thanks in advance,
Ron
I'm using VB5.
not sure if this will help u.. but here is how u restore the showdesktop shortcut...
If the Show Desktop icon is deleted from Quick Launch, the procedure below will recreate the file.
Open Notepad and enter the following text:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
Save the new file as Show Desktop.scf then drag and drop the icon on the Quick Launch bar or whatever location you want the shortcut to appear.
no...it doesn't help..........thanks anyway :)
well y not create the file.. and shell it?
Shell app.path & "\show desctop.scf"
might work?
are you trying to minimize the windows? or actually hide them ? are the windows parts of your application?
How about using my codebank example?
http://www.vbforums.com/showthread.php?t=360571
Sorry, I guess I didn't explain it very well...
Let's say I have Eudora, Office, Notepad, and a couple of Internet Explorer
windows open. I'm trying to hide them with a click of a button, and then
show them again clicking another button.
In the code I posted above, the minimize works in XP, but the hide does not.
Any ideas?
You could try my CWindows class ... :)
VB Code:
Dim windows As CWindows, window As CWindow windows.GetWindows For Each window In windows window.Hide Next
Downloadable from here :)
thanks penagate...but I get a syntax error on line 79
VB Code:
Public Property Get HWNDs() As Long()
I'm using VB5
This doesn't do the trick but it will not show any programs in the bottom, but people can still open them by using ALT+Tab.
In your module, make the following changes.
VB Code:
Public Function HideProgramsShowingInTaskBar() Dim FindClass As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") FindClass2& = FindWindowEx(FindClass&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "MSTaskSwWClass", vbNullString) Handle& = FindWindowEx(Parent&, 0, "[B]ToolbarWindow32[/B]", vbNullString) ShowWindow Handle&, 0 End Function Public Function ShowProgramsShowingInTaskBar() Dim FindClass As Long, FindClass2 As Long, Parent As Long, Handle As Long FindClass& = FindWindow("Shell_TrayWnd", "") FindClass2& = FindWindowEx(FindClass&, 0, "ReBarWindow32", vbNullString) Parent& = FindWindowEx(FindClass2&, 0, "MSTaskSwWClass", vbNullString) Handle& = FindWindowEx(Parent&, 0, "[B]ToolbarWindow32[/B]", vbNullString) ShowWindow Handle&, 1 End Function
I accept no responsibility for any damage any code i provide causes to you or to your possessions.
thanks andrew........but in win98 it shows the programs in the taskbar like the
original code did in xp.
Ah, so you want it to work for any version of windows. No probs
VB Code:
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type Private Sub Form_Load() Dim OSInfo As OSVERSIONINFO, PId As String OSInfo.dwOSVersionInfoSize = Len(OSInfo) Ret& = GetVersionEx(OSInfo) If OSInfo.dwPlatformId = 2 Then 'Win NT or XP End If End Sub
or
Is a bit more accurateVB Code:
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Long Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type Private Enum Enum_OperatingPlatform Platform_Windows_32 = 0 Platform_Windows_95_98_ME = 1 Platform_Windows_NT_2K_XP = 2 End Enum Private Enum Enum_OperatingSystem System_Windows_32 = 0 System_Windows_95 = 1 System_Windows_98 = 2 System_Windows_ME = 3 System_Windows_NT = 4 System_Windows_2K = 5 System_Windows_XP = 6 End Enum Private Sub Form_Load() Select Case OperatingSystem Case System_Windows_32: msgbox "Windows 32" Case System_Windows_95: msgbox "Windows 95" Case System_Windows_98: msgbox "Windows 98" Case System_Windows_ME: msgbox "Windows ME" Case System_Windows_NT: msgbox "Windows NT" Case System_Windows_2K: msgbox "Windows 2K" Case System_Windows_XP: msgbox "Windows XP" End Select End Sub Private Function OperatingSystem() As Enum_OperatingSystem Dim lpVersionInformation As OSVERSIONINFO lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation) Call GetVersionExA(lpVersionInformation) If (lpVersionInformation.dwPlatformId = Platform_Windows_32) Then OperatingSystem = System_Windows_32 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 0) Then OperatingSystem = System_Windows_95 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 10) Then OperatingSystem = System_Windows_98 ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME) And (lpVersionInformation.dwMinorVersion = 90) Then OperatingSystem = System_Windows_ME ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion < 5) Then OperatingSystem = System_Windows_NT ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 0) Then OperatingSystem = System_Windows_2K ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP) And (lpVersionInformation.dwMajorVersion = 5) And (lpVersionInformation.dwMinorVersion = 1) Then OperatingSystem = System_Windows_XP End If End Function
Gets the version of windows. In you code, you need to set a public bolean to check if its XP, and if it is then use the code i modified, if it isn't then use the original code.
Here is some code I use to hide/show all IE windows.
VB Code:
Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal _ lpsz2 As String) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Function HideAllIEWindows() Dim l As Long l = FindWindow("IEFrame", vbNullString) If l <> 0 Then ShowWindow l, 0 End If Do Until l = 0 l = FindWindowEx(0, l, "IEFrame", vbNullString) If l <> 0 Then ShowWindow l, 0 End If Loop End Function Private Function ShowAllIEWindows() Dim l As Long l = FindWindow("IEFrame", vbNullString) If l <> 0 Then ShowWindow l, 1 End If Do Until l = 0 l = FindWindowEx(0, l, "IEFrame", vbNullString) If l <> 0 Then ShowWindow l, 1 End If Loop End Function Private Sub Command1_Click() Call HideAllIEWindows End Sub Private Sub Command2_Click() Call ShowAllIEWindows End Sub
Is there some way to loop through all open programs and get the name
of each program, and replace the "IEFrame" each time it loops?
hey andrew, I appreciate the help, but I wish I could find a way to do this
like the code I just posted (cannot be seen with alt + tab).
Hey... I just found this in a search at VB Helper
VB Code:
Option Explicit Private Declare Function GetTopWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Const GW_HWNDFIRST = 0 Private Const GW_HWNDNEXT = 2 Private Const GWL_STYLE = (-16) Private Const GWL_HWNDPARENT = (-8) Private Const WS_OVERLAPPED = &H0& Private Const WS_BORDER = &H800000 Private Const WS_DLGFRAME = &H400000 Private Const WS_CAPTION = WS_BORDER Or WS_DLGFRAME Private Const WS_SYSMENU = &H80000 Private Const WS_THICKFRAME = &H40000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) ' Return information about this window. Private Sub GetWindowInfo(ByVal app_hwnd As Long, ByRef app_parent As Long, ByRef app_owner As Long, ByRef app_visible As Boolean, ByRef app_style As Long, ByRef app_text As String, ByRef app_class As String) Const MAX_LENGTH = 1024 Dim buf As String * MAX_LENGTH Dim length As Long app_parent = GetParent(app_hwnd) app_owner = GetWindowLong(app_hwnd, GWL_HWNDPARENT) app_visible = IsWindowVisible(app_hwnd) app_style = GetWindowLong(app_hwnd, GWL_STYLE) length = GetWindowText(app_hwnd, buf, MAX_LENGTH) app_text = Left$(buf, length) length = GetClassName(app_hwnd, buf, MAX_LENGTH) app_class = Left$(buf, length) End Sub Private Sub Form_Load() Dim app_hwnd As Long Dim app_parent As Long Dim app_owner As Long Dim app_visible As Boolean Dim app_style As Long Dim app_text As String Dim app_class As String Dim wid As Single Dim col_wid() As Single Dim r As Integer Dim c As Integer MSFlexGrid1.FixedRows = 1 MSFlexGrid1.FixedCols = 0 MSFlexGrid1.Rows = 1 MSFlexGrid1.Cols = 3 MSFlexGrid1.TextMatrix(0, 0) = "hWnd" MSFlexGrid1.TextMatrix(0, 1) = "Text" MSFlexGrid1.TextMatrix(0, 2) = "Class" GetWindowInfo app_hwnd, app_parent, app_owner, _ app_visible, app_style, app_text, app_class app_hwnd = GetTopWindow(0) r = 1 Do While app_hwnd <> 0 ' Get information about this window. GetWindowInfo app_hwnd, app_parent, app_owner, _ app_visible, app_style, app_text, app_class ' See if this window is interesting. If app_visible And _ app_parent = 0 And _ app_owner = 0 And _ Len(app_text) > 0 And _ Left$(app_text, 8) <> "VBBubble" And _ (Left$(app_class, 7) <> "Progman" Or _ (app_style And WS_OVERLAPPEDWINDOW) <> 0) _ Then MSFlexGrid1.Rows = r + 1 MSFlexGrid1.TextMatrix(r, 0) = app_hwnd MSFlexGrid1.TextMatrix(r, 1) = app_text MSFlexGrid1.TextMatrix(r, 2) = app_class r = r + 1 End If app_hwnd = GetNextWindow(app_hwnd, GW_HWNDNEXT) Loop ' Size the columns. ReDim col_wid(0 To MSFlexGrid1.Cols - 1) For r = 0 To MSFlexGrid1.Rows - 1 For c = 0 To MSFlexGrid1.Cols - 1 wid = TextWidth(MSFlexGrid1.TextMatrix(r, c)) + 240 If col_wid(c) < wid Then col_wid(c) = wid Next c Next r For c = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.ColWidth(c) = col_wid(c) Next c End Sub Private Sub Form_Resize() MSFlexGrid1.Move 0, 0, ScaleWidth, ScaleHeight End Sub
Now, this works well in Win98. Could someone would check to see if this works
in XP?
If it does, then I still would have to figure out how to use a Listbox
instead of a MSFlexGrid, and then implement it into the "IEFrame" code (loop)
above.
Am I even making any sense...my little pea brain is tired! thanks guys
Delete that property routine then. The ability to return an array from a function was introduced in VB6.Quote:
Originally Posted by rdcody
Hey fellers...I may have figured it out...try this please :)
works in win98
lol once again theres a MUCH easier way to do itQuote:
Originally Posted by RobDog888
add in a ms shell and automation control and put thise code
VB Code:
dim b as new shell b.MinimizeAll
Yes, I remembered that but couldnt remember exactly where or how. :(