Solved

Graphics in popup-menus

Posted on 1997-11-11
5
175 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 100 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

Industry Leaders: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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