Catching a Minimize event?

A window gives my the opportunity to handle the minimize event and do something different with the window instead of putting it into the dock. In my case, I want it to change to a iTunes-like mini window.
But before this event is triggered, the OS animation moves it to the dock (where I close it afterwards). This is a bit irritating for the user. Is there some way to catch a minimize event before the animation starts?

Why not implement it the way Apple has done it with iTunes? I would stick with what users know and that is that the minimize button sends the window to the dock. Add a menu item like “MiniPlayer” in iTunes to the “Window” menu.

Unless there is a declare for that, I found no way to intercept the minimize.

However, something like this in the minimize event may get you your miniwindow

Miniwindow.show me.close

I tested it. The animation does take place, but as the miniwindow appears at the same time, it may do the trick.

Thanks you two,

yes, a method like proposed from Michel works, but it doesn’t look right when the window disappears to the left side and the mini window appears on the right :wink:
I guess Eli’s idea is the best to go with. Everything else looks confusing. I hoped there would be a Cancelminimize event like for the close event, but looks like this was wrong.

The best I had found with my method was to have the miniwindow positioned over the dock, in the lower right corner, so the animation makes it appear that the windows is shrunk to the miniwindow. Of course, it is not identical to the upper-left corner iTunes miniPlayer window.

It looks convincing, but Eli is right. The way iTunes works is that the miniPlayer appears together with the main window, not replaces it.

It just occurred to me that changing the way the minimize button works would most certainly mean that the app would be rejected in the MAS. Unless instead of closing the main window, one leaves the icon in the dock, at the same time as the miniwindow appears above. Just a thought.

iTunes doesn’t use the miniaturize button for that, it’s a special icon on the right. Here’s the cheap way to do that reusing a Xojo Canvas for the icon, code taken from this thread https://forum.xojo.com/10914-black-windows. There’s many strategies there possibly including the right way to do this which is a NSView subclass implementing drawRect and MouseDown/Drag/Up.

[code]//Window1
Sub Open()
declare function contentView lib “Cocoa” selector “contentView” (id As integer) As Ptr
declare function superView lib “Cocoa” selector “superview” (id As Ptr) As Ptr
declare function subviews lib “Cocoa” selector “subviews” (id As Ptr) As Ptr
declare function objAtIdx lib “Cocoa” selector “objectAtIndex:” (id As Ptr, idx As UInt32) As Ptr
declare sub addSubView lib “Cocoa” selector “addSubview:positioned:relativeTo:” _
(id As Ptr, aView As integer, order As integer, rel As Ptr)

dim themeFrame As Ptr = superView(contentView(self.Handle))
dim firstSubView As Ptr = objAtIdx(subViews(themeFrame), 0)
addSubView(themeFrame, Canvas1.Handle, 0, firstSubView)
End Sub

//Canvas1, 20x20, locked right, placed top-right in titlebar
Sub Paint(g As Graphics, areas() As REALbasic.Rect)
g.ForeColor = &c00FF00
g.FillOval(0, 0, g.Width, g.Height)
End Sub

Function MouseDown(X As Integer, Y As Integer) As Boolean
MsgBox “do itunes mini player”
End Function[/code]