Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on August 31, 2003, 12:13 PM

Title: Cancel Prop in Form_Unload
Post by: CrAz3D on August 31, 2003, 12:13 PM
Dear lord, I double clicked or something, my bad
Title: Re:Cancel Prop in Form_Unload
Post by: Adron on August 31, 2003, 04:03 PM
Would it not be possible for you to instead disable the close button?
Title: Re:Cancel Prop in Form_Unload
Post by: CrAz3D on August 31, 2003, 04:43 PM
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.
Title: Re:Cancel Prop in Form_Unload
Post by: Camel on August 31, 2003, 04:54 PM
You managed to change the subject between postings.
Title: Re:Cancel Prop in Form_Unload
Post by: CrAz3D on August 31, 2003, 05:07 PM
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?
Title: Re:Cancel Prop in Form_Unload
Post by: Adron on August 31, 2003, 05:44 PM
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.
Title: Re:Cancel Prop in Form_Unload
Post by: CrAz3D on August 31, 2003, 07:32 PM
How do I disable the close button?
Title: Re:Cancel Prop in Form_Unload
Post by: Adron on September 01, 2003, 11:01 AM
What need you be able to do with it? For example, setting ControlBox = False removes the close, minimize and maximize functions.
Title: Re:Cancel Prop in Form_Unload
Post by: CrAz3D on September 01, 2003, 01:54 PM
That would work, but I still would like to have minimize & maximize capabilities.
Title: Re:Cancel Prop in Form_Unload
Post by: Adron on September 01, 2003, 02:48 PM
Ah. Hmm, well, apparently you'll then have to remove the close option from the system menu. Which will supposedly disable the X too.
Title: Re:Cancel Prop in Form_Unload
Post by: Adron on September 01, 2003, 02:51 PM
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
Title: Re:Cancel Prop in Form_Unload
Post by: Grok on September 01, 2003, 04:03 PM
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.
Title: Re:Cancel Prop in Form_Unload
Post by: CrAz3D on September 02, 2003, 09:10 PM
Ok, thnx.