Search:
Namespaces
Discussions
.NET v1.1
Feedback
Tiling and Cascading windows
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.interop
.
Post a new message to this list...
Peter McElroy
Hi,
I'm trying to add "Cascade" windows functionality in a C# SDI application,
using the win32 API call:
WORD CascadeWindows( HWND hwndParent,
UINT wHow,
const RECT *lpRect,
UINT cKids,
const HWND *lpKids
);
I've being trying to use the API in the following way, however it is not
cascading the four windows I am passing to it in the windowArray parameter,
instead it cascades my version of Visual Studio that the Application is
being run from:
[DllImport("user32")] public static extern short CascadeWindows(int
hwndParent,
int wHow, int lpRect, int cKids, ref System.
IntPtr
[] lpKids);
public void Cascade(Form[] arrangeWindows )
{
int index = 0;
System.
IntPtr
[] windowArray = new
System.
IntPtr
[arrangeWindows.Length];
foreach(Form arrangeWindow in arrangeWindows)
{
windowArray[index++] = arrangeWindow.Handle;
}
User32.CascadeWindows(0, 0, 0, windowArray.Length, ref windowArray);
}
Any ideas what I am doing wrong?
Thanks in Advance for any Help :-)-Peter Mc
Reply to this message...
Robert Jordan
Hi Peter McElroy,
[Original message clipped]
The hwndParent (1st param) must be an
IntPtr
.
[Original message clipped]
You have to pass the MDI parent form's Handle an the
first argument to CascadeWindow.
bye
Rob
Reply to this message...
Robert Jordan
[Original message clipped]
Ahh, it's actually a SDI-apllication ;-)
Then pass the Main form's Handle to CascadeWindows.
bye
Rob
Reply to this message...
Peter McElroy
Hi Rob,
Thanks for the help, I tried setting the main form so that the code now
looks like this:
[DllImport("user32")] public static extern short
CascadeWindows(System.
IntPtr
hwndParent,
int wHow, int
lpRect, int cKids, ref System.
IntPtr
[] lpKids);
public void Cascade(Form[] arrangeWindows )
{
System.
IntPtr
[] windowArray = new System.
IntPtr
[arrangeWindows.Length];
foreach(Form arrangeWindow in arrangeWindows)
{
windowArray[index++] = arrangeWindow.Handle;
}
User32.CascadeWindows(this.MainForm.Handle, 0, 0, windowArray.Length,
ref windowArray);
}
Unfortunately it is still not working, I'm wondering if I need to specify
the lpRect and wHow parameters,
and if so how I would do this in c#, any Ideas ?
Thanks again :-)
-Peter Mc
"Robert Jordan" <
Click here to reveal e-mail address
> wrote in message
news:ci40tj$dsf$05$
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Robert Jordan
Peter McElroy wrote:
[Original message clipped]
static extern short CascadeWindows(
IntPtr
hwndParent, uint wHow,
IntPtr
lpRect, uint cKids,
IntPtr
[] lpKids);
"ref System.
IntPtr
[] lpKids" is wrong.
[Original message clipped]
According to the docs, lpRect can be
IntPtr
.Zero.
bye
Rob
Reply to this message...
Peter McElroy
Hi Rob,
Thats got it working Thanks! :-)
Cheers
-Peter Mc
"Robert Jordan" <
Click here to reveal e-mail address
> wrote in message
news:ci48mr$v17$02$
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.IntPtr
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com