Valhalla Legends Forums Archive | Visual Basic Programming | Cancel Prop in Form_Unload

AuthorMessageTime
CrAz3D
Dear lord, I double clicked or something, my bad
August 31, 2003, 5:13 PM
Adron
Would it not be possible for you to instead disable the close button?
August 31, 2003, 9:03 PM
CrAz3D
Dear lord, I double clicked or something, my bad....

I just realized it when I couldn't find Grok's post & then saw that I had another topic under the Gen. Cat.
August 31, 2003, 9:43 PM
Camel
You managed to change the subject between postings.
August 31, 2003, 9:54 PM
CrAz3D
Ok, I understand. Maybe I'm talented like that. :'(
(I am aware I placed a crying smiley)
---Screw the below:
Between this Topic & the other one?......or the first post of this one & the last post I made on this topic?
August 31, 2003, 10:07 PM
Adron
Still, you should be disabling the close button, not blocking a call to an enabled button. If a function isn't available, it should be grayed in the ui.
August 31, 2003, 10:44 PM
CrAz3D
How do I disable the close button?
September 1, 2003, 12:32 AM
Adron
What need you be able to do with it? For example, setting ControlBox = False removes the close, minimize and maximize functions.
September 1, 2003, 4:01 PM
CrAz3D
That would work, but I still would like to have minimize & maximize capabilities.
September 1, 2003, 6:54 PM
Adron
Ah. Hmm, well, apparently you'll then have to remove the close option from the system menu. Which will supposedly disable the X too.
September 1, 2003, 7:48 PM
Adron
From http://www.visualbasicforum.com/t63189.html :

[quote]
If you want some simple code to disable the X close button, simply add these declarations to the form and add the code below to the Form Load event of the form that you want to disable the button on:

Private Const SC_CLOSE As Long = &HF060&
Private Const MF_BYCOMMAND = &H0&
Private Declare Function DeleteMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32.dll" (ByVal hWnd As Long, ByVal bRevert As Long) As Long

Private Sub Form_Load()

DeleteMenu GetSystemMenu(Me.hWnd, False), SC_CLOSE, MF_BYCOMMAND

End Sub
[/quote]
September 1, 2003, 7:51 PM
Grok
What's more fun is to do as Adron said, then add a PictureBox as your own caption bar.

Inside the picturebox you can put your own buttons, any size and shape, to create a cool looking form.

It's an old trick, but appropriate to mention in this conversation.
September 1, 2003, 9:03 PM
CrAz3D
Ok, thnx.
September 3, 2003, 2:10 AM

Search