Solved

Image in Popup menu

Posted on 2002-06-05
7
410 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
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 50 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now