【问题标题】:FolderBrowserDialog topmostFolderBrowserDialog 最顶层
【发布时间】:2020-05-21 10:16:56
【问题描述】:

第一逻辑

FolderBrowserDialog dialog = new FolderBrowserDialog();
           DialogResult ret = STAShowDialog(dialog);

第二个逻辑

private DialogResult STAShowDialog(FolderBrowserDialog dialog)
{
    DialogState state = new DialogState();
    state.dialog = dialog;      
   System.Threading.Thread FolderBrowserThread = new System.Threading.Thread(state.ThreadProcShowDialog);
            FolderBrowserThread.SetApartmentState(System.Threading.ApartmentState.STA);
            FolderBrowserThread.Start();
            FolderBrowserThread.Join();
            return state.result;
        }

最后的逻辑

class DialogState
    {
        public DialogResult result;
        public FolderBrowserDialog dialog;

        public void ThreadProcShowDialog()
        {
            dialog.Description = "Select the folder where you want to save the WAV files.";
            result = dialog.ShowDialog(new Form(){TopMost = true,TopLevel = true}           );
        }
    }

FolderBrowserDialog Top 最不工作。 屏幕的层是最低层。

没有错误!

我想在顶层被调用

【问题讨论】:

  • @Guy 我该怎么办?
  • @Guy 没有错误,但 TopMost 不能
  • 您发布的代码绝对不足以重现您的问题。必须有更多。你怎么称呼ThreadProcShowDialog?在那之前你是做什么的,描述一下你的背景
  • @MongZhu sorce add
  • 仍然无法重现。当我尝试你的代码时,它显示得最多。

标签: c# winforms


【解决方案1】:
private void CreateMyTopMostForm()
{
   // Create lower form to display.
   Form bottomForm = new Form();
   // Display the lower form Maximized to demonstrate effect of TopMost property.
   bottomForm.WindowState = FormWindowState.Maximized;
   // Display the bottom form.
   bottomForm.Show();
   // Create the top most form.
   Form topMostForm = new Form();
   // Set the size of the form larger than the default size.
   topMostForm.Size = new Size(300,300);
   // Set the position of the top most form to center of screen.
   topMostForm.StartPosition = FormStartPosition.CenterScreen;
   // Display the form as top most form.
   topMostForm.TopMost = true;
   topMostForm.Show();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-03
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 2013-02-05
    • 2021-11-13
    相关资源
    最近更新 更多