Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vbSystemModal

Posted on 2001-09-16
8
Medium Priority
?
842 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 400 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…
Suggested Courses

688 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