You know how if you open up options in many applications you are no longer able to click to the side of the program until you have either hit ok or cancel. I was wondering if this is possible to do with a program in visual basic, and if it is possible how exactly to make it happen.

Recommended Answers

All 6 Replies

You use the ShowDialog method of the form. This displays the form as Modal, meaning that the calling form can not be accessed until the dialog is closed.

I am not only talking about forms. I mean the entire screen behind the form.

It is common for applications to prevent the user from interacting with other parts of the application, as Reverend Jim describes; however, I haven't really seen any applications that do this, aside from system processes.

There are quite a few things that can get in the way of this, besides mouse clicks:

  • Changing windows with keyboard shortcuts (Alt+Tab, WinKey+Tab)
  • Task Manager (Ctrl+Alt+Del, Crtl+Shift+Esc)
  • Start Menu (WinKey, Ctrl+Esc)
  • etc.

You may be able to capture and handle all of the mouse clicks on-screen without too much difficulty, but without preventing the keyboard shortcuts (which I don't think would be doable without getting down to driver-level software) I couldn't see much point in it.

Do you have a reason for wanting to do this? Most users like to be able to switch between applications, and is a key purpose for many modern Operating Systems.

Same problem here, I want to disable the entire screen except for my form. Something like showdialog but more complicated. Ideas?

To nmaillet. I have made a game in Visual Basic. I want to remove the ability to click off the form, because my highscore saving system is initialized in the start button and the overall highscore of the game is saved when the user clicks on the exit button. If the user closes the form outside of the exit button the highscore system will be off and the only way to fix it is to delete the file and manually put the highscore back into the new text file.

Have you tried handling the close event of the form? That should fire no matter how the form is closed except for anything that ends the process arbitrarily, like End Process in task manager.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.