I use the following script on my home computer to remove captions, however I can not use it on my work computer which is excel 2010 64bit.
I found info on changing the script to prtsafe so I made all the adjustments but it still would not work, it kept getting stuck on the hwnd section even with ptrsafe and prt added.
then in my userform I have the following.
I found info on changing the script to prtsafe so I made all the adjustments but it still would not work, it kept getting stuck on the hwnd section even with ptrsafe and prt added.
Code:
Option Compare Text
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Long
' Public Declare Function GetForegroundWindow _
Lib "user32.dll" () As Long
Private Declare Function GetWindowLong Lib "user32.dll" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long _
) As Long
Private Declare Function SetWindowLong Lib "user32.dll" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long _
) As Long
Private Declare Function DrawMenuBar Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const WS_CAPTION = &HC00000
Function RemoveCaption3(ByVal hwnd As Long)
Dim BitMask As Long
Dim WindowStyle As Long
WindowStyle = GetWindowLong(hwnd, GWL_STYLE)
BitMask = WindowStyle And (Not WS_CAPTION)
Call SetWindowLong(hwnd, GWL_STYLE, BitMask)
Call DrawMenuBar(hwnd)
End Function
Function RestoreCaption3(ByVal hwnd As Long)
Dim BitMask As Long
Dim WindowStyle As Long
WindowStyle = GetWindowLong(hwnd, GWL_STYLE)
BitMask = WindowStyle Or WS_CAPTION
Call SetWindowLong(hwnd, GWL_STYLE, BitMask)
Call DrawMenuBar(hwnd)
End Function
'Example of Restoring Excel's Caption
Sub Restore_Windows_Caption()
RestoreCaption3 Application.hwnd
End Sub
Sub RestoreTitleBars()
Dim i As Long
Dim hwnd As Long
For i = 0 To UserForms.Count - 1
hwnd = FindWindow(vbNullString, UserForms(i).Caption)
RestoreCaption3 Application.hwnd
Next
End Sub
then in my userform I have the following.
Code:
Option Compare Text
Dim myClipbd As New DataObject
Private m_sngX As Single
Private m_sngY As Single
Option Explicit
Private Const MResizer = "ResizeGrab"
Private WithEvents m_objResizer As MSForms.Label
Private m_sngLeftResizePos As Single
Private m_sngTopResizePos As Single
Private m_blnResizing As Single
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
' wait method for miliseconds sleep 500 = 1/2 a second
'Sleep 500
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, ByVal lngWinIdx As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hwnd As Long, ByVal lngWinIdx As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
ByVal hwnd As Long, ByVal crKey As Integer, _
ByVal bAlpha As Integer, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = &HFFEC
Dim hwnd As Long
''''''''''''''''''''''
''''''''''''''''''''''
'MAKE SURE TO SET YOUR CAPTION PROPERTIES ON LEFT TO USERFORM NAM NOT BLANK
'OTHERWISE TITLE BAR WILL NOT REMOVE
''''''''''''''''''''''
''''''''''''''''''''''
Private Sub UserForm_Activate()
Dim lHwnd As Long
lHwnd = FindWindow(vbNullString, Me.Caption)
RemoveCaption3 lHwnd