Hi,
I am trying to write below code in order to resize the userform i have created. However, I am getting the below error message. Can anyone help to debug this.
My system and MS office versions are: 64 bit
The error message is:
"Run-time error '453':
Can't find DLL entry point Get(Set)WindowLongPtrW in user32.dll
Below is the code I have written:
-----------------------------------------
I am trying to write below code in order to resize the userform i have created. However, I am getting the below error message. Can anyone help to debug this.
My system and MS office versions are: 64 bit
The error message is:
"Run-time error '453':
Can't find DLL entry point Get(Set)WindowLongPtrW in user32.dll
Below is the code I have written:
-----------------------------------------
Code:
Public Const SW_HIDE As Long = 0
Public Const SW_NORMAL As Long = 1
Public Const SW_SHOWMINIMIZED As Long = 2
Public Const SW_MAXIMIZED As Long = 3
Public Const WS_MAXIMIZEBOX As Long = &H10000
Public Const WS_MINIMIZEBOX As Long = &H20000
Public Const WS_THICKFRAME As Long = &H40000
Public Const WS_MAXIMIZE As Long = &H1000000
Public Const GWL_STYLE As Long = -16
#If Win64 Then
Public Declare PtrSafe Function GetWindowLong _
Lib "user32.dll" Alias "Get(Set)WindowLongPtrW" _
(ByVal hwnd As LongPtr, _
ByVal nIndex As LongLong) _
As LongPtr
Public Declare PtrSafe Function SetWindowLong _
Lib "user32.dll" Alias "SetWindowLongPtr" _
(ByVal hwnd As LongPtr, _
ByVal nIndex As Long, _
ByVal dwNewLong As LongPtr) _
As LongPtr
Public Declare PtrSafe Function ShowWindow _
Lib "user32.dll" _
(ByVal hwnd As LongPtr, _
ByVal nCmdShow As Long) _
As Long
Public Declare PtrSafe Function GetForegroundWindow Lib "user32.dll" () As LongPtr
Public Sub MakeFormResizable()
Dim lStyle As LongPtr
Dim hwnd As LongPtr
Dim RetVal As LongPtr
hwnd = GetForegroundWindow
'Get the basic window style
lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
'Set the basic window styles
RetVal = SetWindowLong(hwnd, GWL_STYLE, lStyle)
End Sub
#Else
Public Declare Function GetWindowLong _
Lib "user32.dll" Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long) _
As Long
Public Declare Function SetWindowLong _
Lib "user32.dll" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Public Declare Function ShowWindow _
Lib "user32.dll" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) _
As Long
Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Public Sub MakeFormResizable()
Dim lStyle As Long
Dim hwnd As Long
Dim RetVal As Long
hwnd = GetForegroundWindow
'Get the basic window style
lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
'Set the basic window styles
RetVal = SetWindowLong(hwnd, GWL_STYLE, lStyle)
End Sub
#End If
Last edited by a moderator: