home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form MenuBitmaps
- Caption = "Bitmap Menus"
- ClientHeight = 3315
- ClientLeft = 1125
- ClientTop = 1710
- ClientWidth = 5010
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 39.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 4005
- Icon = MENUBMPS.FRX:0000
- Left = 1065
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 3315
- ScaleWidth = 5010
- Top = 1080
- Width = 5130
- Begin PictureBox Picture3
- AutoRedraw = -1 'True
- BackColor = &H00FFFFFF&
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 60
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 585
- Index = 4
- Left = 2100
- ScaleHeight = 555
- ScaleWidth = 2010
- TabIndex = 9
- Top = 2400
- Visible = 0 'False
- Width = 2040
- End
- Begin PictureBox Picture1
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Index = 4
- Left = 0
- Picture = MENUBMPS.FRX:0302
- ScaleHeight = 585
- ScaleWidth = 2040
- TabIndex = 2
- Top = 2400
- Visible = 0 'False
- Width = 2070
- End
- Begin PictureBox Picture3
- AutoRedraw = -1 'True
- BackColor = &H00FFFFFF&
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 50.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 585
- Index = 3
- Left = 2070
- ScaleHeight = 555
- ScaleWidth = 2010
- TabIndex = 4
- Top = 1800
- Visible = 0 'False
- Width = 2040
- End
- Begin PictureBox Picture1
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Index = 3
- Left = 0
- Picture = MENUBMPS.FRX:0DD8
- ScaleHeight = 585
- ScaleWidth = 2040
- TabIndex = 1
- Top = 1800
- Visible = 0 'False
- Width = 2070
- End
- Begin PictureBox Picture2
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 240
- Left = 4440
- Picture = MENUBMPS.FRX:18AE
- ScaleHeight = 14
- ScaleMode = 3 'Pixel
- ScaleWidth = 14
- TabIndex = 3
- Top = 1350
- Visible = 0 'False
- Width = 240
- End
- Begin PictureBox Picture3
- AutoRedraw = -1 'True
- BackColor = &H00FFFFFF&
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 39.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 585
- Index = 2
- Left = 2070
- ScaleHeight = 555
- ScaleWidth = 2010
- TabIndex = 10
- Top = 1200
- Visible = 0 'False
- Width = 2040
- End
- Begin PictureBox Picture1
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Index = 2
- Left = 0
- Picture = MENUBMPS.FRX:1998
- ScaleHeight = 585
- ScaleWidth = 2040
- TabIndex = 5
- Top = 1200
- Visible = 0 'False
- Width = 2070
- End
- Begin PictureBox Picture3
- AutoRedraw = -1 'True
- BackColor = &H00FFFFFF&
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 30
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 585
- Index = 1
- Left = 2070
- ScaleHeight = 555
- ScaleWidth = 2010
- TabIndex = 8
- Top = 600
- Visible = 0 'False
- Width = 2040
- End
- Begin PictureBox Picture1
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Index = 1
- Left = 0
- Picture = MENUBMPS.FRX:246E
- ScaleHeight = 585
- ScaleWidth = 2040
- TabIndex = 6
- Top = 600
- Visible = 0 'False
- Width = 2070
- End
- Begin PictureBox Picture3
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- BackColor = &H00FFFFFF&
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "Times New Roman"
- FontSize = 20.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 795
- Index = 0
- Left = 2070
- Picture = MENUBMPS.FRX:2F44
- ScaleHeight = 765
- ScaleWidth = 3375
- TabIndex = 7
- Top = 0
- Visible = 0 'False
- Width = 3405
- End
- Begin PictureBox Picture1
- AutoSize = -1 'True
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "System"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 615
- Index = 0
- Left = 0
- Picture = MENUBMPS.FRX:46DA
- ScaleHeight = 585
- ScaleWidth = 2040
- TabIndex = 0
- Top = 0
- Visible = 0 'False
- Width = 2070
- End
- Begin Menu Bitmaps
- Caption = "&Static"
- Begin Menu SubMenu
- Caption = "Static Bitmap 0"
- Checked = -1 'True
- Index = 0
- End
- Begin Menu SubMenu
- Caption = "Static Bitmap 1"
- Index = 1
- End
- Begin Menu SubMenu
- Caption = "Static Bitmap 2"
- Index = 2
- End
- Begin Menu SubMenu
- Caption = "Static Bitmap 3"
- Index = 3
- End
- Begin Menu SubMenu
- Caption = "Static Bitmap 4"
- Index = 4
- End
- End
- Begin Menu DynamicBitmaps
- Caption = "&Dynamic"
- Begin Menu MSubMenu
- Caption = "Dynamic Bitmap 0"
- Index = 0
- End
- Begin Menu MSubMenu
- Caption = "Dynamic Bitmap 1"
- Index = 1
- End
- Begin Menu MSubMenu
- Caption = "Dynamic Bitmap 2"
- Checked = -1 'True
- Index = 2
- End
- Begin Menu MSubMenu
- Caption = "Dynamic Bitmap 3"
- Index = 3
- End
- Begin Menu MSubMenu
- Caption = "Dynamic Bitmap 4"
- Index = 4
- End
- End
- Begin Menu CreateDynamic
- Caption = "&Create Dynamic Bitmaps!"
- End
- DefInt A-Z
- 'Window API Function Declarations
- Declare Function GetMenu% Lib "user" (ByVal hwnd%)
- Declare Function GetSubMenu% Lib "user" (ByVal hMenu%, ByVal nPos%)
- Declare Function GetMenuItemID% Lib "user" (ByVal hMenu%, ByVal nPos%)
- Declare Function ModifyMenu% Lib "user" (ByVal hMenu%, ByVal nPosition%, ByVal wFlags%, ByVal wIDNewItem%, ByVal lpNewItem&)
- Declare Function SetMenuItemBitmaps% Lib "user" (ByVal hMenu%, ByVal nPosition%, ByVal wFlags%, ByVal hBitmapUnchecked%, ByVal hBitmapChecked%)
- Declare Function TrackPopupMenu Lib "user" (ByVal hMenu, ByVal r1, ByVal X, ByVal Y, ByVal r2, ByVal hwnd, ByVal r3&)
- Declare Function GetSystemMenu Lib "user" (ByVal hwnd%, ByVal revert%) As Integer
- Const MF_BITMAP = &H4
- Const CLR_MENUBAR = &H80000004
- Const TRUE = -1, FALSE = 0
- Dim TextItems$(4), LastSelection%, CurrentText%, hMenu%
- Sub Create_Dynamic_Menu_Bitmaps ()
- For I% = 0 To 4
- '* Set the width and height of the Picture controls
- '* based on their corresponding Menu items caption,
- '* and the Picture controls Font and FontSize.
- '* DoEvents() is neccessary to make new dimension
- '* values to take affect prior to exiting this Sub.
- picture3(I%).Width = picture3(I%).TextWidth(MSubMenu(I%).Caption)
- picture3(I%).Height = picture3(I%).TextHeight(MSubMenu(I%).Caption)
- X% = DoEvents()
- '* Set Backcolor of Picture control to that of the
- '* current system Menu Bar color, so Dynamic bitmaps
- '* will appear as normal menu items when menu bar
- '* color is changed via the control panel
- picture3(I%).BackColor = CLR_MENUBAR
- '* Print Text onto Picture control. This text will
- '* become the bitmap.
- picture3(I%).Print MSubMenu(I%).Caption
- Next I%
- '* Obtain handle Second submenu
- hSubMenu% = GetSubMenu(hMenu%, 1)
- '* - Set picture controls backgroup picture (Bitmap) to its Image.
- '* Can't use the Image bitmap directly for some reason.
- '* - Get ID of sub menu
- '* - Replace menu text with bitmap from corresponding picture control
- '* - Replace bitmap for menu check mark with custom check mark bitmap
- For I% = 0 To 4
- picture3(I%).Picture = picture3(I%).Image
- menuId% = GetMenuItemID(hSubMenu%, I%)
- X% = ModifyMenu(hMenu%, menuId%, MF_BITMAP, menuId%, CLng(picture3(I%).Picture))
- X% = SetMenuItemBitmaps(hMenu%, menuId%, 0, 0, CLng(picture2.Picture))
- Next I%
- End Sub
- Sub CreateDynamic_Click ()
- CreateDynamic.enabled = False
- Create_Dynamic_Menu_Bitmaps
- End Sub
- Sub Form_Load ()
- '* Obtain handle to the Forms top level menu
- hMenu% = GetMenu(hwnd)
- Static_Bitmaps_To_Menus
- '* Initial String with text displayed when menus are selected.
- '* (Just so something happens when a menu is selected.)
- TextItems$(0) = "Writing Tools"
- TextItems$(1) = "Fonts"
- TextItems$(2) = "Books/Notes"
- TextItems$(3) = "Printers"
- TextItems$(4) = "Computers"
- '* Set "Dynamic" menus submenus initial Menu text values
- '* to Fontname + Fontsize of each menu item
- For I% = 0 To 4
- MSubMenu(I%).Caption = picture3(I%).FontName + Str$(picture3(I%).FontSize) + " Pnt"
- Next I%
- End Sub
- Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
- ScaleMode = 3
- InPixels = ScaleWidth
- ScaleMode = 1
- IX = (X + Left) \ (ScaleWidth \ InPixels)
- IY = (Y + (Top + (Height - ScaleHeight - (Width - ScaleWidth)))) \ (ScaleWidth \ InPixels)
- R = TrackPopupMenu(GetSubMenu(hMenu%, Button - 1), 0, IX, IY, 0, hwnd, 0)
- End Sub
- Sub Form_Paint ()
- Cls
- Print TextItems$(CurrentText%)
- End Sub
- Sub MSubMenu_Click (Index As Integer)
- Static LastSelection%
- '* Reset forms FontSize to selected fontsize
- '* and redisplay current text
- FontSize = picture3(Index).FontSize
- Form_Paint
- '* Uncheck last selected item and check selected item
- MSubMenu(LastSelection%).Checked = False
- MSubMenu(Index).Checked = True
- LastSelection% = Index
- End Sub
- Sub Static_Bitmaps_To_Menus ()
- '* Obtain handle to first submenu
- hSubMenu% = GetSubMenu(hMenu%, 0)
- '* - Get ID of each sub menu
- '* - Replace menu text with bitmap from corresponding picture control
- '* - Replace bitmap for menu check mark with custom check mark bitmap
- For I% = 0 To 4
- menuId% = GetMenuItemID(hSubMenu%, I%)
- X% = ModifyMenu(hMenu%, menuId%, MF_BITMAP, menuId%, CLng(picture1(I%).Picture))
- X% = SetMenuItemBitmaps(hMenu%, menuId%, 0, 0, CLng(picture2.Picture))
- Next I%
- SubMenu(1).enabled = 0
- hMenu% = GetSystemMenu(hwnd, 0)
- menuId% = &HF120
- X% = ModifyMenu(hMenu%, menuId%, MF_BITMAP, menuId%, CLng(picture3(0).Picture))
- End Sub
- Sub SubMenu_Click (Index As Integer)
- Static LastSelection%
- '* Set text to that of selected menu item and
- '* display the new text
- CurrentText% = Index
- Form_Paint
- '* Uncheck last selected item and check seledted item
- SubMenu(LastSelection%).Checked = False 'Check selected menu
- SubMenu(Index).Checked = True 'UnCheck last selected menu
- LastSelection% = Index 'Save current selection
- End Sub
-