Hey, I'm making a type of 'prank' program to use on some unlucky sap in school. I have everything going good so far and one of the pieces of coding is:
Private Sub Form_Click()
Unload Me
Form1.Show vbModal
End Sub
So that way if they try clicking on the form, it will only close and bring itself back up again. (I set the cursor icon to nothing to there's no mouse pointer either :P)
But what is a way that I could have the same kind of reaction by say pressing any key on the keyboard?
Private Sub Form_KeyPress(KeyAscii as Integer)
If KeyAscii <> 0 Then
Unload Me
Form1.Show vbmodal
End If
End Sub
Quote from: Dyndrilliac on November 16, 2004, 10:55 PM
Private Sub Form_KeyPress(KeyAscii as Integer)
If KeyAscii <> 0 Then
Unload Me
Form1.Show vbmodal
End If
End Sub
Didn't do anything. :-\
Why would you want to hide the window then show it again?
Quote from: drivehappy on November 17, 2004, 12:24 AM
Why would you want to hide the window then show it again?
Basically just to screw with the person, isn't it annoying when you close something out and it pops right back up? Esp. when music starts playing everytime the window pops up...
Quote from: Reaper~ on November 17, 2004, 12:53 AM
Quote from: drivehappy on November 17, 2004, 12:24 AM
Why would you want to hide the window then show it again?
Basically just to screw with the person, isn't it annoying when you close something out and it pops right back up? Esp. when music starts playing everytime the window pops up...
So basically..... You're a sociopath?
Sociopath? Nah. Come on MyndFyre, where's your sense of humor! Obviously this is a very funny prank that will get even the teachers laughing, hahaha. Good joke man, keep it up!
Ctrl+Alt+Delete= end of prank.
Quote from: The-FooL on November 17, 2004, 04:30 PM
Ctrl+Alt+Delete= end of prank.
Wouldn't disabling any keypress stop that?
No, and for my answer Form1 the form needs to be in focus.
Quote from: Reaper~ on November 17, 2004, 04:41 PM
Quote from: The-FooL on November 17, 2004, 04:30 PM
Ctrl+Alt+Delete= end of prank.
Wouldn't disabling any keypress stop that?
See SystemParametersInfo (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp) and SPI_SETSCREENSAVERRUNNING
If the application only incoporates a Form, wouldn't the closing of the Form end the application?
Quote from: UserLoser on November 17, 2004, 06:29 PM
Quote from: Reaper~ on November 17, 2004, 04:41 PM
Quote from: The-FooL on November 17, 2004, 04:30 PM
Ctrl+Alt+Delete= end of prank.
Wouldn't disabling any keypress stop that?
See SystemParametersInfo (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp) and SPI_SETSCREENSAVERRUNNING
All it says is that it is used internally for Win95/98.
Quote from: MyndFyre on November 18, 2004, 08:01 AM
Quote from: UserLoser on November 17, 2004, 06:29 PM
Quote from: Reaper~ on November 17, 2004, 04:41 PM
Quote from: The-FooL on November 17, 2004, 04:30 PM
Ctrl+Alt+Delete= end of prank.
Wouldn't disabling any keypress stop that?
See SystemParametersInfo (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp) and SPI_SETSCREENSAVERRUNNING
All it says is that it is used internally for Win95/98.
Right, but correct me if I'm wrong: when a screensaver is running, Windows key, Alt+Tab, Ctrl+Alt+Del, [possibly more] ..., combinations are disabled (I wrote a similiar application at school last year, except it had no control bar at the top of the window, was unmoveable, and was always on top, I challenged the whole class to try and close it; and if someone did I'd pay them a dollar). Btw, on Form_Unload, just do:
Cancel = 1 'Won't close when 'X' button is pressed
Note: This was on Windows 98 at school. MSDN does not say if it'll work on any systems newer than 98, though
UserLoser, this is probably a lot like yours. No controlbar, won't move, etc.. that's all I'm trying to do is make it uncloseable unless computer is shut off or something. Also,
Quote
Cancel = 1 'Won't close when 'X' button is pressed
Doesn't work..
"Compile Error:
Procedure declaration does not match description of event or procedure having the same name"
Quote from: Reaper~ on November 18, 2004, 05:47 PM
UserLoser, this is probably a lot like yours. No controlbar, won't move, etc.. that's all I'm trying to do is make it uncloseable unless computer is shut off or something. Also,
Quote
Cancel = 1 'Won't close when 'X' button is pressed
Doesn't work..
"Compile Error:
Procedure declaration does not match description of event or procedure having the same name"
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
Works for me, also under QueryUnload it works, too
Works now, just didn't see you put (Cancel As Integer) before :-\
Back to the keypress though, still need a solution for that