用api改变窗口大小?

whupyf 武汉大学 2004-04-03 04:54:37
一个窗口
BorderStyle=None '没有标题栏

我希望鼠标拖动右下角可以改变窗口的大小.该怎么办?
...全文
74 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
pcwak 2004-04-03
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

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 Const SWP_FRAMECHANGED = &H20

Private Const SWP_NOSIZE = &H1

Private Const SWP_NOZORDER = &H4

Private Const SWP_NOMOVE = &H2

Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED

Private Const GWL_EXSTYLE = (-20)

Private Const GWL_STYLE = (-16)

Private Const WS_THICKFRAME = &H40000

Sub Resizecontrol(ctlName As Form, frmName As Form)
Dim NewStyle As Long
NewStyle = GetWindowLong(ctlName.hwnd, GWL_STYLE)
NewStyle = NewStyle Or WS_THICKFRAME
NewStyle = SetWindowLong(ctlName.hwnd, GWL_STYLE, NewStyle)
SetWindowPos ctlName.hwnd, frmName.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
End Sub

Private Sub Form_Load()
Resizecontrol Form1, Form1
End Sub
回复
qiangsheng 2004-04-03
BorderStyle设成Sizable,清除Caption,ControlBox设成False。
回复
发动态
发帖子
API
创建于2007-09-28

1455

社区成员

VB API
申请成为版主
社区公告
暂无公告