Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Show/Hide Minimize/Maximize Button in Excel 2007/2010

I found this code posted by Chip Pearson on the internet.

Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const GWL_STYLE = (-16)

Private Declare Function GetWindowLong Lib "user32" Alias
"GetWindowLongA" ( _
ByVal HWnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias
"SetWindowLongA" ( _
ByVal HWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Sub ShowMinMax(ShowMin As Boolean, ShowMax As Boolean)
Dim WinInfo As Long
WinInfo = GetWindowLong(Application.HWnd, GWL_STYLE)

If ShowMin = True Then
WinInfo = WinInfo Or WS_MINIMIZEBOX
Else
WinInfo = WinInfo And (Not WS_MINIMIZEBOX)
End If
If ShowMax = True Then
WinInfo = WinInfo Or WS_MAXIMIZEBOX
Else
WinInfo = WinInfo And (Not WS_MAXIMIZEBOX)
End If
SetWindowLong Application.HWnd, GWL_STYLE, WinInfo
End Sub

How do I pass a variable to implement the ShowMinMax routine?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Show/Hide Minimize/Maximize Button in Excel 2007/2010

Sub GetStarted
Dim BigSize as Boolean
Dim SmallSize as Boolean

BigSize = True
Call ShowMinMax(SmallSize, BigSize)
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(Formats & Styles: lists or removes unused styles & number formats - in the free folder)





wrote in message
...
I found this code posted by Chip Pearson on the internet.

Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const GWL_STYLE = (-16)

Private Declare Function GetWindowLong Lib "user32" Alias
"GetWindowLongA" ( _
ByVal HWnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias
"SetWindowLongA" ( _
ByVal HWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Sub ShowMinMax(ShowMin As Boolean, ShowMax As Boolean)
Dim WinInfo As Long
WinInfo = GetWindowLong(Application.HWnd, GWL_STYLE)

If ShowMin = True Then
WinInfo = WinInfo Or WS_MINIMIZEBOX
Else
WinInfo = WinInfo And (Not WS_MINIMIZEBOX)
End If
If ShowMax = True Then
WinInfo = WinInfo Or WS_MAXIMIZEBOX
Else
WinInfo = WinInfo And (Not WS_MAXIMIZEBOX)
End If
SetWindowLong Application.HWnd, GWL_STYLE, WinInfo
End Sub

How do I pass a variable to implement the ShowMinMax routine?
TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Show/Hide Minimize/Maximize Button in Excel 2007/2010

On Sun, 23 Jan 2011 10:29:38 -0800, "Jim Cone"
wrote:

Sub GetStarted
Dim BigSize as Boolean
Dim SmallSize as Boolean

BigSize = True
Call ShowMinMax(SmallSize, BigSize)
End Sub


Thank you so much.

It's interesiting to note the effect of the four different combination
possibilities.

BigSize = False, SmallSize = False hides both restore and minimize
buttons.

BigSize = True, SmallSize = True restores/shows both restore and
minimize buttons.

BigSize = True, SmallSize = False - Shows both buttons with the
minimize button deactivated.

BigSize = False, SmallSize = True - Shows both buttons with the
restore button deactivated.

Again, Thank You. Your help is appreciated.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Minimize/Maximize button for Excel 2007 Application Steve Excel Programming 2 December 11th 09 10:22 PM
How to show the maximize button L. A. M. Excel Programming 1 July 13th 05 03:01 PM
how do i minimize/maximize a workbook from vba? I want to minimize it durring processing to speed things up a bit Daniel Excel Worksheet Functions 2 July 9th 05 03:35 AM
Minimize/Maximize excel restores command bars Rockee052[_53_] Excel Programming 3 March 3rd 04 12:27 AM
Maximize minimize and restore button No Name Excel Programming 1 October 27th 03 03:14 PM


All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"