473,508 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prevent Alt F4 closing form, but allow OK button to close form.

4 New Member
Hi, Im new to this forum, and new to scripting in general.

Im an ICT Technician for a high school and i am designing a Form in visual basic 2005. The intended purpose of the Form, is to prevent student users logging on to their area, without accepting the Acceptable Use Policy which comes up on screen.

The form, runs maximized, in full screen mode and is constantly in focus, above all other programs. So Basically, until the form is closed, the users PC is unusable.

I have removed the control bar, and right click, so you can only close the form by clicking one of the buttons or by Alt - F4. Task manager is disabled on student accounts, so they cant end the process.

What i am trying to do, is prevent users alt - f4 "ing" the program, but still allow it to close, if you click the accept button.

It has two buttons: "I accept" and "I disagree". the accept button closes the form so the user can use the PC, whereas, the disagree button logs the student off.

What i need, is when you click alt- f4, a message box appears saying you cannot close it. Then all you can do, is accept it or decline it.

although a noob at this, i have managed to do certain things by myself. i can block alt- f4, but it also blocks the ok button.

i can also get a message box 2 appear, but it comes up, no matter how u try to close the form.

If someone can help me with this, i would be extremely greatfull as if i can get it working perfectly, it will be used across the burough.

If someone can give me the precise script commands, ill put a thankyou to them into the program.

As i said, i am a rather big noob at this, as hardware is more my side. so if u could answer me as a noob (but not patronising) it would be appreciated.

thanks in advance

Gregg Cooper CCNA (FreelanceX)
Nov 10 '06 #1
5 10433
freelancex
4 New Member
Hi, if anyone could give me a reply to this asap would be much appreciated!
Dec 5 '06 #2
bplacker
121 New Member
Expand|Select|Wrap|Line Numbers
  1. Private Sub textBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyUp
  2.         If (e.Alt) Then
  3.             If (e.KeyCode = Keys.F4) Then
  4.                 'do something here
  5.             End If
  6.         End If
  7.     End Sub

this is the code to capture the event, what you do from there is up to you

by the way... it doesnt have to be the keyup event of a text box.. thats just what i wrote real fast. It could be the key up event of the whole form.
Dec 5 '06 #3
freelancex
4 New Member
thanks alot for this...

so how do i get it to handle the whole dialog box instead of just a part of the form?

because i cannot put "dialog1.keyup" after "handles".

Like i said, im learning VB .Net, im quite new at it still...

Thanks for helping anyway, much appreciated!
Dec 7 '06 #4
bplacker
121 New Member
Oh, I don't remember seeing that you are doing this from a dialog box. If you want to do this, the only way I can think of is to create a form, and open up the form instead of a dialog box. It is much easier to handle events of a form than a dialog box, at least for as much as I know.
Dec 7 '06 #5
freelancex
4 New Member
Oh, I don't remember seeing that you are doing this from a dialog box. If you want to do this, the only way I can think of is to create a form, and open up the form instead of a dialog box. It is much easier to handle events of a form than a dialog box, at least for as much as I know.
Ahh... OK then. Will do. thanks alot :-)
Dec 8 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2774
by: Peter yeshew | last post by:
Is it possible to forbid closing the form through the File- Close menu ? On my form i have a command button called CmdDeleteInvoice. When this command button is visible ,i want to forbid the user...
1
4401
by: Michel | last post by:
Yes, there is a way of forbidding a form being closed if you create a boolean variable (blnCanClose = False) in the form's Unload event. I didn't read all the responses, but I have just such a form...
22
7526
by: alecjames1 | last post by:
I have a form which the user must complete before closing. I have disabled the window x button and use my own exit button. When selected it checks to see if the user has completed the entries...
3
6427
by: 007 | last post by:
I have a FixedToolWindow form that I create and display when the user presses a button on the toolbar. I want to prevent Alt+F4 on the FixedToolWindow form. How do I accomplish this? I want the...
7
7854
by: Nikki | last post by:
Hi, Can anybody help me, i want to prevent windows to close my winform of ..NET application, when user presses Alt+F4
9
2274
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
2
2418
by: Lauren Wilson | last post by:
Hi folks, I believe I have seen this in this group in the past but my search comes up with nothing so far. I want to prevent our Access application from closing without some kind of...
14
3333
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
7
5208
by: Michiel Rapati-Kekkonen | last post by:
Hi, I would like my record to be saved only when my own close button (with all it's checks) is used. I made the winodws close button disappear, but you still can close using the right mouse...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.