Access to Carbon and Win32 window handle from Max

    Aug 03 2011 | 6:51 am
    Hello all, I am currently trying to create an external with a GUI. I want to use VSTGUI to manage the GUI (since this module already exists in VST, and I do not want to code the GUI fully once again) I think that Max/MSP is able to deal with VSTGUI (since my plugin loads perfectly with vst~) but I can not find how to create the window needed by VSTGUI. On Win32, VSTGUI requires a WINDOW handle. On Mac, it requires a Carbon window pointer. Basically, Max has to create the window, then it defers everything else to VSTGUI.
    Does anybody know how to create a window (most precisely, get the window handle) from a Max external coded in C/C++ ?
    Thanks by advance for your help
    Benoit Kiss-Box

    • Aug 03 2011 | 11:08 am
      This is not supported, and it *will* change. You can send a message to a window object like this:
      void *native_window_for_my_system = object_method(w, gensym("getsyswind");
      In Max 5, on a Mac, this will return the carbon WindowRef. In Max 6, however, it will return an NSView*.
      You'll need to use maxversion() or similar to detect this and handle appropriately in your code.
      best, Tim
    • Aug 04 2011 | 4:54 am
      Hello Tim, thanks for the reply, it will allow me to start my work. From what I see, you switch to Cocoa window handling in Max 6. Am I right ? Benoit
    • Aug 04 2011 | 3:31 pm
      Yes, with Max 6 we make the move from Carbon to Cocoa for the underlying OS support.
      Cheers, Tim
    • Aug 12 2011 | 2:27 pm
      Thanks for these informations, Tim Switching to Cocoa seems a logical step (and VSTGUI also switched to Cocoa, so I expect this to be transparent for me) However, I still have two questions :
      - does this message applies to already created windows by Max (meaning that I have to create the window using the Max API, then get the handle or windowref)? My first idea was to create the window myself, thus I needed the handle of Max main window (thus my window appears as a "child")
      - does this message work also on Windows system (getting then the window handle)?
    • Aug 12 2011 | 4:14 pm
      Yes, it sounds like your understanding is correct. You should create a new jwind object and then you can query it to get the platform-native representation.
      And also you are correct about the method returning an HWND on Windows.
      Cheers, Tim
    • Aug 13 2011 | 8:09 am
      Thanks a lot for these informations, Tim I hope you will be at Expo'74, I would be happy to meet you and discuss with you
    • Mar 03 2012 | 3:35 pm
      Hello Tim, I just noticed that I forgot to keep you informed. Finally, I was able to create a GUI object from Max to host a VSTGUI based user interface, without needing Max to create the window. I made it work under Mac OS and Windows. Tested also under Max6...
    • Mar 05 2012 | 12:00 pm
      Great to hear! Thanks for the update!