1

我正在尝试向我的一个子窗体添加一个窗口幻灯片。我将简要介绍这小部分在我的应用程序中的作用。

用户在 IP 地址范围内键入。应用程序执行所有 ping 操作并以新形式(动态)显示结果。

这是我希望它工作的方式:如果用户运行一次 ping,则幻灯片动画不会发生任何事情。但是如果用户点击结果表单上的“重试”控件,新的结果窗口将从旧结果表单的右侧滑出。

在结果表单(名称:Ping_Form)上,我在加载事件中添加了以下内容:

[DllImport("user32")]
    static extern bool AnimateWindow(IntPtr hwnd, int time, int flags);
    //Constants
    const int AW_SLIDE = 0X40000;
    const int AW_HOR_POSITIVE = 0X1;
    const int AW_HOR_NEGATIVE = 0X2;
    const int AW_BLEND = 0X80000;


 void ping_Form_Load(object sender, EventArgs e) 
        {
        bool is_Open = false;

        FormCollection fc = Application.OpenForms;
        foreach (Form f in fc)
            {
            if (f.Name == "PSE")
                is_Open = true;
            }
        if (is_Open == false)
            return;
        //Load the Form At Position of Main Form
        int WidthOfMain = Application.OpenForms["PSE"].Width;
        int HeightofMain = Application.OpenForms["PSE"].Height;
        int LocationMainX = Application.OpenForms["PSE"].Location.X;
        int locationMainy = Application.OpenForms["PSE"].Location.Y;

        //Set the Location


        this.Location = new Point(LocationMainX + WidthOfMain, locationMainy + 10);

        //Animate form
        AnimateWindow(this.Handle, 500, AW_SLIDE | AW_HOR_POSITIVE);


        }

但是当我运行 ping 方法时,会创建一个空白表单并滑出,但结果表单看起来很正常。

任何导演或建议在这方面都会很棒。非常感谢!

4

1 回答 1

0

Try calling this.Show(); after your call to AnimateWindow.

于 2012-02-22T20:59:29.610 回答