0

I am working on a small project in c++ and packing it into GUI. The reference source code is enter link description here (Download source code - 61.1 Kb)

I want to prompt a dialog window when choose "menu"-"edit"-"parameter setting". I have already draw a dialog like this

enter image description here

When click "parameter setting"

private void menuItem7_Click(object sender, EventArgs e)
{
   if (drawArea.GraphicsList.ShowFormParameter(this))
   {
      drawArea.SetDirty();
      drawArea.Refresh();
   }
}


public bool ShowFormParameter(IWin32Window parent)
{
   return true;
}

But it does not work, the dialog doesn't show when clicking. How can I realize that?

1
  • Something is badly wrong here... You're talking about creating an MFC application, and you've tagged the question c++ and mfc, but the code you've shown is obviously C# and using the WinForms framework. Worse, there's a c# tag on the question. So I have no idea what you're actually trying to do. MFC doesn't work with C#. Is the MFC part just a red herring? Are you actually just creating a C# WinForms application? Commented Aug 20, 2013 at 8:42

1 Answer 1

4

None of the code you've posted actually shows a dialog. You use the ShowDialog member function to do that, but you're not calling that function.

Out of context, I don't really know what the purpose of the ShowFormParameter function is. I suppose it's an attempt to modularize the code by placing the code to display the parameters dialog in a single function.

At any rate, you need to write code inside this function to actually show the dialog you created:

public bool ShowFormParameter(IWin32Window parent)
{
   // This creates (and automatically disposes of) a new instance of your dialog.
   // NOTE: ParameterDialog should be the name of your form class.
   using (ParameterDialog dlg = new ParameterDialog())
   {
       // Call the ShowDialog member function to display the dialog.
       if (dlg.ShowDialog(parent) == DialogResult.OK)
       {
           // If the user clicked OK when closing the dialog, we want to
           // save its settings and update the display.
           //
           // You need to write code here to save the settings.
           // It appears the caller (menuItem7_Click) is updating the display.
           ... 

           return true;               
       }
   }
   return false;  // the user canceled the dialog, so don't save anything
}
Sign up to request clarification or add additional context in comments.

3 Comments

One more wonder want to raise, although it have little relation to the theme. The reference source code demos a drawing tool. So if I draw a rectangle in the draw area, could the parameter of shapes(eg. x,y,width,height in the DrawRectangle.cs) extracted from the code and then displayed in a new dialog?
@qingyao Use the "Ask Question" button to ask a new question. Do be sure to include the code you're talking about in your new question.
I have asked a new question at link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.