PDA

Click to See Complete Forum and Search --> : Win 98 destop shortcut for Win 95


JohnKrutsch
Feb 28th, 2001, 12:05 PM
At work my wife has to use Win 95 but at home she has gotten use to Win 98. She asked me to make her a little app that will sit in the system tray that will act like the desktop icon that is in the shortcut part of the status bar in Win 98.

Something that will just bring the desktop forward no matter what else is open.

I tried getting the hwnd of the desktop which works fine. Then I tried to use the SetWindowPos API to set its z order to be on top but it does not work.

Has anyone done this? it seemd like something simple is escapping me.

Any help would be appreciated.

Feb 28th, 2001, 01:37 PM
Why not just minimize everything and that will show the desktop.


To minimize all Windows:

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_COMMAND As Long = &H111
Private Const MIN_ALL As Long = 419
Private Const MIN_ALL_UNDO As Long = 416


Private Sub MinimizeAll()

Dim lngHwnd As Long
lngHwnd = findwindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL, 0&)

End Sub


Usage

MinimizeAll

To restore all:


Private Sub RestoreAll()

Dim lngHwnd As Long
lngHwnd = findwindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)

End Sub

Usage

RestoreAll

And when you minimize all programs, it minimizes your program as well, here is how to restore just your program:

Private Sub Restore(frm As Form)

Dim lngHwnd As Long
lngHwnd = frm.hwnd
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)

End Sub


Usage

Restore Me

Lord Orwell
Mar 1st, 2001, 04:24 AM
The button activates a command built into internet explorer 4.0 and higher. copy the button onto a floppy disk and install it on her desktop. It should work.

matthew, couldn't you just broadcast a minimize to every open window by setting the handle to HWND_BROADCAST?
Public Const HWND_BROADCAST = &HFFFF&
I never tried it, but i thought that this is what it was for.
I thought about using it for something similar. The only problem i could come up with is that it would restore windows that were minimized to start with. You could read the handle of all top-level windows into an array, then run a test on each one to see if it is already minimized. If so, remove it from the first array. Then when you restore, it will only restore windows it has listed in the array.
As a side note, i have win 95 on another machine. I have the "Internet Explorer desktop enhancements" package installed that comes with full versions of internet explorer 4.0 and higher. It gives you active desktop, etc. and the button she wants emulated.

JohnKrutsch
Mar 1st, 2001, 07:44 AM
Thanks guys,

I was able to write a very small app that I put into the startup folder.

It sits in the system tray and it just atlernates between minimize all and minimize all undo upon clicking it.

Thanks again for helping me attack this from a different angle.