hello there!! i am creating a vb project, and i want that my mainform could not be minimized by any keyboard events, such that it acts like a desktop.. the program should not allow the user to enter any kind of application even if he/she presses the windows button or any shortcut key for minimizing the form. i will be very grateful for your responses. thanks!!

I think you mean modal. You can set that using the following code:

FormName.Show vbModal

Make absolutely sure that you provide an exit for the user. Otherwise they will hate you and delete the project.

Also you can disable the minimize and maximize buttons from the form designer window and set the window size as maximized. But setting it as modal will not solve your problem. A modal window stops the user from accessing other windows of the SAME application, it has no effect on other applications or windows.

To disable windows key, you will need high level API programming. Also please note this is an extremely dangerous practice and I strongly advice against this. If you really, really, absolutely (etc) need this, consult a good book on API programming.

thanks for the reply.. i am only curious with that function.. i think it is possible cause i saw a program something like that. so no one could enter any kind of application(ms office,calculator, my computer,etc,etc..) except with that program with log-off/shutdown keys.. thanks!!

thanks for the reply, but what i mean is that no one could enter any application outside the program..(e.g ms offcie,my doc.my comp., calulator,etc,etc..)

What you'd need to do is disable the Windows key altogether. This requires a bit of spelunking into Windows' guts with an API call or four. However, help is not far away! CodeGuru.com has an excellent article on "hooking" the keyboard for both VB6 and VB.NET. All you have to do to disable the Windows key is (after trapping it and making sure it really is the Windows key that was pressed) not call the next hook. Be careful to put the old hook back before your program closes, though, so that you don't make the system unusable.

- Sendoshin

This article has been dead for over six months. Start a new discussion instead.