Solved

vbSystemModal

Posted on 2001-09-16
8
754 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi!

Do you mean something like this:

Form1.Show 1

That's it!

glass cookie : )
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 44

Expert Comment

by:bruintje
Comment Utility
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
Comment Utility
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
Comment Utility
Ark > thanks for that info
0
 
LVL 1

Author Comment

by:Ryan9999
Comment Utility
thanks a lot just what i was looking for.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

15 Experts available now in Live!

Get 1:1 Help Now