日期:2014-05-18 浏览次数:21597 次
 Form2 f2 = new Form2();
            f2.Show();
            this.Focus();
//在form2中通过设置 this.StartPosition属性决定窗体的起始位置.
------解决方案--------------------
还可以设置topmost属性
------解决方案--------------------
new出以后,焦点放到别处。不能showdialog
------解决方案--------------------
show 之后 设置焦点在本窗口
------解决方案--------------------
我有弹出消息的例子,跟QQ差不多 弹出五秒不动自动消失 ,而且还有锁定的功能 邮箱留下 我发你 楼主
------解决方案--------------------
show之后把焦点放在当前窗口,设置弹出窗口的位置在右下角就行了
------解决方案--------------------
要开独立线程来实现!要不你弹出的窗体肯定要和你的主窗体占用主线程,这样自然会挡住你的主窗体了,
------解决方案--------------------
this.focus();
------解决方案--------------------
让新show出来的窗体失去焦点
------解决方案--------------------
在窗体代码里加入如下的代码:
protected override bool ShowWithoutActivation
{
	get
	{
		return true;
	}
}
------解决方案--------------------
form1.Show();
form1.BringToFront();
------解决方案--------------------
12楼的答案是正确的.
------解决方案--------------------
    private const int SW_SHOWNOACTIVATE = 4;
    private const int HWND_TOPMOST = -1;
    private const uint SWP_NOACTIVATE = 0x0010;
    [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
    static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
    [DllImport("user32.dll")]
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
    static void ShowInactiveTopmost(Form frm)
    {
        ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
        SetWindowPos(frm.Handle, HWND_TOPMOST, frm.Left, frm.Top, frm.Width, frm.Height, SWP_NOACTIVATE);
    }
------解决方案--------------------
用API函数:
[DllImport("user32.dll")]
public static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow);//显示窗口
调用:
Form1 f = new Form1();
ShowWindow(f.Handle,4);
------解决方案--------------------
设置窗体的TopLevel=false
------解决方案--------------------
  这个仿照QQ做的局域网聊天程序里面的,收到信息后在右下角弹出一个小框框提示用户收到信息:
private void ShowNotifyIcon(int ShowClass, string title, string content)
       {
           if (title == "") title = "新消息";
           CustomUIControls.TaskbarNotifier taskbarNotifier = new TaskbarNotifier();
           switch (ShowClass)
           {
               case 1:
                   taskbarNotifier.SetBackgroundBitmap(new Bitmap(GetType(), "skin.bmp"), Color.FromArgb(255, 0, 255));
                   taskbarNotifier.SetCloseBitmap(new Bitmap(GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), new Point(127, 8));
                   taskbarNotifier.TitleRectangle = new Rectangle(40, 9, 70, 25);
                   taskbarNotifier.ContentRectangle = new Rectangle(8, 41, 133, 68);
                   //taskbarNotifier1.TitleClick+=new EventHandler(TitleClick);