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!!

Dani AI

Generated

This question is essentially a kiosk requirement: an app that prevents switching away from it and stops common system shortcuts. Simple UI tweaks or showing a form modal only affect the application process and will not stop the user from launching other programs or invoking OS-level sequences. As suggested, modal windows keep focus inside the same application, and correctly warned that they do not block other applications or the shell.

For a robust, supported solution the right approach is to use OS-level kiosk tooling or policy/configuration: run the program as a dedicated kiosk user, enable Assigned Access / kiosk mode (or a shell replacement) or apply Group Policy restrictions so Explorer and Task Manager are not available. These are administrative changes and require careful testing and an admin recovery path; they are the recommended route for production kiosks because they do not rely on fragile hooks.

For in-process prevention of minimizing, useful measures are to remove the minimize control, make the window borderless/topmost and explicitly ignore the system minimize command. Blocking system-wide shortcuts (Windows key, Alt+Tab) requires global hooks or a kernel filter driver and is potentially dangerous; Ctrl+Alt+Del (the secure attention sequence) cannot be intercepted by a normal application. is right that keyboard hooks are the usual approach, but hooks need admin rights, must be restored on exit, and can leave a machine unusable if handled incorrectly.

Example (VB.NET) to ignore the minimize system command inside the form:

Protected Overrides Sub WndProc(ByRef m As Message)
    Const WM_SYSCOMMAND As Integer = &H112
    Const SC_MINIMIZE As Integer = &HF020

    If m.Msg = WM_SYSCOMMAND AndAlso (m.WParam.ToInt32() And &HFFF0) = SC_MINIMIZE Then
        Return
    End If

    MyBase.WndProc(m)
End Sub

Test in a VM, use a separate kiosk account, provide an out-of-band admin recovery method, and prefer OS-supported kiosk features for stability and security.

Recommended Answers

All 5 Replies

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 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 and . 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

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.