PDA

Click to See Complete Forum and Search --> : Append a Form's System Menu


omarswan
May 27th, 2000, 03:36 PM
Hi,
How can I append a Form's System Menu and And also detect when it has been clicked?

May 29th, 2000, 05:14 AM
What do you man by append to the form's system menu? You mean like add menu to the Restore, Maximize, Minimize, Close etc.?

omarswan
May 29th, 2000, 10:18 AM
Yes Megatron,
That is exactly what I'm talking about. The menu that appears when you click onthe top left hand corner of a form.

May 30th, 2000, 07:45 AM
Hmmm, I think that's a default set by Windows, but there might be a way around it. I'll try testing some things out and get back to you in a couple of days.

omarswan
May 30th, 2000, 03:47 PM
I think it has something to do with the AppendMenu API

omarswan
May 30th, 2000, 08:31 PM
Hi everyone,
I found a perfect example. :) :) :) :)

May 31st, 2000, 02:16 AM
Yes, that does look like the solution. I think you can also add to normal menus using that API.

Jun 3rd, 2000, 08:28 AM
Wait a sec. The InsertMenuItem API adds a menu item to a menu that already exsists. This is probably what you're looking for.

Netfox
Jun 4th, 2000, 12:55 PM
Hi,where's the sample?Can you let me have a look?

omarswan
Jun 4th, 2000, 06:20 PM
I don't know your email address Netfox

Jun 5th, 2000, 02:34 AM
Go to this link.

http://www.vbapi.com/ref/i/insertmenuitem.html

Jun 7th, 2000, 02:56 AM
Try this. Make a Form with a CommandButton and put this code in the Declarations section of the Form.


Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenu Lib "user32" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
Const MF_STRING = &H0&


Private Sub Command1_Click()

Dim mnuMenu As Long, mnuMenuI As Long

mnuMenu = GetSystemMenu(Me.hwnd, 0)
mnuMenuI = GetMenuItemID(mnuMenu, 0)
ModifyMenu mnuMenu, mnuMenuI, MF_STRING, mnuMenuI, "Restore my Bollocks"
mnuMenuI = GetMenuItemID(mnuMenu, 1)
ModifyMenu mnuMenu, mnuMenuI, MF_STRING, mnuMenuI, "Move u'r fat arse!"
mnuMenuI = GetMenuItemID(mnuMenu, 6)
ModifyMenu mnuMenu, mnuMenuI, MF_STRING, mnuMenuI, "Bugger off!"

End Sub

Jun 8th, 2000, 06:44 AM
Just placing this at thre top incase you missed it.