objRange.Borders(XlBordersIndex.xlEdgeBottom).LineStyle = XlLineStyle.xlContinuous
10年積累的成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)經(jīng)驗,可以快速應對客戶對網(wǎng)站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡服務。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計制作后付款的網(wǎng)站建設(shè)流程,更有儀征免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
objRange.Borders(XlBordersIndex.xlEdgeBottom).ColorIndex = 1
objRange.Borders(XlBordersIndex.xlEdgeBottom).Weight = XlBorderWeight.xlThin
? private const int GWL_STYLE = (-16);
? private const int GWL_EXSTYLE = (-20);
? private const uint WS_EX_LAYERED = 0x80000;
? private const uint WS_EX_TRANSPARENT = 0x20;
? private const uint WS_THICKFRAME = 262144;
? private const uint WS_BORDER = 8388608;
/// summary使指定 「 see cref="IntPtr"/ 句柄」 窗體 邊框樣式變?yōu)闊o邊框。/summary
? public static uint 無邊框窗體(IntPtr 句柄) {
? ? ? uint style = API_窗口.GetWindowLong(句柄, GWL_STYLE);
? ? ? style = ~WS_BORDER;
? ? ? style = ~WS_THICKFRAME;
? ? ? return API_窗口.SetWindowLong(句柄, GWL_STYLE, style); ;
? }
API窗口靜態(tài)類
? [DllImport("user32", EntryPoint = "SetWindowLong")]
? public static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
? [DllImport("user32", EntryPoint = "GetWindowLong")]
? public static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
修改窗口位置
/// summary
? /// 設(shè)置窗體的位置和大小。
? /// /summary
? /// param name="hWnd"/param
? /// param name="hWndInsertAfter"用于標識在z-順序的此 CWnd 對象之前的 CWnd 對象。
? /// para/para如果uFlags參數(shù)中設(shè)置了SWP_NOZORDER標記則本參數(shù)將被忽略。可為下列值之一:
? /// para/paraHWND_BOTTOM:值為1,將窗體置于Z序的底部。如果參數(shù)hWnd標識了一個頂層窗體,則窗體失去頂級位置,并且被置在其他窗體的底部。
? /// para/paraHWND_NOTOPMOST:值為-2,將窗體置于所有非頂層窗體之上(即在所有頂層窗體之后)。如果窗體已經(jīng)是非頂層窗體則該標志不起作用。
? /// para/paraHWND_TOP:值為0,將窗體置于Z序的頂部。
? /// para/paraHWND_TOPMOST:值為-1,將窗體置于所有非頂層窗體之上。即使窗體未被激活窗體也將保持頂級位置。/param
? /// param name="x"窗體新的x坐標。如hwnd是一個子窗體,則x用父窗體的客戶區(qū)坐標表示/param
? /// param name="y"窗體新的y坐標。如hwnd是一個子窗體,則y用父窗體的客戶區(qū)坐標表示/param
/// param name="Width"指定新的窗體寬度/param
/// param name="Height"指定新的窗體高度/param
? /// param name="wFlags"/param
? /// returns/returns
? [DllImport("user32.dll", CharSet = CharSet.Ansi, EntryPoint = "SetWindowPos")]
? public static extern int SetWindowPos(IntPtr hWnd, hWndInsertAfter hWndInsertAfter, int x, int y, int Width, int Height, wFlags wFlags);
? /// summary
? /// 調(diào)整指定 「 see cref="IntPtr"/ 句柄」 窗體的位置和尺寸。
? /// /summary
? /// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗體/param
? /// param name="x"橫坐標/param
? /// param name="y"縱坐標/param
? /// param name="w"寬/param
? /// param name="h"高/param
? public static int 調(diào)整窗體(IntPtr 句柄, int x, int y, int w, int h) {
? ? ? return API_窗口.SetWindowPos(句柄, 0, x, y, w, h, wFlags.SWP_NOZORDER);
? }
? /// summary
? /// 調(diào)整指定 「 see cref="IntPtr"/ 句柄」 窗體的位置。
? /// /summary
? /// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗體/param
? /// param name="x"橫坐標/param
? /// param name="y"縱坐標/param
? public static int 調(diào)整窗體位置(IntPtr 句柄, int x, int y) {
? ? ? return API_窗口.SetWindowPos(句柄, 0, x, y, 0, 0, wFlags.SWP_NOSIZE | wFlags.SWP_NOZORDER);
? }
改變大小用Me.Width和Me.Height就行了,樓主想問的是允許用戶改變無邊框窗體的大小吧?
Public Class Form1
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Int32, ByVal nIndex As Int32) As Int32
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Int32, ByVal nIndex As Int32, ByVal dwNewLong As Int32) As Int32
Private Const GWL_STYLE As Int32 = -16
Private Const WS_THICKFRAME As Int32 = H40000
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim style As Int32 = GetWindowLong(Me.Handle, GWL_STYLE) Or WS_THICKFRAME
SetWindowLong(Me.Handle, GWL_STYLE, style)
End Sub
End Class
以下代碼添加到你需要觸發(fā)的事件里:
1,把你的textbox的Multiline改成True(如果此處不修改你后面修改大小的時候只能修改width,而不能修改height),如果希望自動修改height,你的字體也要修改
2,添加這句代碼(假設(shè)你要修改大小的textbox就是textbox1):
TextBox1.Location = New System.Drawing.Point(5, 20) '5, 20是你定義的針對窗體左上角點的X和Y位置
textbox1.size= New System.Drawing.Size(500, 600)‘500, 600是你自己定義的寬(width)和高(height)
3,或者直接寫成:
TextBox1.Multiline = True’允許修改多行文本框
TextBox1.Location = New Point(5, 20) '5, 20是你定義的針對窗體左上角點的水平X和垂直Y位置
TextBox1.Size = New System.Drawing.Size(500, 600)‘500, 600是你自己定義的寬(width)和高(height)
1.在mouse事件中實現(xiàn)
2.調(diào)用windows API
實現(xiàn)方式為:
1.在mouse事件中實現(xiàn)
[csharp] view plain copy
Point mouseOff;//鼠標移動位置變量
bool leftFlag;//標簽是否為左鍵
private void groupControl1_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)
{
leftFlag = false;//釋放鼠標后標注為false;
}
}
private void groupControl1_MouseMove(object sender, MouseEventArgs e)
{
if (leftFlag)
{
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //設(shè)置移動后的位置
Location = mouseSet;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標注為true;
}
}
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOff = new Point(-e.X, -e.Y); //得到變量的值
leftFlag = true; //點擊左鍵按下時標注為true;
}
}
2.調(diào)用windows API
調(diào)用前需要添加using System.Runtime.InteropServices;
[csharp] view plain copy
[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 void groupControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); //釋放鼠標捕捉
//發(fā)送左鍵點擊的消息至該窗體(標題欄)
SendMessage(Handle, 0xA1, 0x02, 0);
}
}
網(wǎng)站標題:vb.net伸縮框的簡單介紹
標題來源:http://chinadenli.net/article22/hesecc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、微信小程序、響應式網(wǎng)站、手機網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、網(wǎng)站設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)