Page 1 of 1

BitMaps And Check Marks in Menu's

Posted: Tue Jan 01, 2002 6:50 am
by BackupUser
Code updated For 5.20+

Restored from previous forum. Originally posted by wayne1.

Code: Select all

 


If OpenWindow(0, 100, 150, 195, 260, "BitMaps and Check Marks in Menu", #PB_Window_SystemMenu)
  ;BitMaps And Check Marks in Menu's
  If CreateMenu(0,WindowID(0))
    MenuTitle("Test Menu")
    MenuItem( 1, "Check Marked Item")
    MenuItem( 2, "")
    MenuItem( 3, "Text with BitMap")
    
    
  EndIf
  
  hMnu=GetMenu_(WindowID(0));get menu handle
  hBmp=LoadImage(1, "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\Assorted\mail.bmp")
  s=ModifyMenu_(hMnu,1,#MF_CHECKED, 1,"Check Marked Item");
  ModifyMenu_(hMnu,2,#MF_BITMAP,2,hBmp);load bitmap in menu
  ;x=GetSystemMetrics_(#SM_CXMENUCHECK);check size for bmp
  ;y=GetSystemMetrics_(#SM_CYMENUCHECK)
  ;add bitmap to text on item 3, use proper size bmp
  SetMenuItemBitmaps_(hMnu,3, #MF_BYCOMMAND,hBmp,hBmp);
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Menu
        Select EventMenu()
          Case 1
            
            hMnu=GetMenu_(WindowID(0))
            State=GetMenuState_(hMnu,1,#MF_BYCOMMAND)
            
            If(State=#MF_UNCHECKED);
              ModifyMenu_(hMnu,1,#MF_BYCOMMAND|#MF_CHECKED, 1,"Check Marked Item");
            Else
              ModifyMenu_(hMnu,1,#MF_BYCOMMAND|#MF_UNCHECKED, 1,"Check Marked Item");
            EndIf
            
          Case 2
            
            MessageRequester("","You clicked the bitmap menu",0)
        EndSelect
      Case #WM_CLOSE
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf
End







Edited by - wayne1 on 01 January 2002 08:26:05

Posted: Tue Jan 01, 2002 4:07 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Nice tips ! Thanks.

Fred - AlphaSND

Posted: Tue Jan 01, 2002 4:59 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Hey Fred !!

I wanted to add this (Bitmap in menus) to 1 of my
next libraries, but now you can do it. :wink:

Look at the following functions:
- SetMenuItemBitmaps (to set the bitmap)
- AppendMenuA (to append a menu entry)
- GetSystemMenu

So you can add new entries to
the SystemMenu and add a bitmap
to this MenuItems.
(The SystemMenu is the Menu
that pops up if you right click
in the taskbar)

Thanks,
...Danilo

(registered PureBasic user)

Posted: Tue Jan 01, 2002 5:41 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
Look at the following functions:
- SetMenuItemBitmaps (to set the bitmap)
- AppendMenuA (to append a menu entry)
- GetSystemMenu
I wrote the original Menu library. Thanks anyway for the tip..

Fred - AlphaSND