Solved

Creating a png/bitmap image with collection of icons

Posted on 2016-11-07
4
20 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now