views:

497

answers:

2

My application doesn't seem to receive or handle the same windows messages for the Cascade, Tile Horizontal/Tile Vertical on specific windows versions.

Windows XP x32 - Not working
Windows XP x64 - Not tested
Windows Vista x32 - Not working
Windows Vista x64 - Works fine??
Windows 7 x32 - Not tested
Windows 7 x64 - Not working

Anyone any idea's as to why this may be the case? Is there anything specific to Vista x64 that isn't with the others, I wouldn't have thought so myself!

Update

More specifically I am referring to when I have one or more instances of my application open and I hold Ctrl and select these from the task bar and then try to Cascade/Tile.

Older versions of our application prior to upgrading to Delphi 2009 seem to work as expected. Differences from this is we are now using the DevExpress ribbon components. Even more frustratingly is we have another version of the application which is in Delphi 2009 and using the ribbons and that works fine!

+1  A: 

If you're talking about Delphi's TForm.Cascade and TForm.Tile methods, from the documentation (Delphi 7, as it was handy):

Use Cascade to arrange MDI child forms so they overlap.

Cascade works only if the form is an MDI parent form (that is, if the form’s 
FormStyle property is fsMDIForm).

As you can see, they're only designed for MDI child forms; they have no effect on non-MDI child forms. That might explain why they're not working on three of the four OS's you've tested on. (I'd suspect the Vista x64 working is a fluke of some kind.)

EDIT: Based on the comment, the problem isn't related to TForm.Cascade/Tile.

I think Craig Young is on the right track, though. Have you tried adding

Application.ShowMainFormOnTaskbar := True;

to the .DPR file? I think the issue may be that, on projects started in earlier versions of Delphi and then updated to newer versions, the flag isn't set and the Application's window is what's put on the taskbar. Changing it to the main form instead may fix the issue.

Ken White
I am referring to when you right click on the application when its on the task bar and selecting those options from the menu. I would have through regardless of what type of application it was it would work.
James
Ah, OK. The phrasing read to me like TForm.Cascade. See updated answer.
Ken White
I have mentioned in the comments on the main question this has already been done. I don't think this is where the issue lies. I noticed we do trap the WM_MOVING message however it doesn't seem to get called when the Cascade/Tile options are selected.
James
A: 

A simple Delphi app has two 'main' handles. One is for the main form, and the other for the TApplication instance.

Personally I don't use the functionality to tile or cascade applications on the desktop (I prefer to run things maximised). Consequently, I've never bothered to dig around with that behaviour. But I can give some pointers:

  • Most likely the TApplication.WndProc method is receiving the message, but it doesn't help trying to resize that.
  • I suggest you intercept the relevant messages and simply pass them on to the main form's handle.
    • The TApplication.OnMessage event is the simplest, and should suffice.
    • If not, you could try using TApplication.HookMainWindow();
Craig Young