vb api 修改指定窗口大小 要怎么操作用哪个api?
2个回答
展开全部
给你一个很简单的API 参数简单,用起来简单。。
第一个:
FindWindow 用来找到窗口句柄。
第二个:
MoveWindow 用来设置窗体坐标及宽高。
-------------------------------------分割线---------------------------------------
exmple:
窗体标题:Test
具体实现
' API调用声明
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'API调用声明
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private sub Command_Click()
Dim HW as long
HW=FindWindow(VBNULLSTRING,"Test")
MoveWindow HW,0,0,200,300 ' 将该窗口X变为200 ,Y变为300
LZ需要多了解windows消息机制和API的熟练、
大家五一快乐。
第一个:
FindWindow 用来找到窗口句柄。
第二个:
MoveWindow 用来设置窗体坐标及宽高。
-------------------------------------分割线---------------------------------------
exmple:
窗体标题:Test
具体实现
' API调用声明
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'API调用声明
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private sub Command_Click()
Dim HW as long
HW=FindWindow(VBNULLSTRING,"Test")
MoveWindow HW,0,0,200,300 ' 将该窗口X变为200 ,Y变为300
LZ需要多了解windows消息机制和API的熟练、
大家五一快乐。
展开全部
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Myhwnd = FindWindow(vbNullString, "计算器") '得到计算器的句柄
SetWindowPos Myhwnd, -1, 400, 100, Me.Width \ 15, Me.Height \ 15, &H400 '设置计算器的大小和位置
End Sub
Private Sub Form_Load()
Shell "calc.exe", vbNormalNoFocus '打开计算器
End Sub
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Myhwnd = FindWindow(vbNullString, "计算器") '得到计算器的句柄
SetWindowPos Myhwnd, -1, 400, 100, Me.Width \ 15, Me.Height \ 15, &H400 '设置计算器的大小和位置
End Sub
Private Sub Form_Load()
Shell "calc.exe", vbNormalNoFocus '打开计算器
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询