Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default UserForm collapse ?

Hi Just wondering If anyone knows a way to add the icon "_" to collapse a
userform along with "X"(close form icon) that usually comes up on the form
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default UserForm collapse ?

Try (not fully tested):

Option Explicit

Private Declare Function FindWindowA Lib "user32" _
(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 GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nindex As Long) As Long

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

Private Sub UserForm_Initialize()
SetWindowStyle FindWindowA(vbNullString, Me.Caption), _
WS_MINIMIZEBOX, True
End Sub

Private Sub SetWindowStyle(hWnd As Long, _
mAttribute As Long, Enable As Boolean)
Dim x As Long
x = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
x = x Or mAttribute
Else
x = x And Not mAttribute
End If
SetWindowLong hWnd, GWL_STYLE, x
End Sub

All the code should go into the UserForm module.

--

Vasant


"vbastarter" wrote in message
...
Hi Just wondering If anyone knows a way to add the icon "_" to collapse a
userform along with "X"(close form icon) that usually comes up on the form
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default UserForm collapse ?

Thank you it works.

"Vasant Nanavati" wrote:

Try (not fully tested):

Option Explicit

Private Declare Function FindWindowA Lib "user32" _
(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 GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nindex As Long) As Long

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

Private Sub UserForm_Initialize()
SetWindowStyle FindWindowA(vbNullString, Me.Caption), _
WS_MINIMIZEBOX, True
End Sub

Private Sub SetWindowStyle(hWnd As Long, _
mAttribute As Long, Enable As Boolean)
Dim x As Long
x = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
x = x Or mAttribute
Else
x = x And Not mAttribute
End If
SetWindowLong hWnd, GWL_STYLE, x
End Sub

All the code should go into the UserForm module.

--

Vasant


"vbastarter" wrote in message
...
Hi Just wondering If anyone knows a way to add the icon "_" to collapse a
userform along with "X"(close form icon) that usually comes up on the form
Thanks




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
collapse rows into one Vic Excel Discussion (Misc queries) 2 September 21st 09 09:21 PM
Row Collapse control GatorVTX Excel Discussion (Misc queries) 2 January 20th 09 01:42 AM
Collapse Rows? LiveUser Excel Discussion (Misc queries) 10 February 6th 08 08:22 PM
Subtotals Don't Collapse Correctly Brenda from Michigan Excel Discussion (Misc queries) 1 September 18th 07 04:08 PM
Help Screens collapse RWN Setting up and Configuration of Excel 0 February 2nd 05 05:08 AM


All times are GMT +1. The time now is 07:27 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"