新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
objRange.Borders(XlBordersIndex.xlEdgeBottom).LineStyle = XlLineStyle.xlContinuous
10年积累的成都网站制作、网站建设、外贸网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计制作后付款的网站建设流程,更有仪征免费网站建设让你可以放心的选择与我们合作。
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"/ 句柄」 窗体 边框样式变为无边框。/summary
public static uint 无边框窗体(IntPtr 句柄) {
uint style = API_窗口.GetWindowLong(句柄, GWL_STYLE);
style = ~WS_BORDER;
style = ~WS_THICKFRAME;
return API_窗口.SetWindowLong(句柄, GWL_STYLE, style); ;
}
API窗口静态类
[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
/// 设置窗体的位置和大小。
/// /summary
/// param name="hWnd"/param
/// param name="hWndInsertAfter"用于标识在z-顺序的此 CWnd 对象之前的 CWnd 对象。
/// para/para如果uFlags参数中设置了SWP_NOZORDER标记则本参数将被忽略。可为下列值之一:
/// para/paraHWND_BOTTOM:值为1,将窗体置于Z序的底部。如果参数hWnd标识了一个顶层窗体,则窗体失去顶级位置,并且被置在其他窗体的底部。
/// para/paraHWND_NOTOPMOST:值为-2,将窗体置于所有非顶层窗体之上(即在所有顶层窗体之后)。如果窗体已经是非顶层窗体则该标志不起作用。
/// para/paraHWND_TOP:值为0,将窗体置于Z序的顶部。
/// para/paraHWND_TOPMOST:值为-1,将窗体置于所有非顶层窗体之上。即使窗体未被激活窗体也将保持顶级位置。/param
/// param name="x"窗体新的x坐标。如hwnd是一个子窗体,则x用父窗体的客户区坐标表示/param
/// param name="y"窗体新的y坐标。如hwnd是一个子窗体,则y用父窗体的客户区坐标表示/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
/// 调整指定 「 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 调整窗体(IntPtr 句柄, int x, int y, int w, int h) {
return API_窗口.SetWindowPos(句柄, 0, x, y, w, h, wFlags.SWP_NOZORDER);
}
/// summary
/// 调整指定 「 see cref="IntPtr"/ 句柄」 窗体的位置。
/// /summary
/// param name="句柄"指定 「 see cref="IntPtr"/ 句柄」 窗体/param
/// param name="x"横坐标/param
/// param name="y"纵坐标/param
public static int 调整窗体位置(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
以下代码添加到你需要触发的事件里:
1,把你的textbox的Multiline改成True(如果此处不修改你后面修改大小的时候只能修改width,而不能修改height),如果希望自动修改height,你的字体也要修改
2,添加这句代码(假设你要修改大小的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事件中实现
2.调用windows API
实现方式为:
1.在mouse事件中实现
[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); //设置移动后的位置
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.调用windows API
调用前需要添加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(); //释放鼠标捕捉
//发送左键点击的消息至该窗体(标题栏)
SendMessage(Handle, 0xA1, 0x02, 0);
}
}