在除錯時如果視窗不在最前面,沒被激活,它是能夠主動彈出并激活,此時輸入字符就會輸入到Textbox1中.
但在運行時發現視窗只是閃幾閃,不能夠彈出、激活,現在想完成主動彈出并讓textbox1選中.請問如何才能實作呢?
用了
this.Show();
this.Activate();
this.BringToFront();
運行時也只是閃幾下
public const int WS_SHOWNORMAL = 0x0001;
[
DllImport("user32.dll", EntryPoint = "ShowWindowAsync")
]
public static extern bool ShowWindowAsync(IntPtr hWnd, Int32 cmdShow);
[
DllImport("user32.dll", EntryPoint = "SetForegroundWindow")
]
public static extern bool SetForegroundWindow(IntPtr hWnd);
private void timer1_Tick(object sender, EventArgs e)
{
if (true)
{
ShowWindowAsync(this.Handle, WS_SHOWNORMAL);
SetForegroundWindow(this.Handle);
this.TextBox1.Select();
this.Show();
this.Activate();
his.BringToFront();
}
}
using System.Runtime.InteropServices;
運行也是閃幾下,不知道怎么回事??
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/133049.html
標籤:C#
上一篇:VS打包安裝軟體,安裝后洗掉安裝目錄內檔案后,雙擊快捷方式后,會把洗掉的檔案重新安裝。
下一篇:如何讀取模型
