1

サブフォームの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

this.Show(); を呼び出してみてください。AnimateWindow への呼び出しの後。

于 2012-02-22T20:59:29.610 に答える