Forms

How to make a startup form Modal ?

when the form is in normal state, and then some other window is behind, if you click outside , the window disappears.
PaulrajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GordonpCommented:
You get nothing for nothing I'm afraid.
But as i'm feeling generous...

you cant make the startup form modal, but there is a way to make the first form the user sees modal.

Gordon
0
Jeremy_DCommented:
Making it modal isn't likely to happen. A modal form's definition is that the user has to perform some action on it before execution is given back to the calling code. Since your startup form has no calling code, it can't be modal. You can however start with a Sub Main and do a 'frmMain.Show vbModal' from there, but what you are probably looking for is a way to put your main window on top of all other windows. That can be done like this:

'-------------------------------------
Private Declare Function SetWindowPos Lib "user32" _
         (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
          ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

SetWindowPos frmMain.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
'-------------------------------------

Use HWND_NOTOPMOST in stead of HWND_TOPMOST to make it normal again.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GordonpCommented:
Since theres an answer for no  points I'll show you the easy way to do it.

Set Start up to Sub Main

then create sub main as

Sub Main()
    frmMain.Show vbModal
End Sub

Gordon
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

GordonpCommented:
Since theres an answer for no  points I'll show you the easy way to do it.

Set Start up to Sub Main

then create sub main as

Sub Main()
    frmMain.Show vbModal
End Sub

Gordon
0
GordonpCommented:
Oops!
0
Jeremy_DCommented:
Like I said...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.