|
-
Mar 18th, 2009, 03:25 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Question about Userform
Is it possible to remove the header on a userform?
-
Mar 18th, 2009, 08:34 PM
#2
Re: Question about Userform
yes, try changing the border style to see if you can get what you want that way
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 18th, 2009, 09:45 PM
#3
Addicted Member
Re: Question about Userform
 Originally Posted by kelvjone
Is it possible to remove the header on a userform?
you mean take out the caption only or you don't want the user to close the form?
The taller the bamboo grows the lower it bends... 
-
Mar 19th, 2009, 12:13 AM
#4
Re: Question about Userform
There is no property of the userform to remove the titlebar as we can do it in VB6 (Which is also known as borderless form). To achieve what you want we have to use few API Calls. Create a userform and also create one commandbutton on it.
Paste this code in the Userform area...
Code:
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 Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Call RemTitleBar(Me)
End Sub
'~~> Removes Titlebar
Sub RemTitleBar(objForm As Object)
Dim lStyle As Long, hMenu As Long, mhWndForm As Long
If Val(Application.Version) < 9 Then
'~~> For Excel 97
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption)
Else
'~~> For Excel 2000 onwards
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption)
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
'~~> Draw the Final userform
DrawMenuBar mhWndForm
End Sub
Sub ShowForm()
UserForm1.Show False
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 19th, 2009, 12:38 PM
#5
Thread Starter
Addicted Member
Re: Question about Userform
Koolsid as ever you are a genius! Many thanks indeed!
-
Mar 19th, 2009, 12:42 PM
#6
Re: Question about Userform
 Originally Posted by kelvjone
Koolsid as ever you are a genius! Many thanks indeed!
Wish I was 
Everyday is a learning for me here in vbforums
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|