[CONNECT C++] How do you get an MSWindowP to the main CONNECT application window?

I'm wanting to add some text to the main CONNECT application window, but I can't figure out how to get an MSWindowP. I tried mdlNativeWindow_getMainHandle(), but it returns nullptr whether I pass in 0 or 1 for the iScreen parameter

  • C++ Wrapper for mdlNativeWindow_api

    In the absence of a MicroStationAPI NativeWindow class, you can write your own wrapper class to help in this situation. Put the initialiser in your class construction, then add methods that wrap the MDL functions you need. In this example …

    struct MdlNativeWindowWrapper
    {
        MdlNativeWindowWrapper () { mdlNativeWindow_initialize ("unused"); }
        HWND GetMainHandle (int screen = 0) { return mdlNativeWindow_getMainHandle (screen);  }
    };

    Usage …

    MdlNativeWindowWrapper wrapper;
    HWND mainWindow = wrapper.GetMainHandle ();
    

    Using your wrapper rather than the raw MDL functions means that you can't forget to initialise. You probably recognise this as an example of RAII.

     
    Regards, Jon Summers
    LA Solutions

  • Unknown said:
    I can't figure out how to get an MSWindowP. I tried mdlNativeWindow_getMainHandle()

    Did you initialise the native window API?  From help: The native window support subsystem must be initialized before other mdlNativeWindow_* functions can be called.

    #include <msnativewindow.h>
    mdlNativeWindow_initialize ("Bruce");

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Bruce Reeves SRNS