winform 窗體設計技巧收集

點擊button按鈕時 那個焦點虛線框怎麼去掉:html

protected override bool ShowFocusCueside

         {
             get
             {
                 return  false ;
             }
         }

C# WinForm 關於窗體最大化時的是否全屏效果與 是否 遮蓋任務欄

0.新建窗體 及添加按鈕post

1.
  執行以下按鈕事件
  private void btnFormMax_Click(object sender, EventArgs e)
  {
     if (this.WindowState == FormWindowState.Maximized)
     {
         this.WindowState = FormWindowState.Normal;
     }
     else
     {
         this.WindowState = FormWindowState.Maximized;
     }
  }
  窗體最大化時 非全屏 不會遮蓋任務欄
  此時this.FormBorderStyle 默認爲 Sizable
this

2.
  執行以下按鈕事件
  private void btnFormMax_Click(object sender, EventArgs e)
  {
      if (this.WindowState == FormWindowState.Maximized)
      {       
         this.WindowState = FormWindowState.Normal;
      }
      else
      {
         this.FormBorderStyle = FormBorderStyle.None;
         this.WindowState = FormWindowState.Maximized;
      }
   }
spa

  窗體最大化時 會全屏 及遮蓋任務欄
  此時this.FormBorderStyle 爲 None 不會顯示窗體標題欄等相關
.net

3.
  執行以下按鈕事件
  private void btnFormMax_Click(object sender, EventArgs e)
  {
      if (this.WindowState == FormWindowState.Maximized)
      {       
         this.WindowState = FormWindowState.Normal;
      }
      else
      {
         this.FormBorderStyle = FormBorderStyle.None;
         this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
         this.WindowState = FormWindowState.Maximized;
      }
   }
code

  窗體最大化時 非全屏 不會遮蓋任務欄
  此時this.FormBorderStyle 爲 None 不會顯示窗體標題欄等相關orm


【winform】窗體拖動、鼠標拖動時顯示虛線框,減小窗體繪製htm

這個方法的好處是不會屏蔽掉鼠標DoubleClick事件blog

http://www.cnblogs.com/liubiaocai/archive/2012/03/21/2410585.html

public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

        private const int WM_SYSCOMMAND = 0x0112;//點擊窗口左上角那個圖標時的系統信息
        private const int WM_MOVING = 0x216;//鼠標移動消息
        private const int SC_MOVE = 0xF010;//移動信息
        private const int HTCAPTION = 0x0002;//表示鼠標在窗口標題欄時的系統信息
        private const int WM_NCHITTEST = 0x84;//鼠標在窗體客戶區(除了標題欄和邊框之外的部分)時發送的消息
        private const int HTCLIENT = 0x1;//表示鼠標在窗口客戶區的系統消息
        private const int SC_MAXIMIZE = 0xF030;//最大化信息
        private const int SC_MINIMIZE = 0xF020;//最小化信息

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_MOVING: //若是鼠標移                 
                    base.WndProc(ref m);//調用基類的窗口過程——WndProc方法處理這個消息
                    if (m.Result == (IntPtr)HTCLIENT)//若是返回的是HTCLIENT
                    {
                        m.Result = (IntPtr)HTCAPTION;//把它改成HTCAPTION
                        return;//直接返回退出方法
                    }
                    break;
            }
            base.WndProc(ref m);//若是不是鼠標移動或單擊消息就調用基類的窗口過程進行處理
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
            }
            base.OnMouseMove(e);
        }
    }

winform 控件縮放四種方法:
 
 
MDI部分:
 
winform 如何去除MDI子窗體最大化後出來的標題欄?
MDI窗口的子窗體最大化後,如何去除其在MDI窗體中添加的標題欄

注:已將controlbox等按鈕設爲false,已將窗體的formborderstyle設爲none
高手給了一超簡單的解決辦法
MDI添加一個menuStrip,而後visible=false;便可(由於個人窗體是沒有菜單功能需求)
若是您的窗體已有菜單控件,而且須要完成一些功能,那麼就在它的itemadd事件里根據e.item.text控制一下吧。:)
 
父窗體中有Panel控件(panel上放置別的有用的控件),打開子窗體後,子窗體卻會被這個Panel擋住.請問有什麼解決方法嗎?
using System.Runtime.InteropServices;

[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);

   Form2 f2 = new Form2();
   f2.MdiParent = this;
   f2.Show();
   SetParent((int)f2.Handle, (int)this.Handle);
 
 C# 無邊框窗體的移動,任務欄右鍵菜單,調整大小
 http://ufo1199078.d101.58ym.cn/view.asp?id=5
http://blog.csdn.net/qqq122281069/article/details/5283012
相關文章
相關標籤/搜索