VB icon

Add new item in System Menu

Email
Submitted on: 1/2/2015 1:19:00 AM
By: Nicholas Afxentiou (from psc cd)  
Level: Intermediate
User Rating: By 12 Users
Compatibility: VB.NET
Views: 2445
 
     A simple way to add new items in your application's system menu or delete current items,see screenshot to understand or right click on your application's button in taskbar. Please Vote...Thanx :)

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Add new item in System Menu
// Description:A simple way to add new items in your application's system menu or delete current items,see screenshot to understand or right click on your application's button in taskbar. Please Vote...Thanx :)
// By: Nicholas Afxentiou (from psc cd)
//**************************************

'declarations
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal bRevert As Boolean) As Integer
 Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Integer, ByVal wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As String) As Integer
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Const MF_BYPOSITION = &H400&
Const MF_REMOVE = &H1000&
 Const WM_SYSCOMMAND As Integer = &H112
'-----------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Dim hSysMenu As Integer
 hSysMenu = GetSystemMenu(Me.Handle.ToInt32, False)
'deletes the close menu item which is in place 6
RemoveMenu(hSysMenu, 6, MF_REMOVE)
'appends new menu items
 AppendMenu(hSysMenu, 0, 1000, "New Item1")
 AppendMenu(hSysMenu, 0, 1001, "New Item2")
 End Sub
'--------------------------------
Protected Overrides Sub WndProc(ByRef m As Message)
 MyBase.WndProc(m)
 If m.Msg = WM_SYSCOMMAND Then
 Select Case m.WParam.ToInt32
 Case 1000
MsgBox("Hello1")
 Case 1001
MsgBox("Hello2")
 End Select
 End If
 End Sub


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.