CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

VB中如何让窗体无法调整大小?

楼主feng_8103(冯)2003-11-01 13:13:29 在 VB / 基础类 提问

请教:  
  VB中如何让窗体无法调整大小? 问题点数:20、回复次数:9Top

1 楼ipqn(i.Posei)回复于 2003-11-01 13:19:22 得分 0

gzTop

2 楼yoki(小马哥--鬓微霜,又何妨)回复于 2003-11-01 13:20:37 得分 2

设置窗体的BordStyle=3Top

3 楼sunnyBelt(一蓑烟雨)回复于 2003-11-01 13:28:38 得分 2

把窗体的borderstyle属性设置为fixed   diaglog,或者屏蔽窗体的最大化和最下化按钮minbutton=false;maxbutton=false并在窗体的resize事件中写上me.height=     me.width=Top

4 楼zyl910(编程的乐趣在于编程控制硬件,与用图形学实现绚丽效果)回复于 2003-11-01 13:35:00 得分 2

注意顺序:  
   
  BordStyle=1  
  MinButton=True  
  Top

5 楼since1990(level)回复于 2003-11-01 13:44:28 得分 0

up  
  Top

6 楼kmzs(.:RNPA:.山水岿濛)回复于 2003-11-01 14:23:24 得分 2

在form_resize中:  
  me.height=1000  
  me.width=1500Top

7 楼itlive(好友(暂别VB版))回复于 2003-11-01 15:47:03 得分 0

form.borderstyle=fixedsingleTop

8 楼hisofty(瘦马)回复于 2003-11-01 16:05:56 得分 10

利用子类处理技术限制窗体的大小    
  '   *   *   *   *   *   *   *   *   *   *   警告   *   *   *   *   *   *   *   *   *   *   *   *   *  
  '   对以下代码进行修改将有可能导致不可预料的后果,甚至能使您的VB崩溃!  
  '   在VB   IDE环境中运行本程序之前请先保存您的修改  
  '   不要使用断点调试模式,这将导致VB崩溃!  
  '   *   *   *   *   *   *   *   *   *   *   注意   *   *   *   *   *   *   *   *   *   *   *   *   *  
  模块:  
  Option   Explicit  
   
  Public   OldWindowProc   As   Long  
  Declare   Function   GetWindowLong   Lib   "user32"   Alias   "GetWindowLongA"   (ByVal   hwnd   As   Long,   ByVal   nIndex   As   Long)   As   Long  
  '从指定的窗口结构中取得信息  
  '参数/类型   说明  
  'hwnd(long):   欲为其获取信息的窗口的句柄  
  'nIndex(long):   欲取回的信息,可以是下述任何一个常数  
  'GWL_EXSTYLE:扩展窗口样式  
  'GWL_STYLE:窗口样式  
  'GWL_WNDPROC:该窗口的窗口函数的地址  
  'GWL_HINSTANCE:拥有窗口的实例的句柄  
  'GWL_HWNDPARENT:该窗口之父的句柄.不要用   SetWindowWord   来改变这个值  
  'GWL_ID:对话框中一个子窗口的标识符  
  'GWL_USERDATA:含义由应用程序规定  
  '对话框亦可指定下列常数  
  'DWL_DLGPROC:这个窗口的对话框函数地址  
  'DWL_MSGRESULT:在对话框函数中处理的一条消息返回的值  
  'DWL_USER:含义由应用程序规定  
  Declare   Function   SetWindowLong   Lib   "user32"   Alias   "SetWindowLongA"   (ByVal   hwnd   As   Long,   ByVal   nIndex   As   Long,   ByVal   dwNewLong   As   Long)   As   Long  
  '在窗体结构中为指定的窗口设置信息  
  '参数/类型   说明  
  'hwnd(long)   欲为其获取信息的窗口的句柄  
  'nIndex(long)   参考GetWindowLong函数  
  'dwNewLong(long)   由nIndex指定的窗口信息的新值  
  Declare   Sub   CopyMemory   Lib   "kernel32"   Alias   "RtlMoveMemory"   (pDest   As   Any,   pSource   As   Any,   ByVal   ByteLen   As   Long)  
  '这就是在VisualBasic中处理指针的"短柄斧"--CopyMemory.你可能在API文档中找不到它,但它确实存在,并且功能异常强大  
  '参数/类型   说明  
  'pDest   你想写入字节到其中的任何变量的ByRef参数(地址)  
  'pSource   要从其中进行复制的ByRef变量  
  'ByteLen   要复制的字节数  
  Declare   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   Long  
  '把控制权传回给原来的窗口过程  
  Public   Const   WM_GETMINMAXINFO   =   &H24  
  Type   POINTAPI  
   x   As   Long  
   y   As   Long  
  End   Type  
  '   This   is   the   structure   that   is   passed   by   reference(ByRef)(ie   an   address)   to   your   message   handler(消息侦听器)  
  '   The   key   items   in   this   structure   are   ptMinTrackSize   and   ptMaxTrackSize  
  Type   MINMAXINFO  
   ptReserved   As   POINTAPI  
   ptMaxSize   As   POINTAPI  
   ptMaxPosition   As   POINTAPI  
   ptMinTrackSize   As   POINTAPI  
   ptMaxTrackSize   As   POINTAPI  
  End   Type  
  Public   Function   SubClass1_WndMessage(ByVal   hwnd   As   Long,   ByVal   Msg   As   Long,   ByVal   wp   As   Long,   ByVal   lp   As   Long)   As   Long  
  '   Watch   for   the   pertinent   message   to   come   in  
   If   Msg   =   WM_GETMINMAXINFO   Then  
    Dim   MinMax   As   MINMAXINFO  
  '    This   is   necessary   because   the   structure   was   passed   by   its   address   and   there  
  '    is   currently   no   intrinsic   way   to   use   an   address   in   Visual   Basic  
    CopyMemory   MinMax,   ByVal   lp,   Len(MinMax)  
  '   This   is   where   you   set   the   values   of   the   MinX,MinY,MaxX,   and   MaxY  
  '   The   values   placed   in   the   structure   must   be   in   pixels.   The   values  
  '   normally   used   in   Visual   Basic   are   in   twips.   The   conversion   is   as   follows:  
  '    pixels   =   twips\twipsperpixel  
    MinMax.ptMinTrackSize.x   =   3975   \   Screen.TwipsPerPixelX  
    MinMax.ptMinTrackSize.y   =   1740   \   Screen.TwipsPerPixelY  
    MinMax.ptMaxTrackSize.x   =   Screen.Width   \   Screen.TwipsPerPixelX   \   2  
    MinMax.ptMaxTrackSize.y   =   3480   \   Screen.TwipsPerPixelY  
  '   Here   we   copy   the   datastructure   back   up   to   the   address   passed   in   the   parameters  
  '   because   Windows   will   look   there   for   the   information.  
    CopyMemory   ByVal   lp,   MinMax,   Len(MinMax)  
  '   This   message   tells   Windows   that   the   message   was   handled   successfully  
    SubClass1_WndMessage   =   1  
    Exit   Function  
   End   If  
  '   Here,   we   forward   all   irrelevant   messages   on   to   the   default   message   handler.  
   SubClass1_WndMessage   =   CallWindowProc(OldWindowProc,   hwnd,   Msg,   wp,   lp)  
  End   Function  
   
  窗体代码:  
  Option   Explicit  
   
  Private   Const   GWL_WNDPROC   =   (-4)  
  Private   Sub   Form_Load()  
  '   First,   we   need   to   store   the   address   of   the   existing   Message   Handler  
   OldWindowProc   =   GetWindowLong(Me.hwnd,   GWL_WNDPROC)  
  '   Now   we   can   tell   windows   to   forward   all   messages   to   out   own   Message   Handler  
   Call   SetWindowLong(Me.hwnd,   GWL_WNDPROC,   AddressOf   SubClass1_WndMessage)  
  End   Sub  
   
  Private   Sub   Form_Unload(Cancel   As   Integer)  
  '   We   must   return   control   of   the   messages   back   to   windows   before   the   program   exits  
  Call   SetWindowLong(Me.hwnd,   GWL_WNDPROC,   OldWindowProc)  
  End   SubTop

9 楼wxrwan(无奈小飞不耻上问)回复于 2003-11-01 16:17:57 得分 2

BordStyle=3  
  Top

相关问题

  • vfp----如何调整窗体的大小!!!!!!
  • 求救!关于窗体大小调整!???
  • 无模窗体如何调整大小
  • VB窗体大小如何固定?
  • mdi中子窗体的大小调整问题
  • 窗体大小的调整,解决就给米分!
  • 关于调整窗体大小的一个问题
  • 如何使打印预览窗体可调整大小!!!
  • 【问】如何做支持调整大小的异型窗体?
  • 如何调整窗体内控件大小

关键词

  • vb
  • me
  • 信息
  • 窗体
  • 大小
  • gwl
  • long

得分解答快速导航

  • 帖主:feng_8103
  • yoki
  • sunnyBelt
  • zyl910
  • kmzs
  • hisofty
  • wxrwan

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo