Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Image in Popup menu

Posted on 2002-06-05
7
Medium Priority
?
540 Views
Last Modified: 2010-04-04
is there a way i can place an image (of the size of a menu item) in popup menu?
0
Comment
Question by:sazehra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7058497
do you mean an icon before the menuitem
or for the whole menuitem-line?
0
 
LVL 1

Accepted Solution

by:
alx512 earned 150 total points
ID: 7058499
What version of Delphi do you have?
In Delphi 6 standart VCL components have appropriate properties. ImageList in TPopupMenu and ImageIndex in TMenuItem. If you use the older version of Delphi you must assign a method to OnDrawItem event of TMenuItem.


procedure TMainForm.N22DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
var
  S: String;
  r: TRect;
begin
  CopyRect(r, ARect);
  s := TMenuItem(Sender).Caption;
  with ACanvas do
  begin
    FillRect(r);
    ImageList1.Draw(ACanvas, r.Left + 2, r.Top, 0);
    r.Left := r.Left + 18;
    DrawText(ACanvas.Handle, PChar(S), -1, r, DT_VCENTER or DT_SINGLELINE);
  end;
end;

0
 

Author Comment

by:sazehra
ID: 7058537
i am using Delphi 5 and i want to place a gif/bmp image on the whole menu item line.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:alx512
ID: 7058556
The method above will work fine. Try it.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7059926
you could also check out Jouni Airaksinens bcBarMenus
http://mintus.codefield.com/download/BarMenus/
0
 

Author Comment

by:sazehra
ID: 7064075
the bar menus were nice but the code that did the trick for me was

procedure TForm1.N1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
var
  bmp:TBitMap;
begin
  bmp:= TBitMap.Create;
  bmp.LoadFromFile('c:\temp\bmp.bmp');
  ACanvas.Draw(1,1, bmp);
end;

Thanks alx512 to set me on the right path...
0
 

Author Comment

by:sazehra
ID: 7064079
the bar menus mentioned by Lee were nice but the code that did the trick for me was

procedure TForm1.N1DrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
var
 bmp:TBitMap;
begin
 bmp:= TBitMap.Create;
 bmp.LoadFromFile('c:\temp\bmp.bmp');
 ACanvas.Draw(1,1, bmp);
end;

Thanks alx512 to set me on the right path...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

721 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