Search the Community
Showing results for tags 'menu'.
Found 2 results
-
Hi, I have isolated another odd behaviour, and I am just dumping it here, to get it off my mind, and for your entertainment, of course. FMX only. Windows only. Edge case. Reproducible. With TMainMenu that wraps! (There are painting problems when ClientHeight is around Screen.WorkingAreaHeight and the number of menu rows changes because of changed ClientWidth.) unit FrmMain; interface (* The goal: - Maximize ClientHeight, but keep in control of aspect ratio of ClientArea. - Height should be Screen.WorkAreaHeight. - Width should be either Portrait (smaller, 800) or Landscape (larger, 1000). - Need to set Width/Height or ClientWidth/ClientHeight in code. - Prefer to set ClientWidth/ClientHeight over Width/Height. The plot thickens: - Have big TMainMenu component. - In Portrait MainMenu will wrap into two lines! - In Landscape MainMenu will fit on one line! The Problem: - ClientArea painting problem when MainMenu wraps/unwraps, when you toggle between Landscape and Portrait: Odd: - MainMenu.Height is not a property. - Changing MainMenu-Height seems to be part of the problem. - Missing space to grow the window is another part of the problem? Usage: Press buttons in order given below... Problem cases: a) Reset, Portrait, Landscape: - Black (unpainted) area at the bottom edge. b) Reset, Button2, Button1: - Black unpainted area at bottom edge of ClientArea in Window. - Button1 and Button2 not painted correctly, around bottom edge. c) Reset, Lanscape, Button1, Landscape: - Window too big, bottom edge behind task bar. These cases work as expected: d) Reset, Portrait e) Reset, Landscape f) Reset, Button 1 (like Portrait but via using Height property) g) Reset, Button 2 (like Lanscape but via using Height property) Steps: - In new, empty FMX project - rename Form to FormMain - paste test code - connect FormCreate, FormDestroy, FormKeyUp - run - hit keys instead of clicking buttons. *) uses System.SysUtils, System.Types, System.UITypes, System.UIConsts, System.Classes, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Menus, FMX.Layouts, FMX.Objects; type TFormMain = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure LandscapeBtnClick(Sender: TObject); procedure PortraitBtnClick(Sender: TObject); procedure ResetBtnClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private ML: TStringList; fa: Integer; MaxClientHeight: Integer; MaxClientHeight1: Integer; MaxClientHeight2: Integer; MenuHeight1: Integer; MenuHeight2: Integer; procedure InitMemoText; procedure InitMenu; procedure UpdateReport; function AddMenu(M: TMainMenu; Caption: string): TMenuItem; procedure InitItem(I: TMenuItem; fa: Integer); public MainMenu: TMainMenu; MemoText: TText; // ResetBtn: TButton; // PortraitBtn: TButton; // LandscapeBtn: TButton; // Button1: TButton; // Button2: TButton; end; var FormMain: TFormMain; implementation {$R *.fmx} procedure TFormMain.FormCreate(Sender: TObject); begin ML := TStringList.Create; { record this while there is no MainMenu } MaxClientHeight := Screen.WorkAreaHeight - (Height - ClientHeight); InitMemoText; InitMenu; { by now we 'know' the height of the main-menu-lines } MaxClientHeight1 := MaxClientHeight - MenuHeight1; MaxClientHeight2 := MaxClientHeight - MenuHeight2; UpdateReport; end; procedure TFormMain.FormDestroy(Sender: TObject); begin ML.Free; end; procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if KeyChar = 'a' then begin ResetBtnClick(nil); PortraitBtnClick(nil); LandscapeBtnClick(nil); end else if KeyChar = 'b' then begin ResetBtnClick(nil); Button2Click(nil); Button1Click(nil); end else if KeyChar = 'c' then begin ResetBtnClick(nil); LandscapeBtnClick(nil); Button1Click(nil); LandscapeBtnClick(nil); end else if KeyChar = 'd' then begin ResetBtnClick(nil); PortraitBtnClick(nil); end else if KeyChar = 'e' then begin ResetBtnClick(nil); LandscapeBtnClick(nil); end else if KeyChar = 'f' then begin ResetBtnClick(nil); Button1Click(nil); end else if KeyChar = 'g' then begin ResetBtnClick(nil); Button2Click(nil); end else if KeyChar = 'l' then begin LandscapeBtnClick(nil); end else if KeyChar = 'p' then begin PortraitBtnClick(nil); end else if KeyChar = 'r' then begin ResetBtnClick(nil); end else if KeyChar = '1' then begin Button1Click(nil); end else if KeyChar = '2' then begin Button2Click(nil); end end; procedure TFormMain.ResetBtnClick(Sender: TObject); begin ClientWidth := 800; ClientHeight := 600; Top := 100; UpdateReport; end; procedure TFormMain.LandscapeBtnClick(Sender: TObject); begin ClientWidth := 1000; ClientHeight := MaxClientHeight1; Top := 0; UpdateReport; end; procedure TFormMain.PortraitBtnClick(Sender: TObject); begin ClientWidth := 800; ClientHeight := MaxClientHeight2; Top := 0; UpdateReport; end; procedure TFormMain.Button1Click(Sender: TObject); begin ClientWidth := 800; Height := Screen.WorkAreaHeight; Top := 0; UpdateReport; end; procedure TFormMain.Button2Click(Sender: TObject); begin ClientWidth := 1000; Height := Screen.WorkAreaHeight; Top := 0; UpdateReport; end; procedure TFormMain.UpdateReport; begin ML.Clear; ML.Add('Button KeyChars:'); ML.Add(' r = Reset'); ML.Add(' p = Portrait'); ML.Add(' l = Landscape'); ML.Add(' 1 = Button 1'); ML.Add(' 2 = Button 2'); ML.Add(''); ML.Add('KeyChars for Test Cases:'); ML.Add(' a, b, c = Bad'); ML.Add(' d, e, f, g = Good'); ML.Add(''); ML.Add('Info:'); ML.Add(Format(' Screen.Height = %d', [Screen.Height])); ML.Add(Format(' WorkAreaHeight = %d', [Screen.WorkAreaHeight])); ML.Add(Format(' MenuHeight1 = %d', [MenuHeight1])); ML.Add(Format(' MenuHeight2 = %d', [MenuHeight2])); ML.Add(Format(' W-H = (%d, %d)', [Width, Height])); ML.Add(Format(' Client-W-H = (%d, %d)', [ClientWidth, ClientHeight])); MemoText.Text := ML.Text; end; procedure TFormMain.InitMemoText; begin MemoText := TText.Create(self); MemoText.Parent := self; MemoText.Position.X := 10.0; MemoText.Position.Y := 20.0; MemoText.TextSettings.WordWrap := False; MemoText.AutoSize := True; MemoText.Font.Family := 'Consolas'; MemoText.Font.Size := 14; MemoText.TextSettings.FontColor := claBlue; MemoText.TextSettings.HorzAlign := TTextAlign.Leading; MemoText.TextSettings.VertAlign := TTextAlign.Leading; end; procedure TFormMain.InitMenu; var i: Integer; ch1, ch2: Integer; begin MainMenu := TMainMenu.Create(self); MainMenu.Parent := self; ch1 := ClientHeight; for i in [1..8] do AddMenu(MainMenu,'Menu' + IntToStr(i)); ch2 := ClientHeight; MenuHeight1 := ch1 - ch2; for i in [9..16] do AddMenu(MainMenu,'Menu' + IntToStr(i)); ch2 := ClientHeight; MenuHeight2 := ch1 - ch2; end; function TFormMain.AddMenu(M: TMainMenu; Caption: string): TMenuItem; var j: Integer; begin result := TMenuItem.Create(M); result.Text := Caption; M.AddObject(result); for j in [1..2] do begin Inc(fa); InitItem(result, fa); end; end; procedure TFormMain.InitItem(I: TMenuItem; fa: Integer); var t: TMenuItem; begin t := TMenuItem.Create(I); t.Width := 50; t.Height := 50; t.Opacity := 1.0; t.Font.Size := 24; t.Text := 'Item' + IntToStr(fa); t.Enabled := True; t.Visible := True; t.Tag := Ord(fa); I.AddObject(t); end; end.
-
Hi, I have my main monitor set to 200% (resolution of 3840 * 2160) . My additionnal monitor is set to 100% (1920 * 1080). Windows 10. The Delphi IDE runs on the second monitor (font 100%). If all the parts of the IDE remain on this same monitor then all is correct. But as soon as I put one or more IDE panels (Structure or Project panes for ex.) on the primary monitor, appart on the panes on the primary monitor, no menu pops up (neither main menu or 'real' popups). (Do they show elsewhere ?) If I do it in the other way (Delphi on the main monitor, 200%) and panes on the additional monitor, then the menu content shows but completely shifted to the left and with a 100% font instead of 200%. This is probably related to HiRes stuffs which the IDE does not correctly support. But perhaps worth mentionning. For me it sounds more like a bug, not taking the current monitor settings, but the last one used !! Perhaps does someone have a magic solution ??? Already a QC entry ? Thanks ! Frédéric