Board index » delphi » Weird TMainmenu problem...

Weird TMainmenu problem...

I've dropped a TMainMenu object on a modal dialog, added a couple of menu
items w/supporting code, and then compiled and run the app.  Using the
de{*word*81}, I can see that the "test" code I put in to enable and disable the
menu items works, but the menu itself is **NEVER** visible in the dialog,
nor do the "Hot Keys" for the menu items fire when I key them.  What am I
doing wrong?

Thanks in advance for your help...

- Allen

Here's the form type definition:

type
  TPrintVerificationForm = class(TForm)
    HxPrintButton: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    TempPrintButton: TButton;
    Label1: TLabel;
    InfoLabel: TLabel;
    HxPrinterID: TLabel;
    TempPrinterID: TLabel;
    MainMenu1: TMainMenu;
    SelectPrinter1: TMenuItem;
    HistoryPrinter1: TMenuItem;
    TempPrinter1: TMenuItem;
    procedure HxPrintButtonClick(Sender: TObject);
    procedure TempPrintButtonClick(Sender: TObject);
    procedure CancelBtnClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure HistoryPrinter1Click(Sender: TObject);
    procedure TempPrinter1Click(Sender: TObject);
  private
    { Private declarations }
  public
    FromPrintVerifyForm : Boolean; file://Added for Temp/Hx Printing - ASG
08/06/99
    { Public declarations }
  end;

Here's the dfm file:

object PrintVerificationForm: TPrintVerificationForm
  Left = 880
  Top = 359
  BorderIcons = []
  BorderStyle = bsDialog
  Caption = 'Print Verification'
  ClientHeight = 218
  ClientWidth = 313
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu1
  Position = poScreenCenter
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Bevel1: TBevel
    Left = 8
    Top = 8
    Width = 297
    Height = 137
    Shape = bsFrame
  end
  object Label1: TLabel
    Left = 24
    Top = 112
    Width = 159
    Height = 20
    Caption = 'Choose a Print Option:'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object InfoLabel: TLabel
    Left = 24
    Top = 24
    Width = 273
    Height = 81
    AutoSize = False
    Color = 12632240
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentColor = False
    ParentFont = False
  end
  object HxPrinterID: TLabel
    Left = 24
    Top = 152
    Width = 73
    Height = 25
    Alignment = taCenter
    AutoSize = False
    Caption = 'HistoryPrinterID'
    Color = 12632240
    ParentColor = False
  end
  object TempPrinterID: TLabel
    Left = 120
    Top = 152
    Width = 73
    Height = 25
    Alignment = taCenter
    AutoSize = False
    Caption = 'TempPrinterID'
    Color = 12632240
    ParentColor = False
  end
  object HxPrintButton: TButton
    Left = 23
    Top = 180
    Width = 75
    Height = 25
    Caption = 'Print History'
    Default = True
    ModalResult = 1
    TabOrder = 0
    OnClick = HxPrintButtonClick
  end
  object CancelBtn: TButton
    Left = 215
    Top = 180
    Width = 75
    Height = 25
    Cancel = True
    Caption = 'Cancel'
    ModalResult = 2
    TabOrder = 2
  end
  object TempPrintButton: TButton
    Left = 119
    Top = 180
    Width = 75
    Height = 25
    Caption = 'Print Temp'
    Default = True
    ModalResult = 1
    TabOrder = 1
    OnClick = TempPrintButtonClick
  end
  object MainMenu1: TMainMenu
    Left = 240
    Top = 152
    object SelectPrinter1: TMenuItem
      Caption = 'Select &Printer'
      object HistoryPrinter1: TMenuItem
        Caption = '&History Printer...'
        ShortCut = 16456
        OnClick = HistoryPrinter1Click
      end
      object TempPrinter1: TMenuItem
        Caption = '&Temp Printer...'
        ShortCut = 16468
        OnClick = TempPrinter1Click
      end
    end
  end
end

... and the "FormShow" procedure:

procedure TPrintVerificationForm.FormShow(Sender: TObject);
begin
     HistoryPrinter1.Enabled := Prefs.AllowHxPrinting;
     TempPrinter1.Enabled := Prefs.AllowTmpPrinting;
     if Prefs.AllowHxPrinting then
     begin
       HxPrinterID.Caption := Prefs.PrinterID;
       HxPrintButton.Enabled := True;
     end
     else
     begin
       HxPrinterID.Caption := '';
       HxPrintButton.Enabled := False;
     end;
     if Prefs.AllowTmpPrinting then
     begin
       TempPrinterID.Caption := Prefs.TempPrinterID;
       TempPrintButton.Enabled := True;
     end
     else
     begin
       TempPrinterID.Caption := '';
       TempPrintButton.Enabled := False;
     end;
end;

 

Re:Weird TMainmenu problem...


On Tue, 24 Aug 1999 10:05:08 -0400, "Allen VM"

Quote
<vandermeulen.al...@mayo.edu> wrote:
>I've dropped a TMainMenu object on a modal dialog, added a couple of menu
>items w/supporting code, and then compiled and run the app.  Using the
>de{*word*81}, I can see that the "test" code I put in to enable and disable the
>menu items works, but the menu itself is **NEVER** visible in the dialog,
>nor do the "Hot Keys" for the menu items fire when I key them.  What am I
>doing wrong?

...

Quote
>Here's the dfm file:

>object PrintVerificationForm: TPrintVerificationForm
>  Left = 880
>  Top = 359
>  BorderIcons = []
>  BorderStyle = bsDialog

Dialog can't have menu. Change borderstyle to bsSingle - so the user
can't alert windows size but you have menu.

HTH
ain

Re:Weird TMainmenu problem...


Thanks.  Do I feel stupid? (Loud chorus: "YES!")

- Allen

Quote
Ain Valtin <a...@taavi.ee> wrote in message

news:37c2b929.15260138@forums.inprise.com...
Quote
> On Tue, 24 Aug 1999 10:05:08 -0400, "Allen VM"
> <vandermeulen.al...@mayo.edu> wrote:

> >I've dropped a TMainMenu object on a modal dialog, added a couple of menu
> >items w/supporting code, and then compiled and run the app.  Using the
> >de{*word*81}, I can see that the "test" code I put in to enable and disable
the
> >menu items works, but the menu itself is **NEVER** visible in the dialog,
> >nor do the "Hot Keys" for the menu items fire when I key them.  What am I
> >doing wrong?

> ...

> >Here's the dfm file:

> >object PrintVerificationForm: TPrintVerificationForm
> >  Left = 880
> >  Top = 359
> >  BorderIcons = []
> >  BorderStyle = bsDialog

> Dialog can't have menu. Change borderstyle to bsSingle - so the user
> can't alert windows size but you have menu.

> HTH
> ain

Other Threads