PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Menu Item Bitmap

 
 
Max
Guest
Posts: n/a
 
      9th Dec 2003
I did not find such thing in .NET, while there was one in Win32 API.
(See MENUITEMINFO, SetMenuItemBitmaps, etc,... help topics in Platform SDK
documentation)

Am I missing something?


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      9th Dec 2003
* "Max" <(E-Mail Removed)> scripsit:
> I did not find such thing in .NET, while there was one in Win32 API.
> (See MENUITEMINFO, SetMenuItemBitmaps, etc,... help topics in Platform SDK
> documentation)


You can use an ownerdrawn menu (or wirk with p/invoke on the functions
mentioned above):

<http://www.codeproject.com/vb/net/#Menus>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      10th Dec 2003
No comments, just a link.
http://longhorn.msdn.microsoft.com/l.../hbmpitem.aspx

"Max" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I did not find such thing in .NET, while there was one in Win32 API.
> (See MENUITEMINFO, SetMenuItemBitmaps, etc,... help topics in Platform SDK
> documentation)
>
> Am I missing something?
>
>



 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      11th Dec 2003
Here is the implementation of Menu Item Bitmap using SetMenuItemInfo API
function.
I have MyNamespace.MenuItem class derived from Windows.Forms.MenuItem.

It implements two additional properties. The public Bitmap protperty is to
set and retrieve MenuItem's bitmap (get not tested).

The code is unsafe.

Menu containing the menu item should be created BEFORE adding the bitmap.

I had a problem displaying transparent images. The transparent pixels are
show as something blue.

Identifiers starting with WinUser WinGDI and WinBase refer api stuff mapped
from the Platform SDK *.h files with same names. I will post the mappings if
anybody will be interested.


public class MenuItem : System.Windows.Forms.MenuItem
{
/// <summary>
/// Default constructor.
/// Initializes menu item instance.
/// Calls base default constructor.
/// </summary>
public MenuItem()
:base()
{
//
// TODO: Add constructor logic here
//
}

unsafe IntPtr HBitmap
{
get
{
WinUser.tagMENUITEMINFO mii;
mii.cbSize = (uint)sizeof(WinUser.tagMENUITEMINFO);
mii.fMask = WinUser.MIIM.BITMAP;
mii.wID = (uint)this.MenuID;
mii.hbmpItem = (IntPtr)null;
int iResult =
WinUser.GetMenuItemInfoW(this.Parent.Handle,(uint)this.Index,1,(IntPtr)(&mii
..cbSize));
return mii.hbmpItem;
}
set
{
WinUser.tagMENUITEMINFO mii;
mii.cbSize = (uint)sizeof(WinUser.tagMENUITEMINFO);
mii.hbmpItem = (IntPtr)(null);
mii.fMask = WinUser.MIIM.BITMAP;
int iResult =
WinUser.GetMenuItemInfoW(this.Parent.Handle,(uint)this.Index,1,(IntPtr)(&mii
..cbSize));
if (((IntPtr)null)!=mii.hbmpItem)
{//Delete Old Bitmap, if any
WinGDI.DeleteObject(mii.hbmpItem);
}
mii.hbmpItem = value;
iResult =
WinUser.SetMenuItemInfoW(this.Parent.Handle,(uint)this.Index,1,(IntPtr)(&mii
..cbSize));
uint uiLastError = WinBase.GetLastError();
}
}
}
"Max" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I did not find such thing in .NET, while there was one in Win32 API.
> (See MENUITEMINFO, SetMenuItemBitmaps, etc,... help topics in Platform SDK
> documentation)
>
> Am I missing something?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image (bitmap) into menu R.A.F. Microsoft C# .NET 0 24th Nov 2007 08:10 PM
Context menu bitmap =?Utf-8?B?SGVhZE9mZmljZQ==?= Microsoft C# .NET 1 18th Jun 2006 04:25 AM
how do i add an bitmap object into a task item's body? news.inode.at Microsoft Outlook 0 20th Dec 2005 05:08 PM
Not able to call a function from custom menu item that is added in word menu(File) jayrm100@yahoo.com Microsoft Word Document Management 0 9th Nov 2005 06:36 AM
I create a menu item using VB, within a custom contacts form. I do not want the item to be visible in other forms or views. How do I do this?? Tore Microsoft Outlook Form Programming 0 10th Mar 2004 02:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.