Board logo

標題: [發問] 使用vba 使Excel視窗右上角之縮小放大"失效"? [打印本頁]

作者: yangjie    時間: 2014-7-3 08:52     標題: 使用vba 使Excel視窗右上角之縮小放大"失效"?

請教各位先進:
應如何使用vba 使Excel視窗右上角之縮小放大"失效"?
(Excel2003   Excel2010中均可使用)
作者: stillfish00    時間: 2014-7-4 14:54

本帖最後由 stillfish00 於 2014-7-4 14:55 編輯

回復 1# yangjie
google可找到用API的方法
[attach]18621[/attach]
[attach]18622[/attach]
  1. Option Explicit

  2. Public Const GWL_STYLE = (-16)
  3. Public Const WS_THICKFRAME = &H40000
  4. Public Const WS_MINIMIZEBOX = &H20000
  5. Public Const WS_MAXIMIZEBOX = &H10000

  6. Public Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" ( _
  7.     ByVal hWnd As Long, _
  8.     ByVal nIndex As Long) As Long

  9. Public Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" ( _
  10.     ByVal hWnd As Long, _
  11.     ByVal nIndex As Long, _
  12.     ByVal dwNewLong As Long) As Long


  13. Public Sub Prevent_Window_Resize()

  14.     Dim hWnd As Long
  15.     Dim style As Long
  16.     Dim ret As Long
  17.    
  18.     hWnd = Application.hWnd
  19.         
  20.     style = GetWindowLong(hWnd, GWL_STYLE)
  21.       
  22.     style = style And Not (WS_THICKFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
  23.     ret = SetWindowLong(hWnd, GWL_STYLE, style)
  24.    
  25. End Sub
複製代碼
要還原可把
style = style And Not (WS_THICKFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
改成
style = style OR (WS_THICKFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
再執行




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)