Solved

vbSystemModal

Posted on 2001-09-16
8
787 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 28

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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
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 28

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

830 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