[C++] reproducing "Adjust Mesh" dialog for analysis mode UI [SOLVED]

I’m trying to produce UI for a false color visual analysis mode. In this mode I want to have a button for “Adjust mesh” to be able to get mesh settings for the analysis mode, similar to dialogs for e.g. CurvatureAnalysis and Zebra commands.

I have found the SDK function RhinoMeshObjects that seems to do exactly what I want. There is just a couple of minor problems

  1. When I click the Preview button, the commandline gets filled with the message Click OK to keep mesh: This message does not go away, even when the UI is closed. see the reply below
  2. When I close the mesh settings dialog with the Cancel button while a preview is showing, this preview keeps on showing. solved with a redraw

Below is the code that handles the button-click of the “Adjust mesh” button. Any suggestions on how to tackle the problems above are highly appreciated.

void CProjectionDialog::OnBnClickedButtonAdjust()
{
    CRhinoDoc* pDoc = RhinoApp().ActiveDoc();
    if (!pDoc) return;

    ON_UUID currentMode = CurrentModeId();
    ON_SimpleArray<const CRhinoObject*> analysing;
    CRhinoObjectIterator it(*pDoc);
    while(CRhinoObject* pObj = it.Next())
    {
        if (pObj && pObj->InAnalysisMode(currentMode))
        {
            analysing.Append(pObj);
        }
    }

    const ON_MeshParameters& anal = pDoc->Properties().AnalysisMeshSettings();
    ON_MeshParameters toChange(anal);
    ON_ClassArray<CRhinoObjectMesh> meshes;

    // TODO: after clicking OK the dialog hangs with "Click OK to keep meshes" on the command line
    // TODO: after clicking Cancel when a preview is showing, the preview keeps on showing
    CRhinoCommand::result res = RhinoMeshObjects(analysing, toChange, m_uiStyle, meshes);
    if (res == CRhinoCommand::result::success)
    {
        pDoc->Properties().SetAnalysisMeshSettings(toChange);
    }
}

Solved the problem with the command prompt by getting the existing prompt and restoring it after the dialog is closed.

void CProjectionDialog::OnBnClickedButtonAdjust()
{
    CRhinoDoc* pDoc = RhinoApp().ActiveDoc();
    if (!pDoc) return;

    ON_UUID currentMode = CurrentModeId();
    ON_SimpleArray<const CRhinoObject*> analysing;
    CRhinoObjectIterator it(*pDoc);
    while(CRhinoObject* pObj = it.Next())
    {
        if (pObj && pObj->InAnalysisMode(currentMode))
        {
            analysing.Append(pObj);
        }
    }

    // to prevent the "Click OK to keep mesh" command prompt to 
    // hang around after we close the dialog, get it here and 
    // set it after completion.
    ON_wString prompt;
    if (!RhinoApp().GetCommandPrompt(prompt))
        prompt = L"Command";

    prompt.TrimRight(L":");

    const ON_MeshParameters& anal = pDoc->Properties().AnalysisMeshSettings();
    ON_MeshParameters toChange(anal);
    
    ON_ClassArray<CRhinoObjectMesh> meshes;
    
    CRhinoCommand::result res = RhinoMeshObjects(analysing, toChange, m_uiStyle, meshes);
    if (res == CRhinoCommand::result::success)
    {
        pDoc->Properties().SetAnalysisMeshSettings(toChange);
    }
    else
    {
        pDoc->Properties().SetAnalysisMeshSettings(anal);
    }

    // after clicking Cancel when a preview is showing, the preview keeps on showing
    // therefore, give a Regen() to re-create the views
    pDoc->Regen();
    RhinoApp().SetCommandPrompt(prompt);
}