What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » WLM Plus! General » Temporarily remove desktop contacts

Temporarily remove desktop contacts
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Temporarily remove desktop contacts
I took the liberty to fix (it doesn't work) and improve Matty's code.... sorry matty ;) :p


code:
Option Explicit

Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam 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 Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_HIDE = 0
Private Const SW_SHOWNA = 8

' The callback function. This MUST be in a normal module (not a class module)
Private Function CallBack(ByVal hWnd As Long, ByVal lParam As Long) As Long
   Dim lResult As Long
   Dim sClassName As String * 260
   
   lResult = GetClassName(hWnd, sClassName, Len(sClassName))
   If LCase$(Left$(sClassName, lResult)) = "msgplusfloatingwindow" Then
       If lParam Then
           ShowWindow hWnd, SW_SHOWNA
       Else
           ShowWindow hWnd, SW_HIDE
       End If
   End If
   
   CallBack = True
   
End Function


' Two seperate public procedures to show and hide the windows
Public Sub ShowFloatingWindows()
   EnumWindows AddressOf CallBack, True
End Sub
Public Sub HideFloatingWindows()
   EnumWindows AddressOf CallBack, False
End Sub


' Only one public procedure which can do both (with optional parameter)
'    To show windows: FloatingWindowsState True
'    To hide windows: FloatingWindowsState False
'    If the (true/false) parameter is omitted it will also show the windows

Public Sub FloatingWindowsState(Optional State As Boolean = True)
   EnumWindows AddressOf CallBack, State
End Sub


Note 1: as you can see you don't need the two seperate procedures, you can do it with one also. It depends on what you prefer I assume...

To make the code even shorter you can also do this
code:
If LCase$(Left$(sClassName, lResult)) = "msgplusfloatingwindow" Then
    ShowWindow hWnd, -lParam * 8
End If
In that way you don't even need the private constants anymore and the code gets even smaller (because there is no need for the second IF THEN ELSE anymore)...

Note 2: As you'll notice I didn't use the SW_NORMAL constant as others would do, but the SW_SHOWNA constant instead. This is because SW_NORMAL will also make the floating windows active (it sets the focus to them), SW_SHOWNA does not. More info on this can be found in the MSDN library: ShowWindow.


Download the attachment for the complete VB6 project files (using the short method)

-------------------------------

EDIT: The included compiled exe file has basically the same functionality as the one from Fergy. But it will not loose focus (because I used SW_SHOWNA instead of SW_NORMAL) when you show the floating windows. And you can also start it up with a parameter "hide" or "show":

plusfloatingwindows => Will start up as normal and will show you the two buttons
plusfloatingwindows hide => Will hide the floating windows immediatly without showing any window
plusfloatingwindows show => Will show the floating windows immediatly without showing any window (in fact, instead of "show" you can use whatever you like :p)

Note: as it is an VB program it requires the useuall VB6 runtime library to be present on your system (MSVBVM60.DLL), if you don't have it (aka if you get an error when you start the program) download it here and install it.

.zip File Attachment: PlusFloatingWindows.zip (5.83 KB)
This file has been downloaded 153 time(s).

This post was edited on 08-24-2005 at 09:44 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-24-2005 03:59 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Temporarily remove desktop contacts - by aC23 on 08-21-2005 at 01:45 AM
RE: Temporarily remove desktop contacts - by Val on 08-21-2005 at 02:49 AM
RE: Temporarily remove desktop contacts - by cardshark on 08-24-2005 at 12:06 AM
RE: Temporarily remove desktop contacts - by uberdosis on 08-24-2005 at 12:33 AM
RE: Temporarily remove desktop contacts - by ShawnZ on 08-24-2005 at 12:46 AM
RE: Temporarily remove desktop contacts - by Concord Dawn on 08-24-2005 at 12:48 AM
RE: RE: Temporarily remove desktop contacts - by CookieRevised on 08-24-2005 at 02:29 AM
RE: Temporarily remove desktop contacts - by matty on 08-24-2005 at 02:49 AM
RE: Temporarily remove desktop contacts - by CookieRevised on 08-24-2005 at 03:59 AM
RE: Temporarily remove desktop contacts - by Fergy on 08-24-2005 at 06:44 AM
RE: Temporarily remove desktop contacts - by CookieRevised on 08-24-2005 at 06:46 AM
RE: Temporarily remove desktop contacts - by Fergy on 08-24-2005 at 06:53 AM
RE: Temporarily remove desktop contacts - by aC23 on 08-24-2005 at 04:11 PM
RE: RE: Temporarily remove desktop contacts - by CookieRevised on 08-24-2005 at 06:03 PM
RE: Temporarily remove desktop contacts - by aC23 on 08-25-2005 at 01:18 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On