大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> 限定窗口大小范围--windows message subclassing

限定窗口大小范围--windows message subclassing

时间: 2021-07-31 作者:daque

imports system.windows.formsimports system.componentmodelnamespace vbcitynamespace formclassespublic class frmrestrictedinherits form'#region " iridium form properties code "private mformminsize, mformmaxsize as pointapi<category("formsize"), _description( _"the minimum height that the form can be sized to.")> _public property formminheight() as int32get' scs - a return of zero indicates that it has not been ' set. return mformminsize.yend getset(byval value as int32)checkbounds(value, false)mformminsize.y = valueend setend property ' formminheight<category("formsize"), _description( _"the maximum height that the form can be sized to.")> _public property formmaxheight() as int32get' scs - a return of zero indicates that it has not been ' set.return mformmaxsize.yend getset(byval value as int32)checkbounds(value, false)mformmaxsize.y = valueend setend property ' formmaxheight<category("formsize"), _description( _"the minimum width that the form can be sized to.")> _public property formminwidth() as int32get' scs - a return of zero indicates that it has not been ' set.return mformminsize.xend getset(byval value as int32)checkbounds(value, false)mformminsize.x = valueend setend property ' formminwidth<category("formsize"), _description( _"the maximum width that the form can be sized to.")> _public property formmaxwidth() as int32get' scs - a return of zero indicates that it has not been ' set.return mformmaxsize.xend getset(byval value as int32)checkbounds(value, false)mformmaxsize.x = valueend setend property ' formmaxwidth#end regionprivate sub checkbounds(byref pintvalue as int32, _byval pblncheckwidth as boolean)if pintvalue < 0 thenpintvalue = 0else' scs - check that the co-ords are not outside of the ' screen here?dim screenpoint as system.drawing.rectanglescreenpoint = screen.primaryscreen.bounds()if pblncheckwidth thenif pintvalue > screenpoint.width then pintvalue = _screenpoint.widthelseif pintvalue > screenpoint.height then pintvalue = _screenpoint.heightend ifend ifend subprotected overrides sub wndproc( _byref m as system.windows.forms.message)if m.msg = wm_getminmaxinfo thendim mmistruct as minmaxinfomybase.wndproc(m)' scs - get the information from lparam into our ' structuremmistruct = ctype(m.getlparam(mmistruct.gettype()), _minmaxinfo)' scs - the following line does the same - i haven't yet ' tested for speed to' see which is the quickest'mmistruct = ctype(marshal.ptrtostructure(m.lparam, ' mmistruct.gettype), minmaxinfo)' scs - set new structure values where applicablewith mmistructif not (mformmaxsize.x.equals(0)) then.ptmaxtracksize.x = mformmaxsize.xend ifif not (mformmaxsize.y.equals(0)) then.ptmaxtracksize.y = mformmaxsize.yend ifif not (mformminsize.x.equals(0)) then.ptmintracksize.x = mformminsize.xend ifif not (mformminsize.y.equals(0)) then.ptmintracksize.y = mformminsize.yend if'.ptmaxposition.x = 100'.ptmaxsize.x = 200end with' scs - copy the information back into lparammarshal.structuretoptr(mmistruct, m.lparam, true)' scs - return 0 because msdn tells us to.m.result() = new system.intptr()elsemybase.wndproc(m)end ifend subend classend namespacenamespace apipublic class clsgetminmaxinfo'microsoft.win32.interop.win.wm_getminmaxinfopublic const wm_getminmaxinfo as int32 = 100<structlayout(layoutkind.sequential)> _public structure pointapipublic x as int32public y as int32end structure<structlayout(layoutkind.sequential)> _public structure minmaxinfoprivate ptreserved as pointapiprivate ptmaxsize as pointapiprivate ptmaxposition as pointapipublic ptmintracksize as pointapipublic ptmaxtracksize as pointapiend structure<structlayout(layoutkind.sequential)> _public structure windowpospublic hwnd as int32public hwndinsertafter as int32public x as int32public y as int32public cx as int32public cy as int32public flags as int32end structureend classend namespaceend namespace

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.