?
Solved

Graphics in popup-menus

Posted on 1997-11-11
5
Medium Priority
?
180 Views
Last Modified: 2010-04-04
I want to be able to make a menu like the Start-menu on
Windows 95 / Win NT (with a vertical bitmap thing).
Is there any component around that does this or if not can
I get a hint about how to do this?
0
Comment
Question by:mortenmo
[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
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1349989
hehehehe 50 points for bitmapped menu items? With 3 screens of code to re-type here? hehehehe
0
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 400 total points
ID: 1349990
ok, I'll bite:

unit radmenuu;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
  Controls, Forms, Dialogs, Menus, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Justification1: TMenuItem;
    Left1: TMenuItem;
    Right1: TMenuItem;
    Center1: TMenuItem;
    Memo1: TMemo;
    Dummy1: TMenuItem;
    N1: TMenuItem;
    N2: TMenuItem;
    Dummy2: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure JustClick(Sender: TObject);
  private
    { Private declarations }
    bmCheck, bmUncheck: TBitmap;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
FUNCTION MakeCheckBmp(C: Char): TBitmap;
VAR
  L : LongInt;
  R : TRect;
BEGIN
  L := GetMenuCheckMarkDimensions;
  Result := TBitmap.Create;
  WITH Result DO
    BEGIN
      Width  := LoWord(L);
      Height := HiWord(L);
      Canvas.FillRect(Rect(0, 0, Width, Height));
      Canvas.Font.Name := 'WingDings';
      Canvas.Font.Size := 10;
      R := Rect(0, 0, Width, Height);
      DrawText(Canvas.Handle, @C, 1, R, DT_CENTER OR DT_VCENTER);
    END;
END;

procedure TForm1.FormCreate(Sender: TObject);
VAR N : Integer;
begin
  bmCheck   := MakeCheckBmp('l'); {try 'n'}
  bmUncheck := MakeCheckBmp('m'); {try 'o'}
  Justification1.Items[2].Checked := True;
  FOR N := 2 TO 4 DO
    SetMenuItemBitmaps(Justification1.Handle, N, MF_BYPOSITION,
      bmUncheck.Handle, bmCheck.Handle);
end;

procedure TForm1.JustClick(Sender: TObject);
VAR N : Integer;
begin
  Memo1.Alignment := TAlignment((Sender AS TMenuItem).Tag);
  {don't set Checked property, else lose bitmaps in 16-bit}
  WITH Justification1 DO
    FOR N := 2 TO 4 DO
      IF Items[N] = Sender THEN
        CheckMenuItem(Handle, N, MF_BYPOSITION OR MF_CHECKED)
      ELSE CheckMenuItem(Handle,N,MF_BYPOSITION OR MF_UNCHECKED);
end;

end.
0
 
LVL 1

Author Comment

by:mortenmo
ID: 1349991
Maybe I didn't get how the menuitems were setup, but it didn't
work exactly as I ment. Why do you start on MenuItem 2? There
must be something I'm missing here. Can you explain how the
menu is build up?

I've increased the points, maybe 50 were a bit low yes I've never
used this before.

0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1349992
The code doesn't really reflect the correct ordering of the menu items. In order (from top to bottom) is
Dummy1
Left
Right
Center
Dummy2

I start on menu item 2 because the first item is a "dummy" menu item with no bitmap. MakeCheckBmp simply creates a bitmap to use with the menu item. Give me your email address and I can zip the entire sample and send it so you can see how it works.

What version of Delphi are you using?
0
 
LVL 1

Author Comment

by:mortenmo
ID: 1349993
I'm using Delphi 3. My address is morten@nvg.ntnu.no ;)
Thanks a lot

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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