首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >user32 AnimateWindow函数不能滑动正确的表单

user32 AnimateWindow函数不能滑动正确的表单
EN

Stack Overflow用户
提问于 2012-02-23 00:37:24
回答 1查看 685关注 0票数 1

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

用户键入IP地址范围。App执行所有pinging操作,并在新表单中显示结果(动态)。

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

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

代码语言:javascript
复制
[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方法时,创建了一个空白表单并滑出,但结果表单看起来很正常。

在这一领域,任何导演或建议都是很棒的。非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2012-02-23 04:59:30

尝试在调用AnimateWindow之后调用this.Show();。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9398999

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档