Valhalla Legends Forums Archive | Visual Basic Programming | Quick Question

AuthorMessageTime
Reaper
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:
[code]
Private Sub Form_Click()
Unload Me
Form1.Show vbModal
End Sub
[/code]
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?
November 17, 2004, 4:08 AM
Dyndrilliac
[code]Private Sub Form_KeyPress(KeyAscii as Integer)
If KeyAscii <> 0 Then
Unload Me
Form1.Show vbmodal
End If
End Sub[/code]
November 17, 2004, 4:55 AM
Reaper
[quote author=Dyndrilliac link=topic=9583.msg89080#msg89080 date=1100667315]
[code]Private Sub Form_KeyPress(KeyAscii as Integer)
If KeyAscii <> 0 Then
Unload Me
Form1.Show vbmodal
End If
End Sub[/code]
[/quote]

Didn't do anything.  :-\
November 17, 2004, 5:05 AM
drivehappy
Why would you want to hide the window then show it again?
November 17, 2004, 6:24 AM
Reaper
[quote author=drivehappy link=topic=9583.msg89084#msg89084 date=1100672650]
Why would you want to hide the window then show it again?
[/quote]
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...
November 17, 2004, 6:53 AM
Myndfyr
[quote author=Reaper~ link=topic=9583.msg89086#msg89086 date=1100674400]
[quote author=drivehappy link=topic=9583.msg89084#msg89084 date=1100672650]
Why would you want to hide the window then show it again?
[/quote]
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]

So basically.....  You're a sociopath?
November 17, 2004, 9:06 AM
LivedKrad
Sociopath? Nah. Come on MyndFyre, where's your sense of humor! Obviously this is a [u]very[/u] funny prank that will get even the teachers laughing, hahaha. Good joke man, keep it up!
November 17, 2004, 5:02 PM
The-FooL
Ctrl+Alt+Delete= end of prank.
November 17, 2004, 10:30 PM
Reaper
[quote author=The-FooL link=topic=9583.msg89160#msg89160 date=1100730621]
Ctrl+Alt+Delete= end of prank.
[/quote]

Wouldn't disabling any keypress stop that?
November 17, 2004, 10:41 PM
Dyndrilliac
No, and for my answer Form1 the form needs to be in focus.
November 18, 2004, 12:14 AM
UserLoser.
[quote author=Reaper~ link=topic=9583.msg89162#msg89162 date=1100731270]
[quote author=The-FooL link=topic=9583.msg89160#msg89160 date=1100730621]
Ctrl+Alt+Delete= end of prank.
[/quote]

Wouldn't disabling any keypress stop that?
[/quote]

See SystemParametersInfo and SPI_SETSCREENSAVERRUNNING
November 18, 2004, 12:29 AM
LivedKrad
If the application only incoporates a Form, wouldn't the closing of the Form end the application?
November 18, 2004, 1:07 PM
Myndfyr
[quote author=UserLoser link=topic=9583.msg89186#msg89186 date=1100737790]
[quote author=Reaper~ link=topic=9583.msg89162#msg89162 date=1100731270]
[quote author=The-FooL link=topic=9583.msg89160#msg89160 date=1100730621]
Ctrl+Alt+Delete= end of prank.
[/quote]

Wouldn't disabling any keypress stop that?
[/quote]

See SystemParametersInfo and SPI_SETSCREENSAVERRUNNING
[/quote]

All it says is that it is used internally for Win95/98.
November 18, 2004, 2:01 PM
UserLoser.
[quote author=MyndFyre link=topic=9583.msg89245#msg89245 date=1100786482]
[quote author=UserLoser link=topic=9583.msg89186#msg89186 date=1100737790]
[quote author=Reaper~ link=topic=9583.msg89162#msg89162 date=1100731270]
[quote author=The-FooL link=topic=9583.msg89160#msg89160 date=1100730621]
Ctrl+Alt+Delete= end of prank.
[/quote]

Wouldn't disabling any keypress stop that?
[/quote]

See SystemParametersInfo and SPI_SETSCREENSAVERRUNNING
[/quote]

All it says is that it is used internally for Win95/98.
[/quote]

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:

[code]
Cancel = 1 'Won't close when 'X' button is pressed
[/code]

Note: This was on Windows 98 at school.  MSDN does not say if it'll work on any systems newer than 98, though
November 18, 2004, 7:40 PM
Reaper
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]
[code]
Cancel = 1 'Won't close when 'X' button is pressed
[/code]
[/quote]

Doesn't work..
"Compile Error:
Procedure declaration does not match description of event or procedure having the same name"
November 18, 2004, 11:47 PM
UserLoser.
[quote author=Reaper~ link=topic=9583.msg89301#msg89301 date=1100821652]
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]
[code]
Cancel = 1 'Won't close when 'X' button is pressed
[/code]
[/quote]

Doesn't work..
"Compile Error:
Procedure declaration does not match description of event or procedure having the same name"
[/quote]

[code]
Private Sub Form_Unload(Cancel As Integer)
    Cancel = 1
End Sub
[/code]

Works for me, also under QueryUnload it works, too
November 19, 2004, 12:34 AM
Reaper
Works now, just didn't see you put (Cancel As Integer) before  :-\
Back to the keypress though, still need a solution for that
November 19, 2004, 12:39 AM

Search