Link to home
Start Free TrialLog in
Avatar of Ryan9999
Ryan9999

asked on

vbSystemModal

how do you load a form as vbSystemModal so that the user can't switch to anything else until they click the apply button on your form.
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hi Ryan9999, you could play around with the following code

' first the declare

Private Declare Function SetWindowPos Lib "User32" (ByVal h%, ByVal hb%, ByVal X%, _
ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer

' then the function to make some form stay on top or not

Sub OnTop(frm As Form, OnTopFlag%)

    '[Declarations]
    Const SWP_NOMOVE = 2
    Const SWP_NOSIZE = 1
    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2

    '[Code]
    If OnTopFlag% Then
        res = SetWindowPos(frm.hWnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE)
    Else
        res = SetWindowPos(frm.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE)
    End If

End Sub

' and then the form load event with formname and in this case true to make it stay on top

Private Sub Form_Load()
  Call OnTop(Form1, (True))
End Sub

HTH:O)Bruintje
Avatar of Richie_Simonetti
I thonk that constant is usefull on windows 3.x OS, since w95, it can't be used.
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of glass_cookie
glass_cookie

Hi!

Do you mean something like this:

Form1.Show 1

That's it!

glass cookie : )
Hi Richie, tested it in win98 and guess it worked then posted it, yes it's old so maybe not the most desirable :O)
In Win16 TOPMOST = SysModal.
In Win32 HWND_TOPMOST mean TOPMOST, not SysModal, ie user can switch to any task and execute it, your windows wil stay on top but no active.

Cheers
Ark > thanks for that info
Avatar of Ryan9999

ASKER

thanks a lot just what i was looking for.