Click here to Skip to main content
15,892,674 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionDifferentiate form close event Pin
nishkarsh_k15-May-08 2:59
nishkarsh_k15-May-08 2:59 
AnswerRe: Differentiate form close event Pin
Rupesh Kumar Swami15-May-08 3:16
Rupesh Kumar Swami15-May-08 3:16 
GeneralRe: Differentiate form close event Pin
nishkarsh_k15-May-08 3:23
nishkarsh_k15-May-08 3:23 
AnswerRe: Differentiate form close event Pin
helelark12315-May-08 3:29
helelark12315-May-08 3:29 
GeneralRe: Differentiate form close event Pin
nishkarsh_k15-May-08 3:32
nishkarsh_k15-May-08 3:32 
GeneralRe: Differentiate form close event Pin
mr_lasseter15-May-08 4:05
mr_lasseter15-May-08 4:05 
GeneralRe: Differentiate form close event Pin
nlarson1115-May-08 4:07
nlarson1115-May-08 4:07 
AnswerRe: Differentiate form close event Pin
helelark12315-May-08 4:48
helelark12315-May-08 4:48 
You can also disable the close button of the form:

Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean

Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
Private Const MF_DISABLED = &H2

Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
Dim hMenu As IntPtr
Dim menuItemCount As Integer

hMenu = GetSystemMenu(hwnd, False)
menuItemCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)

Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
Call DrawMenuBar(hwnd)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DisableCloseButton(Handle)
End Sub

Shay Noy

AnswerRe: Differentiate form close event Pin
nishkarsh_k15-May-08 19:05
nishkarsh_k15-May-08 19:05 
QuestionLive Broadcast on web using Windows Media Encoder SDK Pin
xavier198815-May-08 2:29
xavier198815-May-08 2:29 
AnswerRe: Live Broadcast on web using Windows Media Encoder SDK Pin
Thomas Stockwell19-May-08 8:23
professionalThomas Stockwell19-May-08 8:23 
QuestionFlickering Problem in Text Control Pin
Soumya9215-May-08 2:05
Soumya9215-May-08 2:05 
QuestionHow to open an excel file in the Visual Basic 6.0 Form Pin
Member 224184315-May-08 1:02
Member 224184315-May-08 1:02 
AnswerRe: How to open an excel file in the Visual Basic 6.0 Form Pin
helelark12315-May-08 3:30
helelark12315-May-08 3:30 
QuestionInsert Row In Excel File Pin
hitesh sojitra15-May-08 0:36
hitesh sojitra15-May-08 0:36 
AnswerRe: Insert Row In Excel File Pin
parth.p15-May-08 0:59
parth.p15-May-08 0:59 
GeneralRe: Insert Row In Excel File Pin
hitesh sojitra15-May-08 1:29
hitesh sojitra15-May-08 1:29 
GeneralRe: Insert Row In Excel File Pin
hitesh sojitra15-May-08 1:48
hitesh sojitra15-May-08 1:48 
GeneralRe: Insert Row In Excel File Pin
hitesh sojitra15-May-08 1:55
hitesh sojitra15-May-08 1:55 
Questiondata binding update problem Pin
asha_s15-May-08 0:33
asha_s15-May-08 0:33 
AnswerRe: data binding update problem Pin
Mycroft Holmes15-May-08 19:44
professionalMycroft Holmes15-May-08 19:44 
QuestionCatching an exception from a control Pin
Steven J Jowett14-May-08 22:33
Steven J Jowett14-May-08 22:33 
AnswerRe: Catching an exception from a control Pin
Chinners15-May-08 0:55
Chinners15-May-08 0:55 
GeneralRe: Catching an exception from a control Pin
Steven J Jowett15-May-08 1:08
Steven J Jowett15-May-08 1:08 
QuestionCompressing in vb .net 2003 Pin
aphei14-May-08 22:23
aphei14-May-08 22:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.