I’ve been working on implementing @Greg_O’s example project for MacOS SaveOpenDialogs for a text editor type project.
The example includes an AccessoryView
feature that I would like to use to offer some options for both opening & saving files (e.g., alternate Encodings).
Note: for custom controls to appear in the NSOpenPanelGTO or NSSavePanelGTO windows, they need to be hosted in a
DesktopContainer
.
The challenge is that the example project is based on having a DesktopWindow
open, which the custom container (for the AccessoryView
) is added as a control.
But what I’m attempting to do is invoke the Open & Save Panels (with the AccessoryView
) without a window open.
I can successfully display the Open & Save Panels from the app’s DesktopApplication
object (App) fine, but I cannot attach the AccessoryView
because calling the custom container with the New
keyword results in the container object having a Handle
of &h0000000000000000
(zero).
After some testing and reading of the docs, I see that a DesktopContainer
does not have a Handle
value until either one of the .EmbedWithin
methods are called, or the control is “opened” like when the window it is attached too is opened.
In other words, I’m trying to convert Greg’s example code from the following:
// add the custom accessory view
SaveAccessories1.SetFileTypes(types)
SaveAccessories1.Reset
mDialog.AccessoryView = SaveAccessories1
To something like the following:
// add the custom accessory view
Var accView As New SaveAccessories()
accView.SetFileTypes(types)
accView.Reset
mDialog.AccessoryView = accView // assignment errors out
The project will run in debug mode, but when the Open or Save panel is invoked, it fails because the AccessoryView
method requires an object with a proper Handle value.
I tried to adopt @Ian_Kennedy’s workaround from this post, but I couldn’t get it to work. I had trouble following the conversation (brain-fog, eh), so I’m not sure where I went wrong.
Any suggestions would be appreciated.
Keep in mind, I’m trying to make this work without having a DesktopWindow
already open.
Thank you.
2 posts - 2 participants