我正在尝试向我的一个子窗体添加窗口幻灯片。我将简要介绍一下这一小部分在我的应用程序中的作用。
用户键入IP地址范围。App执行所有pinging操作,并在新表单中显示结果(动态)。
以下是我希望它的工作方式:如果用户运行ping一次,幻灯片动画将不会发生任何事情。但是,如果用户单击结果表单上的“重试”控件,新的结果窗口将从旧结果表单的右侧滑出。
在结果表单(名为: Ping_Form)中,我在load事件中添加了以下内容:
[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方法时,创建了一个空白表单并滑出,但结果表单看起来很正常。
在这一领域,任何导演或建议都是很棒的。非常感谢!
发布于 2012-02-23 04:59:30
尝试在调用AnimateWindow之后调用this.Show();。
https://stackoverflow.com/questions/9398999
复制相似问题