Solved

IContextmenu Icon-->

Posted on 2000-03-09
2
783 Views
Last Modified: 2010-04-04
When my app register a menuitem to Explorer-Shell Contextmenu ,
How can I add an Icon to this menuitem ?
------------->
I think that is easy to you ...:-)
0
Comment
Question by:Maria1977
2 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 105 total points
ID: 2600692
hi,
you use setmenuitembitmaps() .for an example open delphi ContMenu example in demos\activeX\shellext folder.
drop a image into the folder (help.bmp).
in delphi add "graphics" to the uses section of contextM.pas and change the TContextMenu.QueryContextMenu function to look like this:

function TContextMenu.QueryContextMenu(Menu: HMENU; indexMenu, idCmdFirst,
          idCmdLast, uFlags: UINT): HResult;
     var
     bmp : tpicture;
          begin
  Result := 0; // or use MakeResult(SEVERITY_SUCCESS, FACILITY_NULL, 0);

  if ((uFlags and $0000000F) = CMF_NORMAL) or
     ((uFlags and CMF_EXPLORE) <> 0) then begin
    // Add one menu item to context menu
    InsertMenu(Menu, indexMenu, MF_STRING or MF_BYPOSITION, idCmdFirst,
      'Compile...');
  bmp:=tpicture.create;
  bmp.LoadFromFile('help.bmp');
  SetMenuItemBitmaps(Menu,indexMenu,MF_BYPOSITION,bmp.Bitmap.handle,bmp.bitmap.handle);
    // Return number of menu items added
    Result := 1; // or use MakeResult(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  end;
end;


now compile build and register and right click a dpr file in explorer and see our icon on the menu :-)

Regards Barry
0
 

Author Comment

by:Maria1977
ID: 2609511
Many Thanks ! :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
Delphi Spellcheck in Webbrowser 1 43
Delphi 2 77
MS Access from Delphi 31 77
"Could not obtain OLE control window handle" under Delphi XE8 8 16
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

680 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