Solved

Creating a png/bitmap image with collection of icons

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pop out of webbrowser1 control vba6 5 24
Help with consolidating excel files using VB.net 2 29
Logon script fails 23 45
How to duplicate form in Visual Studio 2015 2 55
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

792 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