R
Ray Phillips
I have been scouring the web for information on how to create something
similar to the system tray. Before anyone tries to show me how to make a
tray icon; that's NOT what I'm trying to do. Instead, I'm trying to get a
list of system tray applications.
By looking through the source code from GeoShell, I was able to figure out
that the process involves using CreateWindowEx() to create a window with the
class "Shell_TrayWnd" and then watch the WndProc messages for CopyData
messages. All sounds fairly simple. Or so I thought.
I created a windows form application in VB.NET 2005 and made the following
API Declarations:
'The CreateWindowEx function for making the window with a specified class name
Private Declare Auto Function CreateWindowEx Lib "user32" _
(ByVal dwExStyle As Integer, _
ByVal lpClassName As String, _
ByVal lpWindowName As String, _
ByVal dwStyle As Integer, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hWndParent As IntPtr, _
ByVal hMenu As IntPtr, _
ByVal hInstance As IntPtr, _
ByVal lpParam As IntPtr) As IntPtr
'GetLastError for finding the error if the CreateWindowEx fails
Private Declare Function GetLastError Lib "kernel32" () As Integer
I then put the following code in the Form Load event:
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim hinst As IntPtr
Dim myTray as IntPtr
'Get hInstance
hinst = Marshal.GetHINSTANCE(GetType(Form1).Module)
'Attempt to create a window with the class "Shell_TrayWnd"
myTray = CreateWindowEx(0, "Shell_TrayWnd", _
0, 0, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, hinst, IntPtr.Zero)
if myTray = IntPtr.Zero then
Dim err As Integer = GetLastError()
msgbox(err)
end if
End Sub
Any ideas what I'm doing wrong? I'm so close I can smell it! Is there a
managed code version of CreateWindowEx()? I need some way to create a window
with a specific window class.
BTW: I've written a replacement shell and this is one of the last steps
before it's finished. If you want to check it out, visit www.lcarsx32.com.
Thanks,
Ray
similar to the system tray. Before anyone tries to show me how to make a
tray icon; that's NOT what I'm trying to do. Instead, I'm trying to get a
list of system tray applications.
By looking through the source code from GeoShell, I was able to figure out
that the process involves using CreateWindowEx() to create a window with the
class "Shell_TrayWnd" and then watch the WndProc messages for CopyData
messages. All sounds fairly simple. Or so I thought.
I created a windows form application in VB.NET 2005 and made the following
API Declarations:
'The CreateWindowEx function for making the window with a specified class name
Private Declare Auto Function CreateWindowEx Lib "user32" _
(ByVal dwExStyle As Integer, _
ByVal lpClassName As String, _
ByVal lpWindowName As String, _
ByVal dwStyle As Integer, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hWndParent As IntPtr, _
ByVal hMenu As IntPtr, _
ByVal hInstance As IntPtr, _
ByVal lpParam As IntPtr) As IntPtr
'GetLastError for finding the error if the CreateWindowEx fails
Private Declare Function GetLastError Lib "kernel32" () As Integer
I then put the following code in the Form Load event:
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim hinst As IntPtr
Dim myTray as IntPtr
'Get hInstance
hinst = Marshal.GetHINSTANCE(GetType(Form1).Module)
'Attempt to create a window with the class "Shell_TrayWnd"
myTray = CreateWindowEx(0, "Shell_TrayWnd", _
0, 0, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, hinst, IntPtr.Zero)
if myTray = IntPtr.Zero then
Dim err As Integer = GetLastError()
msgbox(err)
end if
End Sub
Any ideas what I'm doing wrong? I'm so close I can smell it! Is there a
managed code version of CreateWindowEx()? I need some way to create a window
with a specific window class.
BTW: I've written a replacement shell and this is one of the last steps
before it's finished. If you want to check it out, visit www.lcarsx32.com.
Thanks,
Ray