Results 1 to 10 of 10

Thread: Adding to System Menu

  1. #1

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    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:
    1. Option Explicit
    2.  
    3.  
    4. Private Declare Function DrawMenuBar Lib "user32" _
    5. (ByVal hWnd As Long) As Long
    6.  
    7.  
    8. Private Declare Function GetSystemMenu Lib "user32" _
    9. (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    10.  
    11.  
    12. Private Declare Function AppendMenu Lib "user32" Alias _
    13. "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags _
    14. As Long, ByVal wIDNewItem As Long, ByVal lpNewItem _As Any) As Long
    15. Const MF_STRING = &H0&
    16.  
    17.  
    18. Private Sub Form_Load()
    19. Dim SysMenu As Long
    20. SysMenu = GetSystemMenu(Me.hWnd, False)
    21.  
    22.  
    23. If SysMenu Then
    24. AppendMenu SysMenu, MF_STRING, 0, "YourItem"
    25. DrawMenuBar Me.hWnd
    26. End If
    27. End Sub

    Thanks
    -Joey
    <removed by admin>

  2. #2
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    why not just use the menu editor?.........

  3. #3
    He's talking about this menu:

    Attached Images Attached Images  

  4. #4
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    The code you have now only displays the menu. To process events, you will need subclassing.

    There's a better example on PSC.

  5. #5

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Ok I'll go look for it...
    <removed by admin>

  6. #6
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    o ic takes me a while to get questions somtiimes

  7. #7

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    Unhappy

    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
    <removed by admin>

  8. #8
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    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.

  9. #9

    Thread Starter
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    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.
    <removed by admin>

  10. #10
    Megatron
    Guest
    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
  •  



Click Here to Expand Forum to Full Width