Does anyone have a Cocoa replacement for GetSheetWindowParent

Hi Folks,

More weekend refactoring and I’d like to get rid of a deprecation on a call to GetSheetWindowParent since it uses the Carbon lib instead of Cocoa. I’ve hit the Apple headerdocs, but I’m either using the wrong search term or they don’t have it documented.

Does anyone have a Cocoa replacement that allows us to check a window to see if a sheet is attached?

Give the sheet window a constructor with one argument: parentWindow As Window, so you can call it like that:

Dim sheet As New SheetWindow(Self)   // assuming Self is the parent window

Of course tore that reference in a property in the sheet window.

Actually, I’m using that function to determine is a Window ‘w’ has a sheetwindow attached after the fact. It may be that further refactoring work may obviate the need since I’m now using a better mechanism for tracking my dialogs, but the requirement still exists for the moment.

The reason behind needing this is that the sheet can sometimes display on the wrong window if the user has clicked at JUST that right moment…

Unless moved, a sheet window always open in the center of the parent window. At position zero.

In this case where sheet has been displayed within Window1, both values are identical :

system.DebugLog str(self.left)+" "+ str(window1.Left+(window1.width-self.width)/2)

Also, a sheet window has exactly the same top as the parent window.

Using these two values, you can ascertain if a particular sheet window is actually child.

Function isChild(extends sheet as window, parent as window) As boolean if sheet.Left = parent.Left+(parent.width-sheet.width)/2 and _ sheet.top = parent.top then return true else return false end if End Function

msgbox str(self.ischild(window1))

You can refine that if your sheet displays at a different left position, or if you display a ModalDialog.