Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2004

Tip: Looking for answers? Try searching our database.

Tiling and Cascading windows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter McElroy - 13 Sep 2004 12:16 GMT
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
Robert Jordan - 13 Sep 2004 12:37 GMT
Hi Peter McElroy,

> Hi,
>
[quoted text clipped - 12 lines]
> 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);

The hwndParent (1st param) must be an IntPtr.

> public void Cascade(Form[] arrangeWindows )
> {
[quoted text clipped - 7 lines]
>
>     User32.CascadeWindows(0, 0, 0, windowArray.Length, ref windowArray);

You have to pass the MDI parent form's Handle an the
first argument to CascadeWindow.

bye
Rob
Robert Jordan - 13 Sep 2004 12:39 GMT
>> public void Cascade(Form[] arrangeWindows )
>> {
[quoted text clipped - 10 lines]
> You have to pass the MDI parent form's Handle an the
> first argument to CascadeWindow.

Ahh, it's actually a SDI-apllication ;-)
Then pass the Main form's Handle to CascadeWindows.

bye
Rob
Peter McElroy - 13 Sep 2004 14:11 GMT
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

>>> public void Cascade(Form[] arrangeWindows )
>>> {
[quoted text clipped - 16 lines]
> bye
> Rob
Robert Jordan - 13 Sep 2004 14:52 GMT
> Hi Rob,
>
[quoted text clipped - 5 lines]
>                                                         int wHow, int
> lpRect, int cKids, ref System.IntPtr[] lpKids);

static extern short CascadeWindows(IntPtr hwndParent, uint wHow,
   IntPtr lpRect, uint cKids, IntPtr[] lpKids);

"ref System.IntPtr[] lpKids" is wrong.

> public void Cascade(Form[] arrangeWindows )
> {
[quoted text clipped - 12 lines]
> the lpRect and wHow parameters,
> and if so how I would do this in c#, any Ideas ?

According to the docs, lpRect can be IntPtr.Zero.

bye
Rob
Peter McElroy - 15 Sep 2004 15:13 GMT
Hi Rob,

Thats got it working Thanks! :-)

Cheers
-Peter Mc

>> Hi Rob,
>>
[quoted text clipped - 33 lines]
> bye
> Rob

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.