改变窗体大小的问题

pursue 2000-07-12 10:41:00
我想限制窗体改变大小。
我的窗体可以改变大小,但是我限制它小到某一尺寸时就不能再小了,就像画笔那样。
我试这在From_Resize函数中:
If Width<1000 Then Width=1000
If Height<1000 Then Height=1000
这样确实可以让窗体大小大于等于1000,1000可是效果不好,我是想得到画笔那样的效果,即小到1000,1000时鼠标无法再改变窗体的大小了
...全文
184 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skt642 2001-05-31
  • 打赏
  • 举报
回复
18786关注!
Un1 2000-07-17
  • 打赏
  • 举报
回复
看看这个例子:需要(subclass.ocx)

VERSION 5.00
Object = "{5B033ECF-098E-11D1-A4B2-444553540000}#1.0#0"; "Subclass.ocx"
Begin VB.Form Form1
Caption = "Limit Window Size Demo"
ClientHeight = 3165
ClientLeft = 1350
ClientTop = 1770
ClientWidth = 4740
ForeColor = &H80000008&
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3165
ScaleWidth = 4740
Begin SubclassCtl.Subclass Subclass1
Left = 120
Top = 120
_ExtentX = 741
_ExtentY = 741
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'GetMinMx - Subclassing Demonstration Program
'Copyright (c) 1997 SoftCircuits Programming (R)
'Redistributed by Permission.
'
'This example program demonstrates use of the Subclass OCX control.
'See Examples.txt for information specific to this example.
'
'The accompanying files may be distributed on the condition that they
'are distributed in full and unchanged, and that no fee is charged for
'such distribution with the exception of reasonable shipping and media
'charges. In addition, the code in these example programs may be
'incorporated into your own programs and the resulting programs may be
'distributed without payment of royalties.
'
'This example program was provided by:
' SoftCircuits Programming
' http://www.softcircuits.com
' P.O. Box 16262
' Irvine, CA 92623
Option Explicit

'Windows declarations
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (lpDest As Any, lpSource As Any, ByVal nCount As Long)

'Windows constants
Private Const WM_GETMINMAXINFO = &H24

'Windows data types
Private Type POINTAPI
x As Long
y As Long
End Type

Private Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End Type

Private Sub Form_Load()
'Setup Subclass
Subclass1.hWnd = Me.hWnd
Subclass1.Messages(WM_GETMINMAXINFO) = True
End Sub

Private Sub Subclass1_WndProc(Msg As Long, wParam As Long, lParam As Long, Result As Long)
Dim MinMax As MINMAXINFO

If Msg = WM_GETMINMAXINFO Then
'Copy to our local MinMax variable
CopyMemory MinMax, ByVal lParam, Len(MinMax)
'Set minimum/maximum tracking size
MinMax.ptMinTrackSize.x = 150
MinMax.ptMinTrackSize.y = 150
MinMax.ptMaxTrackSize.x = 400
MinMax.ptMaxTrackSize.y = 400
'Copy data back to Windows
CopyMemory ByVal lParam, MinMax, Len(MinMax)
Result = 0
End If
End Sub
twoy2000 2000-07-12
  • 打赏
  • 举报
回复
在Form_Resize()中检测鼠标的位置,用GetCursorPos(),SetCursorPos()函数,
Sub Form_Resize()
GetCursorpos(一个POINT类型的结构)
通过位置的分析可以达到要求
然后通过SetCursorPos()来控制鼠标的位置
茂奇软件 2000-07-12
  • 打赏
  • 举报
回复
I know a message WM_SIZING, you should deal it here.

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧