Rolly_Sefu
Board Regular
- Joined
- Oct 25, 2013
- Messages
- 149
Hello.
I have a userform that when initialized textbox1.setfocus is run => all is ok
I needed to remove the caption and x button from the userform => textbox1 will not get selected
this is the code I used for the caption removal:
in a module:
in userform:
Does anyone know how to setfocus to the userform after the caption is removed ?
Thanks
I have a userform that when initialized textbox1.setfocus is run => all is ok
I needed to remove the caption and x button from the userform => textbox1 will not get selected
this is the code I used for the caption removal:
in a module:
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
Sub RemoveCaption(objForm As Object)
Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption) 'XL2000+
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm
End Sub
Sub button1()
UserForm1.Show False
End Sub
in userform:
Code:
Private Sub userform_initialize()
TextBox1.SetFocus
Call RemoveCaption(Me)
End Sub
Does anyone know how to setfocus to the userform after the caption is removed ?
Thanks
Last edited: