窗体Form1上有一个Panel控件panel1.
private void panel1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("OK");
}单击panel1,弹出对话框后,不结束对话框,我可以选择桌面上的图标,启动其他的程序。
但在panel1的panel1_DragDrop事件中,如下:
private void panel1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
} private void panel1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
MessageBox.Show("ok");
}如果拖一个文件或者文件夹上去,弹出对话框,此时桌面上的图标则不能选中,这是为何?我就是想在这个应用程序中弹出对话框后,不去确认,去选中桌面上的其他图表和程序,谁有办法解决???

解决方案 »

  1.   

    估计windows消息不同,不太清楚,帮你顶
      

  2.   

    gngnandgngn(仗义执言),如果点显示桌面后,那对话框就消失了,要保持对话框显示的情况下,选桌面上的图标。为何第一种情况可以做到,第二种情况不行呢?
      

  3.   

    不知道
    可能和你拖动文件有关, 你程序挂起在messagebox那里, 而桌面上的资源因为该消息而被锁住。 
    而第一种只是单击panel消息, 桌面上的资源肯定不会被锁住。
    仅仅猜测
      

  4.   

    好像messagebox弹出就不能点了,除非你做成2个form,然后用线程控制.
      

  5.   

    copico(一路向北) ,能像你说得那样搞,我早搞过了,你用窗体做一个MessageBox,show()方法显示后,程序继续往下执行了,根本没有停住,如何和用户交互啊?你这哪里是对话框啊
      

  6.   

    liuyangxp1(),我讲的第一种情况就是可以的为何第二种情况不行,谁能给我个解决方案,我再送他200分。
      

  7.   

    用copico(一路向北)的方法,然后再你“程序继续往下执行”的地方之前加一个循环Sleep你的窗口进程,直到满足向下执行条件(这里就是你操作完后,可能需要一个标志)例如……
    while(!continueFlag)//continueFlag是程序继续执行的标志
    {
        System.Threading.Thread.Sleep(300);
    }
    ……因为你是几个程序互动的执行,这个标志应该是从文件或注册表中读出来到, 可能需要你在另一个程序中写入它。
      

  8.   

    fd7893(看着办吧) ,这种办法不是没想过,但感觉不好,我发现别人实现的程序,在DropDrop事件里弹出对话框,可以选择桌面上的东西,可惜看不到源码,不知道人家是怎么实现的。有哪位知道,就用MessageBox,如何来实现????
      

  9.   

    Win XP + VS.NET2003没出现你那种情况using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication1
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Panel panel1;
    private System.Windows.Forms.Button button1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.panel1 = new System.Windows.Forms.Panel();
    this.button1 = new System.Windows.Forms.Button();
    this.panel1.SuspendLayout();
    this.SuspendLayout();
    // 
    // panel1
    // 
    this.panel1.AllowDrop = true;
    this.panel1.Controls.Add(this.button1);
    this.panel1.Location = new System.Drawing.Point(48, 88);
    this.panel1.Name = "panel1";
    this.panel1.TabIndex = 0;
    this.panel1.DragEnter += new System.Windows.Forms.DragEventHandler(this.panel1_DragEnter);
    this.panel1.DragDrop += new System.Windows.Forms.DragEventHandler(this.panel1_DragDrop);
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(56, 40);
    this.button1.Name = "button1";
    this.button1.TabIndex = 0;
    this.button1.Text = "button1";
    this.button1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button1_MouseDown);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.panel1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.panel1.ResumeLayout(false);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    this.panel1.DoDragDrop(this.button1,DragDropEffects.Copy);
    } private void panel1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
    {
    MessageBox.Show("ok");
    } private void panel1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
    {
    e.Effect = DragDropEffects.Copy;
    }
    }
    }
      

  10.   

    Sorry……对不起,我看错了,我以为是内部控件拖动呢……
      

  11.   

    单击panel1,弹出对话框后,不结束对话框,我可以选择桌面上的图标,启动其他的程序。--------------------------------------------------------------------------------怎么做到了
      

  12.   

    笨办法,在窗体上放一个timer1
    然后在panel1_DragDrop里写timer1.Enable = true;return;
    在timer1_Tick里写timer1.Enable = false;MessageBox.Show("OK!");这个方法是让DragDrop响应Windows消息后马上返回,以免发送消息的窗体等着MessageBox而不能动,用Timer是使得MessageBox对窗体是模式的,另开线程的话就不是模式的了。
      

  13.   

    我说一下我的看法,不知道正确与否,大家讨论,呵呵:你从桌面上拖动文件是,桌面是激活的,即当前激活程序是桌面,用MessageBox.Show()时,该消息框的父窗口可能就是桌面,故你不能在操作桌面;如果真是这种情况,那么很好解决:MessageBox.Show(this, "Ok", "窗口标题");试试看吧,这样弹出的消息框的父窗口就是你那个Panel1了
      

  14.   

    不是MessageBox的问题..
    而是DragEnter.和DragDrop事件的原因....
    因为是拖放..在响应事件的过程中鼠标在桌面上将一直被程序控件...
      

  15.   


            private void panel1_DragDrop(object sender, DragEventArgs e)
            {
                message = "OK";
                Thread th = new Thread(new ThreadStart(ShowBox));
                th.Start();
            }
            string message;
            public  void ShowBox()
            {
                MessageBox.Show(message);
            }
    新建一个线程显示提示框可以解决
      

  16.   

    如果楼主还在,不妨试试我的方法。Its not the best,but it works.
    To另开线程:另开线程弹出的对话框不是模式的。
    Tofengqinggao(风清高),MessageBox省略owner默认就是this。