C 無邊框窗體調整大小的方法

2021-06-08 04:53:13 字數 2694 閱讀 1063

#region 窗體大小調整的方法

public bool ismousedown = false;      

///

/// 調整大小時,滑鼠感應的邊框寬度

///

private int resizeborderwidth = 6;

///

/// 位置型別

///

private mouselocationstyle loactionstyle = mouselocationstyle.s22_middelcenter;

///

/// 上一次滑鼠座標

///

private point lastmoustlocation;

///

/// 根據滑鼠座標,返回滑鼠位置型別

///

/// 滑鼠距窗體左上角的座標

///

private mouselocationstyle getlocationstyle(point mouselocation)

//中上

if (mouselocation.x > resizeborderwidth &&

mouselocation.x <= this.width - resizeborderwidth &&

mouselocation.y <= resizeborderwidth)

//右上

if (mouselocation.x > this.width - resizeborderwidth &&

mouselocation.y <= resizeborderwidth)

//左中

if (mouselocation.x <= resizeborderwidth &&

mouselocation.y > resizeborderwidth &&

mouselocation.y <= this.height - resizeborderwidth)

//中中

if (mouselocation.x > resizeborderwidth &&

mouselocation.x <= this.width - resizeborderwidth &&

mouselocation.y > resizeborderwidth &&

mouselocation.y <= this.height - resizeborderwidth)

//右中

if (mouselocation.x > this.width - resizeborderwidth &&

mouselocation.y > resizeborderwidth &&

mouselocation.y <= this.height - resizeborderwidth)

//左下

if (mouselocation.x <= resizeborderwidth

&& mouselocation.y > this.height - resizeborderwidth)

//中下

if (mouselocation.x > resizeborderwidth &&

mouselocation.x <= this.width - resizeborderwidth &&

mouselocation.y > this.height - resizeborderwidth)

//右下

if (mouselocation.x > this.width - resizeborderwidth &&

mouselocation.y > this.height - resizeborderwidth)

throw new exception("未知區域");

}///

/// 根據滑鼠位置型別,返回滑鼠游標型別

///

/// 滑鼠位置型別

/// 滑鼠游標型別

private cursor getcursorbymouselocationstyle(mouselocationstyle mousestyle)

}///

/// 根據滑鼠座標和滑鼠座標型別調整窗體大小

///

/// 滑鼠座標

/// 滑鼠位置型別

private void changesize(point mouselocation, mouselocationstyle mousestyle)

if (newsize.width>250&&newsize.height>200)

this.size = newsize;

}///

/// 滑鼠座標型別列舉

/// 【用於調整窗體大小】

/// 【對應九宮格】

///

public enum mouselocationstyle

private void test_mousemove(object sender, mouseeventargs e)

y:", mouselocation.x, mouselocation.y);}}

else

}private void test_mousedown(object sender, mouseeventargs e)

private void test_mouseup(object sender, mouseeventargs e)

#endregion

C 移動無邊框窗體

private point mouseoffset private bool ismousedown false private void form1 mousedown object sender,system.windows.forms.mouseeventargs e private void...

C 無邊框控制窗體移動

雖然c 自帶有邊框,但是在開發過程中那個邊框並不是很好看,當我們不使用那個邊框的時候,那麼就會面臨乙個問題,沒有c 自帶的邊框了,那麼窗體怎麼進行移動呢?這涉及到c 的三個事件 1.mousedown 滑鼠單擊事件 2.mousemove 滑鼠經過事件 3.mouseup 滑鼠抬起事件 在寫的時候依...

無邊框窗體拖動和改變大小

const int htleft 10 const int htright 11 const int httop 12 const int httopleft 13 const int httopright 14 const int htbottom 15 const int htbottomlef...