ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm Caption (https://www.excelbanter.com/excel-programming/278767-userform-caption.html)

Soniya

UserForm Caption
 
Hi all,

How can I hede the userform caption bar?

so the user form will be without a title/caption bar.

TIA
Soniya

def

UserForm Caption
 
Whops, I misunderstood what do you want, sorry!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


keepITcool

UserForm Caption
 
it's a bit more complicated then you may have assumed
as it cannot be done without some API functions.

Note1: you MUST have a button on the form to close it!
Note2: The Private Declare lines MUST go at the top of a userform's
module



Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
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
Private Declare Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long

Private Function HideCaptionBar()
Dim lngHnd As Long
Dim lngStyle As Long
Dim lngH(1) As Long
Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
lngH(0) = Me.Height - Me.InsideHeight
If Val(Application.Version) 8 Then
lngHnd = FindWindow("ThunderDFrame", Me.Caption)
Else
lngHnd = FindWindow("ThunderXFrame", Me.Caption)
End If
lngStyle = GetWindowLong(lngHnd, GWL_STYLE) And Not WS_CAPTION
SetWindowLong lngHnd, GWL_STYLE, lngStyle
DrawMenuBar lngHnd
lngH(1) = Me.Height - Me.InsideHeight
Me.Height = Me.Height + lngH(1) - lngH(0)
End Function

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
HideCaptionBar
End Sub





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Soniya" wrote:

Hi all,

How can I hede the userform caption bar?

so the user form will be without a title/caption bar.

TIA
Soniya




All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com