M
Mallikarjun Tuppad
Whats the equivalent in .NET for the following.
FindWindowEx (or EnumWindows/EnumChildWindows)
Mallik
FindWindowEx (or EnumWindows/EnumChildWindows)
Mallik
Whats the equivalent in .NET for the following.
FindWindowEx (or EnumWindows/EnumChildWindows)
You could also just allow the .NET interop services do most/all of the work
and declare it like the following in a class (mine's a static utility
class), then just use it.
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr FindWindowEx([MarshalAs(UnmanagedType.I4)]int
hWndParent, [MarshalAs(UnmanagedType.I4)]int hWndChild,
[MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
[MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
This seems to work good for my purposes.
John
Jeff said:You could also just allow the .NET interop services do most/all of the work
and declare it like the following in a class (mine's a static utility
class), then just use it.
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr FindWindowEx([MarshalAs(UnmanagedType.I4)]int
hWndParent, [MarshalAs(UnmanagedType.I4)]int hWndChild,
[MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
[MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
This seems to work good for my purposes.
John
John
I have been trying to find the 'Desktop' window so that I can hook
into it and pick up mouse clicks.
Spy shows its class name as 'SysListView32' and its Window text as
'FolderView' but even with this information FindWindowEx returns null.
Is this a 'special' case of some sort or is XP/.NET hiding this
particular window?
Jeff Gaines said:You could also just allow the .NET interop services do most/all of the work
and declare it like the following in a class (mine's a static utility
class), then just use it.
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr FindWindowEx([MarshalAs(UnmanagedType.I4)]int
hWndParent, [MarshalAs(UnmanagedType.I4)]int hWndChild,
[MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
[MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
This seems to work good for my purposes.
John
John
I have been trying to find the 'Desktop' window so that I can hook
into it and pick up mouse clicks.
Spy shows its class name as 'SysListView32' and its Window text as
'FolderView' but even with this information FindWindowEx returns null.
Is this a 'special' case of some sort or is XP/.NET hiding this
particular window?
Jeff,
I'd try to use GetDesktopWindow(), but you'd have to adorn it w/ proper
attribute info analogously to the FindWindowEx approach to get the .NET
interop services to access it correctly. I havent't tried it, but something
like this should be pretty close:
[DllImport("user32.dll", SetLastError=false, CharSet=CharSet.Auto)]
public static extern IntPtr GetDesktopWindow();
John
I have been trying to find the 'Desktop' window so that I can hook
into it and pick up mouse clicks.
Spy shows its class name as 'SysListView32' and its Window text as
'FolderView' but even with this information FindWindowEx returns null.
Jeff,
The FolderView window isn't a top-level window, so you have to walk
the window hierarchy to find it. It's
The desktop window (GetDesktopWindow)
- The shell window (GetShellWindow)
- A window with class name SHELLDLL_DefView
- The FolderView window with class name SysListView32
So I guess you could do
IntPtr shell = GetShellWindow();
IntPtr defView = FindWindowEx( shell, IntPtr.Zero, "SHELLDLL_DefView",
null );
IntPtr folderView = FindWindowEx( defView, IntPtr.Zero,
"SysListView32", "FolderView" );
Mattias
Mattias Sjögren said:Jeff,
The FolderView window isn't a top-level window, so you have to walk
the window hierarchy to find it. It's
The desktop window (GetDesktopWindow)
- The shell window (GetShellWindow)
- A window with class name SHELLDLL_DefView
- The FolderView window with class name SysListView32
So I guess you could do
IntPtr shell = GetShellWindow();
IntPtr defView = FindWindowEx( shell, IntPtr.Zero, "SHELLDLL_DefView",
null );
IntPtr folderView = FindWindowEx( defView, IntPtr.Zero,
"SysListView32", "FolderView" );
Mattias