Solved

Creating a png/bitmap image with collection of icons

Posted on 2016-11-07
4
30 Views
Last Modified: 2016-11-29
Icons
I cannot find any instructions of how to create a single png/bitmap file that would contain a number of images. In our vb app i would load these and use in my menu.

Any help greatly appreciated.

Ed
0
Comment
Question by:sprintdata
  • 3
4 Comments
 
LVL 11

Expert Comment

by:louisfr
ID: 41878521
Which VB are you targeting? All three?
0
 

Author Comment

by:sprintdata
ID: 41878633
Hello Louisfr

I am targeting VB6 currently and moving to .Net next year ;)
0
 
LVL 11

Accepted Solution

by:
louisfr earned 500 total points (awarded by participants)
ID: 41880019
In VB6, you can use a PictureClip control to load one picture and extract parts of it.
You can use the GetMenu, GetSubMenu and SetMenuItemBitmaps functions to add images to the menu.
Here's an example:
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function GetSubMenu Lib "user32" _
    (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, _
    ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long

Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
    Dim hMenu As Long
    Dim hSubMenu As Long
    
    Set PictureClip1.Picture = LoadPicture("d:\temp\bitmap.bmp")
    PictureClip1.Cols = 10
    
    hMenu = GetMenu(hwnd)
    hSubMenu = GetSubMenu(hMenu, 0)
    SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, PictureClip1.GraphicCell(0), 0
    SetMenuItemBitmaps hSubMenu, 1, MF_BYPOSITION, PictureClip1.GraphicCell(1), PictureClip1.GraphicCell(3)
    hSubMenu = GetSubMenu(hMenu, 1)
    SetMenuItemBitmaps hSubMenu, 0, MF_BYPOSITION, PictureClip1.GraphicCell(2), 0
End Sub

Open in new window

0
 
LVL 11

Expert Comment

by:louisfr
ID: 41905442
I think my reply answers the question.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 1 23
Problem to cell option 1 28
No Data for DropDown List 2 26
backup program with robocopy 6 22
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question