Window Event for "Moving"?

I have two windows for example. I want to be able to move left window and have right window move with it.

I thought there was a Moving window event but only a Moved event. Has anyone tried something like this?

In the Moved event:

OtherWindow.top=self.top
OtherWindow.left=self.left

Hm… I assumed that wouldn’t do anything while you are “moving” vs. after the move.

Ill give it a try then Thanks James.

[quote=84786:@James A Smith]In the Moved event:

OtherWindow.top=self.top
OtherWindow.left=self.left[/quote]

Thanks James, but its not seemless while “moving”.

Mike
I have 17 windows that I move so that it appears as one. They all maintain the same height and width. The Moved and Resized Event call a routine which does the moving and resizing. In that routine I have a once-switch which return if routine is being used.

The switch is commented:
’ Do NOT allow more than one to run at at time
’ otherwise will get some strange window jumping arround

[quote=84774:@Mike Cotrone]I have two windows for example. I want to be able to move left window and have right window move with it.

I thought there was a Moving window event but only a Moved event. Has anyone tried something like this?[/quote]
What platform ?
There are some easy ways to do this on different platforms
OS X refers to them as “window groups” - and I’d guess that MacOSLib has a means to set these up already

On Windows you’d probably have to subclass the window proc (SetWindowLong declare), then look for the WM_MOVING message. For an example on how to subclass a window proc you can look at the CommandLinkExample project in the Examples Projects/Platform-Specific/Windows folder.

Not sure about Linux

For Windows Norman is absolutely on target…

In Cocoa, look at the NSWindow and NSNotificationCenter classes (or alternately assign a delegate instance to an NSWindow, which receives notifications implicitly just by implementing appropriate methods).

For instance you can use windowWillMove: or windowDidMove: notifications to notice when a window has been moved by the user. This is not sent continuously; it is sent when the user starts moving a window, or pauses while moving the window. If you need fine-grained control over mouse events you can subclass the window and implement methods from its superclass NSResponder.

Linux… only has apis for when a window begins moving and ends moving just like Mac and would need mouseevent handling between both start and end moving events to determine location…

Mac OS X.

Thanks and Ill give that a try Norman.

[quote=84837:@Matthew Combatti]For Windows Norman is absolutely on target…

In Cocoa, look at the NSWindow and NSNotificationCenter classes (or alternately assign a delegate instance to an NSWindow, which receives notifications implicitly just by implementing appropriate methods).

For instance you can use windowWillMove: or windowDidMove: notifications to notice when a window has been moved by the user. This is not sent continuously; it is sent when the user starts moving a window, or pauses while moving the window. If you need fine-grained control over mouse events you can subclass the window and implement methods from its superclass NSResponder.

Linux… only has apis for when a window begins moving and ends moving just like Mac and would need mouseevent handling between both start and end moving events to determine location…[/quote]
I will thanks Matthew!

never mind I forgot window groups are a CARBON thing
not sure there’s an equivalent for Cocoa

NSWindow has addChildWindow:ordered: which will move the child with the parent.

But the parent won’t move with the child. Do you need it both ways?

[code]Sub Action()
dim w As new Window1
w.top = self.top + self.height+30
w.left = self.left + self.width

declare sub addChild lib “Cocoa” selector “addChildWindow:ordered:” (id As integer, child As integer, ordering As integer)

addChild(self.Handle, w.Handle, 1)
End Sub
[/code]

no just one way thanks!

OSX Window groups were always a little bit flaky anyways…

[quote=85005:@Will Shank]NSWindow has addChildWindow:ordered: which will move the child with the parent.

But the parent won’t move with the child. Do you need it both ways?

[code]Sub Action()
dim w As new Window1
w.top = self.top + self.height+30
w.left = self.left + self.width

declare sub addChild lib “Cocoa” selector “addChildWindow:ordered:” (id As integer, child As integer, ordering As integer)

addChild(self.Handle, w.Handle, 1)
End Sub
[/code][/quote]

Thanks again Will. I just used this again in another project to keep two Mac OS X Windows together in an overlay situation. It worked perfectly. Thanks!