ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 2649|回复: 5

[分享] 最大化最小化,控件隨視窗變更

[复制链接]

TA的精华主题

TA的得分主题

发表于 2008-3-5 15:28 | 显示全部楼层 |阅读模式
本帖已被收录到知识树中,索引项:Windows API应用
QUOTE:


Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Public Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_THICKFRAME = &H40000
Public Const WM_SETICON = &H80
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Sub add_menu(FM As Object)
Dim hwnd1 As Long
Dim IsTyle As Long
    hwnd1 = FindWindow(vbNullString, FM.Caption)
    IsTyle = GetWindowLong(hwnd1, GWL_STYLE)
    IsTyle = IsTyle Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_THICKFRAME
    SetWindowLong hwnd1, GWL_STYLE, IsTyle
End Sub


QUOTE:

Private Sub UserForm_Initialize() '定義視窗初始化
 Call add_menu(Me)
  taqw = Me.Width
  taqh = Me.Height
  oldw = Me.Width
  oldh = Me.Height

  tmp1 = 1
  tmp2 = 1

End Sub


QUOTE:

Private Sub UserForm_Resize()   'Userform 的大小變更變數

Dim oldw2, oldh2     '將所有物件定義為變數
Dim cbar As Control

oldw2 = Me.Width / oldw
oldh2 = Me.Height / oldh
 
If (dcut Mod 2) <> 0 Then
 For Each cbar In Me.Controls
    With cbar
     .Width = .Width * oldw2
     .Height = .Height * oldh2
     .Left = .Left * oldw2
     .Top = .Top * oldh2
    End With
 Next cbar
Else
 For Each cbar In Me.Controls
    With cbar
     .Width = .Width / tmp1
     .Height = .Height / tmp2
     .Left = .Left / tmp1
     .Top = .Top / tmp2
    End With
 Next cbar
End If
 
 dcut = dcut + 1
 tmp1 = oldw2
 tmp2 = oldh2
 
 UserForm1.Repaint

End Sub

[此贴子已经被作者于2008-3-5 15:31:23编辑过]

评分

1

查看全部评分

TA的精华主题

TA的得分主题

发表于 2008-3-5 15:41 | 显示全部楼层
有文件么?

TA的精华主题

TA的得分主题

发表于 2008-3-5 16:56 | 显示全部楼层
QUOTE:
以下是引用冰山上的来客在2008-3-5 15:41:59的发言:
有文件么?

[分享]Excel小秘书(开放源码)

里面的“文字转换”就有这个功能,有兴趣可以看看......

TA的精华主题

TA的得分主题

发表于 2010-6-6 13:21 | 显示全部楼层
这部分无法定义,谁能解决?
Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_THICKFRAME = &H40000
Public Const WM_SETICON = &H80

TA的精华主题

TA的得分主题

发表于 2010-6-6 15:24 | 显示全部楼层
楼主的代码从何处来的,能说说吗?

TA的精华主题

TA的得分主题

发表于 2012-12-4 22:33 | 显示全部楼层
请问楼主,这个问题,如何解决呢:
http://www.exceltip.net/thread-42666-1-1.html
谢谢!
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-12-4 02:32 , Processed in 0.053169 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表