Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Minimize Maximize buttons

How to add Minimize and Maximize/Restore Down buttons to a user form?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Minimize Maximize buttons

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user form?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Minimize Maximize buttons

Tom,

Thanks very much. The FormFun is very interesting. But the codes are too
complicated for me to adopt. I just want to have the bottons on the form once
the form is initialized.

Anyway, I apprecite your help.

Scott

"Tom Ogilvy" wrote:

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user form?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Minimize Maximize buttons

This is simplest code to add those buttons:

Option Explicit
Public Declare Function GetWindowLong _
Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong _
Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As
Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const GWL_STYLE As Long = (-16)
Private strFormType As String

Sub AddMinMax(strFormCaption As String)

Dim hwnd As Long
Dim lngStyle As Long

'this is not really necessary, vbNullString will do
If Val(Application.Version) = 9 Then
strFormType = "ThunderDFrame"
Else
strFormType = "ThunderXFrame"
End If

hwnd = FindWindow(strFormType, strFormCaption)
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or WS_MINIMIZEBOX

SetWindowLong hwnd, GWL_STYLE, lngStyle
DrawMenuBar hwnd

End Sub


Sub LoadForm()

Load UserForm1
UserForm1.Show 0

AddMinMax "Userform1"

End Sub


RBS


"Scott" wrote in message
...
Tom,

Thanks very much. The FormFun is very interesting. But the codes are too
complicated for me to adopt. I just want to have the bottons on the form
once
the form is initialized.

Anyway, I apprecite your help.

Scott

"Tom Ogilvy" wrote:

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user form?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Minimize Maximize buttons

Thanks for the help.

I copied your codes to my file, but I still did not get the buttons on my
UserForm1.

"RB Smissaert" wrote:

This is simplest code to add those buttons:

Option Explicit
Public Declare Function GetWindowLong _
Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong _
Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As
Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const GWL_STYLE As Long = (-16)
Private strFormType As String

Sub AddMinMax(strFormCaption As String)

Dim hwnd As Long
Dim lngStyle As Long

'this is not really necessary, vbNullString will do
If Val(Application.Version) = 9 Then
strFormType = "ThunderDFrame"
Else
strFormType = "ThunderXFrame"
End If

hwnd = FindWindow(strFormType, strFormCaption)
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or WS_MINIMIZEBOX

SetWindowLong hwnd, GWL_STYLE, lngStyle
DrawMenuBar hwnd

End Sub


Sub LoadForm()

Load UserForm1
UserForm1.Show 0

AddMinMax "Userform1"

End Sub


RBS


"Scott" wrote in message
...
Tom,

Thanks very much. The FormFun is very interesting. But the codes are too
complicated for me to adopt. I just want to have the bottons on the form
once
the form is initialized.

Anyway, I apprecite your help.

Scott

"Tom Ogilvy" wrote:

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user form?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Minimize Maximize buttons

If you can show the relevant code I might be able to tell you where you went
wrong.

RBS

"Scott" wrote in message
...
Thanks for the help.

I copied your codes to my file, but I still did not get the buttons on my
UserForm1.

"RB Smissaert" wrote:

This is simplest code to add those buttons:

Option Explicit
Public Declare Function GetWindowLong _
Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As
Long
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong _
Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long)
As
Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As
Long
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const GWL_STYLE As Long = (-16)
Private strFormType As String

Sub AddMinMax(strFormCaption As String)

Dim hwnd As Long
Dim lngStyle As Long

'this is not really necessary, vbNullString will do
If Val(Application.Version) = 9 Then
strFormType = "ThunderDFrame"
Else
strFormType = "ThunderXFrame"
End If

hwnd = FindWindow(strFormType, strFormCaption)
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or WS_MINIMIZEBOX

SetWindowLong hwnd, GWL_STYLE, lngStyle
DrawMenuBar hwnd

End Sub


Sub LoadForm()

Load UserForm1
UserForm1.Show 0

AddMinMax "Userform1"

End Sub


RBS


"Scott" wrote in message
...
Tom,

Thanks very much. The FormFun is very interesting. But the codes are
too
complicated for me to adopt. I just want to have the bottons on the
form
once
the form is initialized.

Anyway, I apprecite your help.

Scott

"Tom Ogilvy" wrote:

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user
form?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Minimize Maximize buttons

Did you do:
UserForm1.Show 0

So did you load the form as a modeless form?
A modeless form means you can do things outside the form (like doing things
in the sheet) while the form is loaded.
It doesn't work with a normal modal form, not sure now if it can.

RBS

"Scott" wrote in message
...
Thanks for the help.

I copied your codes to my file, but I still did not get the buttons on my
UserForm1.

"RB Smissaert" wrote:

This is simplest code to add those buttons:

Option Explicit
Public Declare Function GetWindowLong _
Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long) As
Long
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong _
Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long)
As
Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ShowWindow _
Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As
Long
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const GWL_STYLE As Long = (-16)
Private strFormType As String

Sub AddMinMax(strFormCaption As String)

Dim hwnd As Long
Dim lngStyle As Long

'this is not really necessary, vbNullString will do
If Val(Application.Version) = 9 Then
strFormType = "ThunderDFrame"
Else
strFormType = "ThunderXFrame"
End If

hwnd = FindWindow(strFormType, strFormCaption)
lngStyle = GetWindowLong(hwnd, GWL_STYLE)
lngStyle = lngStyle Or WS_MAXIMIZEBOX
lngStyle = lngStyle Or WS_MINIMIZEBOX

SetWindowLong hwnd, GWL_STYLE, lngStyle
DrawMenuBar hwnd

End Sub


Sub LoadForm()

Load UserForm1
UserForm1.Show 0

AddMinMax "Userform1"

End Sub


RBS


"Scott" wrote in message
...
Tom,

Thanks very much. The FormFun is very interesting. But the codes are
too
complicated for me to adopt. I just want to have the bottons on the
form
once
the form is initialized.

Anyway, I apprecite your help.

Scott

"Tom Ogilvy" wrote:

Stephen Bullen's site:
http://www.oaltd.co.uk/MVP/Default.htm
download FormFun.zip

uncompress it. Run/look at the code. Use the class module.

--
Regards,
Tom Ogilvy


"Scott" wrote:

How to add Minimize and Maximize/Restore Down buttons to a user
form?




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
minimize and maximize buttons missing KR4d Excel Discussion (Misc queries) 8 October 9th 09 03:32 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 and maximize buttons userforms RB Smissaert Excel Programming 15 February 26th 05 11:13 PM
Maximize & Minimize buttons where are they? Don Bowyer Excel Programming 3 July 18th 04 01:28 AM
How to get Maximize and Minimize buttons on Userform TBA[_2_] Excel Programming 1 September 9th 03 08:13 PM


All times are GMT +1. The time now is 06:52 PM.

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

About Us

"It's about Microsoft Excel"