限制Form Resize的最大值

only睿醇

only睿醇

2016-02-19 16:51

有一种朋友不在生活里,却在生命力;有一种陪伴不在身边,却在心间。图老师即在大家的生活中又在身边。这么贴心的服务你感受到了吗?话不多说下面就和大家分享限制Form Resize的最大值吧。

  当Form的Position更动或大小改变时,会Send WM_GETMINMAXINFO的讯息,当我们取得这个讯息时,可以更动该讯息内定Windows Resize的值,不过本人目前只有测出如何限定其最大的Size,而最小的Size目前没有测出来,知道可者告诉我

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)

  

Option Explicit'以下程式在module1.basDeclare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As LongDeclare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _ (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, _  ByVal wParam As Long, ByVal lParam As Long) As LongDeclare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _  lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)Public Const GWL_WNDPROC = (-4)Public Const WM_GETMINMAXINFO = &H24Type POINTAPI    x As Long    y As LongEnd TypeType MINMAXINFO    ptReserved As POINTAPI    ptMaxSize As POINTAPI    ptMaxPosition As POINTAPI    ptMinTrackSize As POINTAPI    ptMaxTrackSize As POINTAPIEnd TypePublic preWinProc As LongPublic Function wndproc(ByVal hwnd As Long, ByVal Msg As Long, _             ByVal wParam As Long, ByVal lParam As Long) As LongDim lwd As Long, hwd As LongIf Msg = WM_GETMINMAXINFO Then   Dim maxmin As MINMAXINFO   CopyMemory maxmin, ByVal lParam, Len(maxmin)   maxmin.ptMaxTrackSize.x = 500 '设定最大Resize的宽度   maxmin.ptMaxTrackSize.y = 400 '设定最大Resize的高度   'maxmin.ptMinTrackSize.x = 300 '设定最大小Resize的宽度   'maxmin.ptMinTrackSize.y = 300 '设定最大小Resize的高度   CopyMemory ByVal lParam, maxmin, Len(maxmin)End If'将之送往原来的Window Procedurewndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)End Function'以下在FormSub Form_Load()Dim ret As Long'记录原本的Window Procedure的位址preWinProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)ret = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf wndproc)End SubPrivate Sub Form_Unload(Cancel As Integer)Dim ret As Long'取消Message的截取,而使之又只送往原来的Window Procedureret = SetWindowLong(Me.hwnd, GWL_WNDPROC, preWinProc)End Sub

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
展开更多 50%)
分享

猜你喜欢

限制Form Resize的最大值

编程语言 网络编程
限制Form Resize的最大值

TTL值最大值和默认值是多少

服务器
TTL值最大值和默认值是多少

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

大于N的最小值 小于M的最大值

电脑入门
大于N的最小值 小于M的最大值

一个求最大值与最小值的函数

ASP
一个求最大值与最小值的函数

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

限制FORM的大小

编程语言 网络编程
限制FORM的大小

《零:真红之蝶》不升级最大值 黑泽纱重123连视频

电脑网络
《零:真红之蝶》不升级最大值 黑泽纱重123连视频

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

如何将整个画面暗下来如同关机前一般

如何将整个画面暗下来如同关机前一般

操作系统有哪些

操作系统有哪些
下拉加载更多内容 ↓