Click to See Complete Forum and Search --> : Load a form in Modal mode at Windows Stratup
Coolboylp
September 8th, 2006, 01:36 PM
Hi all,
I have a small program with just one form. I'll be placing this EXE in windows startup folder. What I would like to do is when Windows loads this form, I want to load this program and wait for the user to click ok. Its like how you open a form in showdialog mode but at startup.
Thanks.
sotoasty
September 8th, 2006, 01:51 PM
Maybe add a sub Main to your program and set it as the startup, then in the sub main show the form as dialog? I think that should work.
Coolboylp
September 8th, 2006, 01:57 PM
Thanks for the reply. I do not know how to include the sub main and make it a dialog? Can you help me on that?
zombie_man23
September 8th, 2006, 02:35 PM
Add a module to your project (or modify your current one). You will need to set the subMain module to start first, rather than your form.
Module subMain
Public Sub Main()
Dim fMain As "YOUR FORM NAME GOES HERE" = New Main
fMain.ShowDialog()
End Sub
End Module
DSJ
September 8th, 2006, 02:35 PM
Add a module to your project and put this code in it:
Public Sub Main(Args() as string)
Dim F as new Form1
F.ShowDialog
End
Then in your projects properties, set the startup object to "Sub Main".
Coolboylp
September 9th, 2006, 01:39 AM
Thanks for the feedback. I tried both your options. When I run it from vb the form loads but I'm still able to click on other areas like the windows start button and the my form minimizes. Any ideas?
HanneSThEGreaT
September 9th, 2006, 02:48 AM
The reason for this is that your form is shown modal, for your program and not modal for the system.
I'd set the Form's TopMost Property to true.
In design time you can set the TopMost property to True in the Properties Window.
In code (Run time) you could do this :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TopMost = True
End Sub
But still, You'll still be able to click the Start Button however
I'd advise you to set your Form's FormBorderStyle property to None, casuing the form not to have a titlebar. And setting your form's WindowState property to Maximised.
I do have something similar. I use it to prevent users from continuing without the right user name and password. It blocks the system keys such as Ctrl+Esc, Alt + Tab, and it reads the username from a text file.
Only If the USername and Password corresponds with those in the textfile it allows you to go into Windows.
There's another trick also. When this app is first run, there are no Textboxes or anything - just a black screen. To get the textboxes, you have to press a special key combination (easter egg). Once the secret key combination is pressed, the textboxes and login button are shown.
I use this to prevent people from using my computer.
Do you want it ¿
Do you feel it will help you ¿
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.