ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel97 Userform to be system modal/equivalent (https://www.excelbanter.com/excel-programming/311510-excel97-userform-system-modal-equivalent.html)

George J

Excel97 Userform to be system modal/equivalent
 
I have done a bit of research online, but it seems that
setsysmodalwindow is not supported in 32bit systems, only
16bit so i can't use that.

I am ok with basic coding, but after that i don't have
much of a clue so if you could tell me what the code is
trying to do rather than what i think it is doing will be
a big help.

I understand that the xl97 userforms are modal, but you
can make use of a bug to make them modeless within the
application; but i am wanting the focus brought back to
the userform if another application is selected. (Forcing
the user to shut down the userform before doing anything
else)

I want to watch the userform's LostFocus event and use a
timer to continually check the form and restore if
required. The timer i can probably manage, but the
LostFocus has me, well - lost.

Very rough coding of what i have so far. (Not sure if
hWnd is available in excel97 so i have been struggling
with that also)


Private Declare Function SetActiveWindow Lib "user32.dll"
(ByVal gj As Long) As Long

Private Declare Function FindWindow Lib "user32"
Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As
String) As Long

Private Declare Function GetActiveWindow Lib "user32" ()
As Long

Private Sub Userform_LostFocus()
Dim gj As Long
Dim WinSelected as long
gj = FindWindow("ThunderXFrame", UserForm1.Caption)
WinSelected = GetActiveWindow()
On Error Resume Next
If Not WinSelected = gj Then
SetActiveWindow gj

End If
End Sub

As you can see, i need some serious help.
All comments welcome.
thanks
George


Tom Ogilvy

Excel97 Userform to be system modal/equivalent
 
A userform doesn't have a lostfocus event in xl97 to the best of my
knowledge.

there is no hwnd property in xl97

--
Regards,
Tom Ogilvy

"George J" wrote in message
...
I have done a bit of research online, but it seems that
setsysmodalwindow is not supported in 32bit systems, only
16bit so i can't use that.

I am ok with basic coding, but after that i don't have
much of a clue so if you could tell me what the code is
trying to do rather than what i think it is doing will be
a big help.

I understand that the xl97 userforms are modal, but you
can make use of a bug to make them modeless within the
application; but i am wanting the focus brought back to
the userform if another application is selected. (Forcing
the user to shut down the userform before doing anything
else)

I want to watch the userform's LostFocus event and use a
timer to continually check the form and restore if
required. The timer i can probably manage, but the
LostFocus has me, well - lost.

Very rough coding of what i have so far. (Not sure if
hWnd is available in excel97 so i have been struggling
with that also)


Private Declare Function SetActiveWindow Lib "user32.dll"
(ByVal gj As Long) As Long

Private Declare Function FindWindow Lib "user32"
Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As
String) As Long

Private Declare Function GetActiveWindow Lib "user32" ()
As Long

Private Sub Userform_LostFocus()
Dim gj As Long
Dim WinSelected as long
gj = FindWindow("ThunderXFrame", UserForm1.Caption)
WinSelected = GetActiveWindow()
On Error Resume Next
If Not WinSelected = gj Then
SetActiveWindow gj

End If
End Sub

As you can see, i need some serious help.
All comments welcome.
thanks
George




George J

Excel97 Userform to be system modal/equivalent
 
Well that would explain how i couldn't find any info on it
at least.

Any suggestions on a way i might be able to do something
along these lines??

thanks
George
-----Original Message-----
A userform doesn't have a lostfocus event in xl97 to the

best of my
knowledge.

there is no hwnd property in xl97

--
Regards,
Tom Ogilvy

"George J" wrote in

message
...
I have done a bit of research online, but it seems that
setsysmodalwindow is not supported in 32bit systems,

only
16bit so i can't use that.

I am ok with basic coding, but after that i don't have
much of a clue so if you could tell me what the code is
trying to do rather than what i think it is doing will

be
a big help.

I understand that the xl97 userforms are modal, but you
can make use of a bug to make them modeless within the
application; but i am wanting the focus brought back to
the userform if another application is selected.

(Forcing
the user to shut down the userform before doing anything
else)

I want to watch the userform's LostFocus event and use a
timer to continually check the form and restore if
required. The timer i can probably manage, but the
LostFocus has me, well - lost.

Very rough coding of what i have so far. (Not sure if
hWnd is available in excel97 so i have been struggling
with that also)


Private Declare Function SetActiveWindow

Lib "user32.dll"
(ByVal gj As Long) As Long

Private Declare Function FindWindow Lib "user32"
Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As
String) As Long

Private Declare Function GetActiveWindow Lib "user32" ()
As Long

Private Sub Userform_LostFocus()
Dim gj As Long
Dim WinSelected as long
gj = FindWindow("ThunderXFrame", UserForm1.Caption)
WinSelected = GetActiveWindow()
On Error Resume Next
If Not WinSelected = gj Then
SetActiveWindow gj

End If
End Sub

As you can see, i need some serious help.
All comments welcome.
thanks
George



.



All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com