0

我正在用 C++ 开发一个小项目并将其打包到 GUI 中。参考源代码在此处输入链接描述(下载源代码 - 61.1 Kb)

我想在选择“菜单”-“编辑”-“参数设置”时提示一个对话窗口。我已经画了一个这样的对话框

在此处输入图像描述

点击“参数设置”时

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


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

但它不起作用,单击时对话框不显示。我怎么能意识到这一点?

4

1 回答 1

4

您发布的所有代码实际上都没有显示对话框。您使用ShowDialog成员函数来执行此操作,但您没有调用该函数。

断章取义,我真的不知道该ShowFormParameter功能的目的是什么。我想这是一种通过将代码放置在单个函数中来显示参数对话框来模块化代码的尝试。

无论如何,您需要在此函数中编写代码以实际显示您创建的对话框:

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
}
于 2013-08-20T09:29:35.730 回答