how to remove Close button on the form

chinrose

Member
Joined
Jul 13, 2011
Messages
15
Location
Philippines
Programming Experience
Beginner
hi guys, just want to know a better way to remove the close "x" button of the form, or atleast every time i close it end up openning again.
 
to others that still dont know ..

to remove min/max/close
***** at the properties of the form set controlbox = false
***** but this dont dissable the Alt + F4 fuction
***** to disable the Alt + F4

in your form1_closing
e.cancel = true
this will cancel the close function even the Alt + F4
 
Thank you for sharing the information.

Note that it is still possible to close such a program, using Taskmanager or the command line Taskkill /im programname.exe /f command.
 
Thank you for sharing the information.

Note that it is still possible to close such a program, using Taskmanager or the command line Taskkill /im programname.exe /f command.


hm........... i never think of that way, but you are rigth, seem i still need to find way to do this. can you help me with this problem
 
I don't think it is possible to make something that cannot be killed or prevented from running. Windows ensures it is possible to stop everything except a few core Windows programs, since anything could be malware or could cause a conflict.
If it is absolutely vital that this program remain online, I'd take a look at some of the tricks Security software uses to keep running.
Antivirus programs for example run primarily as a service and with elevated privileges, so they are very hard to take down.
For most uses though, just ensuring that your program doesn't get casually closed should be sufficient.
 
a more sophisticated way of doing that is


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub


This makes your form immovable and you might have to program yourself to make it move again

Use this :

'Declare the variables
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer


Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
drag = True 'Sets the variable drag to true.
mousex = Windows.Forms.Cursor.Position.X - Me.Left 'Sets variable mousex
mousey = Windows.Forms.Cursor.Position.Y - Me.Top 'Sets variable mousey
End Sub


Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
'If drag is set to true then move the form accordingly.
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub


Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
drag = False 'Sets drag to false, so the form does not move according to the code in MouseMove
End Sub


To make form invisible from

taskbar -> me.showintaskbar = false
taskmanager -> you'll have to program a rootkit a more advance programming methodology search it on google
 
Back
Top