Nuz
12-02-2011, 01:14 AM
I have created a userform that utilizes API calls to create a menu and to display an icon on the header.
When the userform is closed, the Excel freezes and becomes unresponsive. I figured it out it is due to the menu created with API's.
I have some cleaning measures with UserForm_QueryClose and UserForm_Terminate procedures but they seem not to help.
In both procedures I have:
DestroyMenu g_hMenu
SetWindowLong g_hForm, GWL_WNDPROC, g_lpMyWndProc
and:
Public Declare Function DestroyMenu _
Lib "user32" ( _
ByVal hMenu As Long) _
As Long
Public Declare Function SetWindowLong _
Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
How can I prevent Excel from freezing when the userform is closed?
When the userform is closed, the Excel freezes and becomes unresponsive. I figured it out it is due to the menu created with API's.
I have some cleaning measures with UserForm_QueryClose and UserForm_Terminate procedures but they seem not to help.
In both procedures I have:
DestroyMenu g_hMenu
SetWindowLong g_hForm, GWL_WNDPROC, g_lpMyWndProc
and:
Public Declare Function DestroyMenu _
Lib "user32" ( _
ByVal hMenu As Long) _
As Long
Public Declare Function SetWindowLong _
Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
How can I prevent Excel from freezing when the userform is closed?