1、我想固定我的窗体的大小,就是说用户可以最小化我的窗口,但是不能最大化,也不能拉大我的窗体,请问我该怎么做?就像QQ的登陆窗体一样。2、我想用户点击“确定”的时候,我的窗体可以最小化到windows的通知区域,(还是拿QQ举例,就是QQ登陆后的在右下角有个小企鹅的图标),我该怎么做?3、我用process类怎么才可以实现关闭打开了特定网址的那个IE浏览器。先谢谢各位DD们了、。

解决方案 »

  1.   

    1 设置FormBorderStyle = FixedSingle;MaximizeBox = false;
    2.notifyicon
      

  2.   

    1:设置窗体属性如下:this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    this.MaximizeBox = false;
    this.MinimizeBox = true;
    2:要使用NotifyIcon,把此控件放到你的窗体上,然后参考下面的代码:bool exit=false;
    protected override void OnFormClosing(FormClosingEventArgs e)
    {
    base.OnFormClosing(e);
    if (!exit)
    {
    this.WindowState = FormWindowState.Minimized;
    this.ShowInTaskbar = false;
    e.Cancel = true;
    }
    }private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
    if (this.WindowState == FormWindowState.Minimized)
    {
    this.WindowState = FormWindowState.Normal;
    this.ShowInTaskbar = true;
    }
    else
    {
    this.WindowState = FormWindowState.Minimized;
    this.ShowInTaskbar = false;
    }
    }private void mnuClose_Click(object sender, EventArgs e)
    {
    this.exit = true;
    this.Close();
    }3:正在想...
      

  3.   

    1 this.FormBorderStyle = FormBorderStyle.FixedDialog;
                this.MaximizeBox = false;
                this.MinimizeBox = false;  2          NotifyIcon _NotifyIcon = new NotifyIcon();
                _NotifyIcon.Icon = this.Icon;
                _NotifyIcon.Visible = true;
     3           System.Diagnostics.Process.Start("http://www.zz.ha.cn");            System.Diagnostics.Process[] _ProcessList = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");            for (int i = 0; i != _ProcessList.Length; i++)
                {
                    MessageBox.Show(_ProcessList[i].MainWindowTitle);
                    //判断
                    //_ProcessList[i].Kill();  //关闭窗体
                }
      

  4.   

    虽然MinWindowTitle比较不准确,但是仅从Process来说这个是比较好用的了。没有想到更好的办法。
      

  5.   

    1、我想固定我的窗体的大小,就是说用户可以最小化我的窗口,但是不能最大化,也不能拉大我的窗体,请问我该怎么做?就像QQ的登陆窗体一样。 
    form窗体有个属性的,FormBorderStyle设置一下,为FixedSingle
    然后最大化的属性-MaximizeBox设为false.
      

  6.   

    System.Diagnostics.Process.Start("http://www.zz.ha.cn"); 3
      

  7.   

    第三个using System;
    using System.Collections.Generic;
    using System.Runtime;
    using System.Runtime.InteropServices;
    using System.Threading;
    using System.Diagnostics;
    using System.Text;namespace PM
    {
    class Program
    {
    static void Main(string[] args)
    {
    Console.OutputEncoding = Encoding.GetEncoding(936); EWD ew = new EWD(EnumWin);
    Process[] ps = Process.GetProcessesByName("IEXPLORE");
    foreach (Process p in ps)
    foreach (ProcessThread t in p.Threads)
    EnumThreadWindows(t.Id, ew, 0);
    } public static bool EnumWin(IntPtr hwnd, int lparam)
    {
    StringBuilder buff = new StringBuilder(256); IntPtr p;
    p = FindWindowEx(hwnd, IntPtr.Zero, "WorkerA", null);
    if (p == IntPtr.Zero)
    p = FindWindowEx(hwnd, IntPtr.Zero, "WorkerW", null);
    // 非浏览器窗口
    if (p == IntPtr.Zero)
    return true; p = FindWindowEx(p, IntPtr.Zero, "ReBarWindow32", null);
    p = FindWindowEx(p, IntPtr.Zero, "ComboBoxEx32", null);
    p = FindWindowEx(p, IntPtr.Zero, "ComboBox", null);
    p = FindWindowEx(p, IntPtr.Zero, "Edit", null); SendMessage(p, 13, buff.Capacity, buff);
    Console.WriteLine("Found {0} : {1}", p, buff); return true;
    } public delegate bool EWD(IntPtr hwnd, int lparam); [DllImport("user32.dll")]
    public extern static bool EnumThreadWindows(int dwThreadId, EWD lpfn, int lParam); [DllImport("user32.dll")]
    public extern static IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public extern static int SendMessage(IntPtr hWnd, int Msg, int wParam, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lParam);
    }
    }
    参考 http://topic.csdn.net/t/20020716/17/878893.html