Solved

vbSystemModal

Posted on 2001-09-16
8
767 Views
Last Modified: 2012-06-22
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.
0
Comment
Question by:Ryan9999
8 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6486072
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
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6486119
I thonk that constant is usefull on windows 3.x OS, since w95, it can't be used.
0
 
LVL 27

Accepted Solution

by:
Ark earned 100 total points
ID: 6486494
Hi

'==============Bas module code=============
Private Type RECT
     left As Long
     top As Long
     right As Long
     bottom As Long
End Type

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function ClipCursor& Lib "user32" (lpRect As RECT)
Public Declare Function ClipCursorBynum& Lib "user32" Alias "ClipCursor" (ByVal lpRect As Long)
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Const SPI_SCREENSAVERRUNNING = 97


Public Sub MakeSysModal(ByVal hwnd As Long)
    Dim rc As Rect
    GetWindowRect hwnd, rc
    ClipCursor rc
    SystemParametersInfo SPI_SCREENSAVERRUNNING, True, False, 0
End Sub

Public Sub MakeSysModelless(ByVal hwnd As Long)
    ClipCursorBynum 0&
    SystemParametersInfo SPI_SCREENSAVERRUNNING, False, True, 0
End Sub

In form load event - MakeSysModal me.hwnd
In form unload event - MakeSysModeless me.hwnd

Cheers

0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6486540
Hi!

Do you mean something like this:

Form1.Show 1

That's it!

glass cookie : )
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 44

Expert Comment

by:bruintje
ID: 6486553
Hi Richie, tested it in win98 and guess it worked then posted it, yes it's old so maybe not the most desirable :O)
0
 
LVL 27

Expert Comment

by:Ark
ID: 6486583
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
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6486593
Ark > thanks for that info
0
 
LVL 1

Author Comment

by:Ryan9999
ID: 6486641
thanks a lot just what i was looking for.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now