|
-
Sep 23rd, 2001, 02:34 PM
#1
Thread Starter
PowerPoster
Adding to System Menu
I am using this code from PSC to add an item to the systemmenu on my app, but when I click it, nothing happens. How can I make it do my code. And while I'm posting, how can I add a seperator bar to the menu? I tried just using this code and putting a "-" but that didn't work.
The code I am using:
VB Code:
Option Explicit
Private Declare Function DrawMenuBar 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 AppendMenu Lib "user32" Alias _
"AppendMenuA" (ByVal hMenu As Long, ByVal wFlags _
As Long, ByVal wIDNewItem As Long, ByVal lpNewItem _As Any) As Long
Const MF_STRING = &H0&
Private Sub Form_Load()
Dim SysMenu As Long
SysMenu = GetSystemMenu(Me.hWnd, False)
If SysMenu Then
AppendMenu SysMenu, MF_STRING, 0, "YourItem"
DrawMenuBar Me.hWnd
End If
End Sub
Thanks
-Joey
-
Sep 23rd, 2001, 02:40 PM
#2
Frenzied Member
why not just use the menu editor?.........
-
Sep 23rd, 2001, 02:41 PM
#3
Member
-
Sep 23rd, 2001, 02:43 PM
#4
PowerPoster
The code you have now only displays the menu. To process events, you will need subclassing.
There's a better example on PSC.
-
Sep 23rd, 2001, 02:44 PM
#5
Thread Starter
PowerPoster
Ok I'll go look for it...
-
Sep 23rd, 2001, 02:47 PM
#6
Frenzied Member
o ic takes me a while to get questions somtiimes
-
Sep 23rd, 2001, 03:02 PM
#7
Thread Starter
PowerPoster
Damn... I can't find any code that works on that site! I found some that kinda works, but when I close the form after testing it, it closes VB too, so I have to copy and paste the code all over again. Does anyone have this code that they can just post, I don't feel like searching through PSC anymore... it's too unorganized!
Thanks
-Joey
-
Sep 23rd, 2001, 03:02 PM
#8
PowerPoster
Originally posted by MidgetsBro
Damn... I can't find any code that works on that site! I found some that kinda works, but when I close the form after testing it, it closes VB too, so I have to copy and paste the code all over again. Does anyone have this code that they can just post, I don't feel like searching through PSC anymore... it's too unorganized!
Thanks
-Joey
...That's what happens when you use subclassing.
-
Sep 23rd, 2001, 03:05 PM
#9
Thread Starter
PowerPoster
I know that's what happens if u use subclassing and you don't close the form by the X... but I did close it with the X and it still did it. arg! Maybe I don't need this in my program if it's going to be this hard to do.
-
Sep 24th, 2001, 02:52 PM
#10
If you subclass your window, and catch the WM_COMMAND message, the LOWORD of wParam is the menu ID that was clicked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|