473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,396 developers and data experts.

Adding Bitmap to Menu.

debasisdas
8,127 Expert 4TB
Add a menu item and a sub-menu to the main menu to the form.
Add a picture box to the form and set its visible property to False.

Add the following code to a general module (.BAS).(API Functions)
=================================================
Expand|Select|Wrap|Line Numbers
  1. Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  2. Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  3. Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  4. Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  5. Public Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
  6. Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
  7. Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
  8.  
Add this code to the form load event.
==============================
Expand|Select|Wrap|Line Numbers
  1. Picture1.Picture = LoadPicture(app.path & "\" & "CUT.BMP")
  2. Dim D As Long, DU as Long
  3. Dim H As Long
  4. D = CreateCompatibleDC(Picture1.hdc)
  5. H = CreateCompatibleBitmap(Picture1.hdc, 16, 16)
  6.  
  7. Dim P As Long
  8. P = SelectObject(D, H)
  9. DU = BitBlt(D, 0, 0, 16, 16, Picture1.hdc, 0, 0, &HCC0020)
  10. DU = SelectObject(D, P)
  11. D = ModifyMenu(GetSubMenu(GetMenu(Me.hwnd), 0), 0, &H404, 0, H)
  12.  
Oct 17 '07 #1
0 5633

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Picho | last post by:
Hi all, Is there any .NET way (I am not rulling out API usage) to add button(s) to a form's title bar? I found some non-.NET solutions that did actually work in VB6 but not in the ..NET...
5
by: Monty R. Caywood | last post by:
Is there a way to add a specific bitmap on a button?
8
by: Dave Quigley | last post by:
Hello everyone.... Im currently starting my targa support project again for ..NET and I am wondering if there are any particular interfaces or classes that Im supposed to extend in order to do this...
1
by: jay | last post by:
I have a bitmap and a graphicspath object. I draw pixels on m_Bitmap and I'm drawing text using m_Graphics GraphicsPath object. However, saving my work with m_Bitmap.Save doesn't save...
6
by: Maheshkumar.R | last post by:
How i can store images in array @ runtime..? What are the possbile ways.. Thankz.. - Mähésh Kumär. R
6
by: Richard | last post by:
On my webpage I am making I want that if users view any image in my gallery a small logo/tekst will appear in the image. I know it's possible but I haven't got a clue how to get a logo or tekst on...
2
by: Carl Gilbert | last post by:
Hi I have to following code which sets up a new bitmap. 'set up a transparent 16x16 bitmap Dim bm As New Bitmap(16, 16) Dim g As Graphics = Graphics.FromImage(bm)...
3
by: John Dann | last post by:
I've never had much cause to read up in detail on GDI+ but there's a small piece of a project where I need to add some annotation (let's say just some small filled rectangles as markers) to a...
1
by: HeadOffice | last post by:
Hi, I'd like to have a context menu attached to my NotifyTrayIcon. Easy enough - but I'd like to have one of those menus with a bitmap that runs down the entire length of the menu (company name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.