Recent

Author Topic: Message dialog button position  (Read 2802 times)

Racing Dog

  • Newbie
  • Posts: 5
Message dialog button position
« on: April 15, 2023, 10:21:53 pm »
It seems that on WinCe message dialog buttons are in the normal position at the bottom of the dialog. So when I used Basic4PPC to ceate dialogs that was where they appeared (apart from just OK which appeared at the right end of the Title bar).

But now I am using the latest stable versions of Lazarus and the arm-wince for Windows 32 bit, the dialog buttons appear above the text for OK, or the side for multiple buttons. Can I prevent this somehow?

d2010

  • Full Member
  • ***
  • Posts: 235
Re: Message dialog button position
« Reply #1 on: September 06, 2025, 10:56:15 pm »
You can reconstruct entire Dialog-Box.
Code: Pascal  [Select][+][-]
  1. function GetAveCharSize2(Canvas: TCanvas): TPoint;
  2. var
  3.   I: Integer;
  4.   Buffer: array[0..51] of Char;
  5. begin
  6.   for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
  7.   for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
  8.   GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
  9.   Result.X := Result.X div 52;
  10. end;
  11.  
  12. Function dfn_dcl_button2(const titlu_cutie,
  13.                       APrompt:string;
  14.             mesajul_buton_yes:string;
  15.                     yeslatime:integer;{0.default/else.ok}
  16.              mesajul_buton_no:string;
  17.                      nolatime:integer;{0.default/else.ok}
  18.             latimea_ferestrei:integer;
  19.           inaltimea_ferestrei:integer
  20. ): Char;
  21. var
  22.   msj_prompt:string;
  23.   de_sus_in_jos:integer;
  24.   pozitia_butoanelor    :integer;
  25.   s3m:string;
  26.   leny,lenn:integer;
  27.   latime_buton,ucsxdir,ucsydir:integer;
  28.  
  29.  
  30.  
  31.   Form: TForm;
  32.   Prompt:array[1..15] of TLabel;
  33.   DialogUnits: TPoint;
  34.   ButtonTop, ButtonWidth, ButtonHeight: Integer;
  35.  
  36.    Function creaza_okaiulul:integer;
  37.    begin
  38.       with TButton.Create(Form) do
  39.       begin
  40.         Parent := Form;
  41.         Caption :=mesajul_buton_yes;
  42.         ModalResult := mrOk;
  43.         Default := True;
  44.         SetBounds(MulDiv(pozitia_butoanelor, DialogUnits.X, 4),
  45.                   ButtonTop,
  46.                   yeslatime,
  47.                   ButtonHeight);
  48.         result:=ButtonTop+ButtonHeight div 2;
  49.         pozitia_butoanelor:=pozitia_butoanelor+10+yeslatime;
  50.       end;
  51.     end;
  52.  
  53.  
  54.    procedure creaza_cancelurul;
  55.    begin
  56.       with TButton.Create(Form) do
  57.       begin
  58.         Parent := Form;
  59.         Caption := mesajul_buton_no;
  60.         ModalResult := mrCancel;
  61.         Cancel := True;
  62.         SetBounds(MulDiv(pozitia_butoanelor, DialogUnits.X, 4),
  63.                                                      ButtonTop,
  64.                                                       nolatime,
  65.                                                  ButtonHeight);
  66.         pozitia_butoanelor:=pozitia_butoanelor+10+nolatime;
  67.         ucsxdir:=Left;
  68.         ucsydir:=Top;
  69.       end;
  70.     end;
  71.  
  72.  
  73.  
  74.   procedure creaza_promptolira;
  75.    var i,j:integer;q:pchar;
  76.    begin
  77.      s3m:=msj_prompt;
  78.      j:=15;
  79.      i:=01;
  80.      while (i>0) do
  81.       begin
  82.          q:=pchar(msj_prompt);
  83.          i:=pos(#10,msj_prompt);
  84.          if (i>0)
  85.            then begin s3m:=copy(msj_prompt,1,i-1);
  86.                       inc(q,i);
  87.                       msj_prompt:=strpas(q);
  88.                       i:=2;
  89.                  end
  90.            else s3m:=msj_prompt;
  91.            Prompt[j] := TLabel.Create(Form);
  92.             with Prompt[j] do
  93.                 begin
  94.                       Parent := Form;
  95.                       AutoSize := True;
  96.                       Left := MulDiv(8, DialogUnits.X, 4);
  97.                       Top := MulDiv(de_sus_in_jos, DialogUnits.Y, 8);
  98.                       Caption := s3m;
  99.                  end;
  100.             dec(j);
  101.           if (j<2) then j:=1;
  102.           inc(de_sus_in_jos,12);
  103.           dec(i);
  104.           if (j<1) then i:=0;
  105.       end;{while}
  106.    end;
  107.  
  108.  
  109.   procedure pozitoneaza_butonasele;
  110.   begin
  111.          ButtonTop := MulDiv(de_sus_in_jos, DialogUnits.Y, 8);
  112.       ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
  113.       inc(de_sus_in_jos,21);
  114.   end;
  115.  
  116. begin
  117.  
  118.   if  (length(mesajul_buton_yes)<2) then mesajul_buton_yes:='Yes';
  119.   if  (length(mesajul_buton_no)<2) then mesajul_buton_no:='No';
  120.   leny:=length(mesajul_buton_yes);
  121.   lenn:=length(mesajul_buton_no);
  122.  
  123.   case inaltimea_ferestrei of
  124.    0..1: inaltimea_ferestrei:=200;
  125.    else
  126.   end; {case}
  127.  
  128.  
  129.   case latimea_ferestrei of
  130.    0..1: latimea_ferestrei:=164;
  131.    else
  132.   end; {case}
  133.  
  134.   de_sus_in_jos     :=11;
  135.   msj_prompt        :=APrompt;
  136.   pozitia_butoanelor:=38;
  137.  
  138.   if (length(msj_prompt)<2) then msj_prompt:='Prompt';
  139.   pozitia_butoanelor:= 38;
  140.   if (msj_prompt[1]='#') and ((msj_prompt[5] in ['1'..'F']))
  141.          then pozitia_butoanelor:=ord(msj_prompt[5]) - ord('0')*10;
  142.   result := 'e';
  143.   Form := TForm.Create(Application);
  144.   with Form do
  145.     try
  146.       Canvas.Font  := Font;
  147.       DialogUnits  := GetAveCharSize2(Canvas);
  148.       BorderStyle  := bsDialog;
  149.       Caption      := titlu_cutie;
  150.       ClientWidth  := MulDiv(latimea_ferestrei  , DialogUnits.X, 4);
  151.       ClientHeight := MulDiv(inaltimea_ferestrei,  DialogUnits.Y, 8);
  152.       Position     := poScreenCenter;
  153.  
  154.       if (msj_prompt<>'none') then
  155.            creaza_promptolira;
  156.  
  157.       pozitoneaza_butonasele;
  158.       if (yeslatime<1) then yeslatime:=60+leny;
  159.       yeslatime:=MulDiv(yeslatime, DialogUnits.X, 4);
  160.       if (nolatime<1) then nolatime:=60+lenn;
  161.       nolatime :=MulDiv(nolatime, DialogUnits.X, 4);
  162.       creaza_okaiulul;
  163.         SetCursorPos(Screen.width div 2,Screen.height div 2);
  164. //      SetCursorPos(100,300);
  165.       creaza_cancelurul;
  166.       result:='n';
  167.       if (ShowModal = mrOk) then result:='y';
  168.     finally
  169.       Form.Free;
  170.     end;
  171. end;
  172.  

Demonstration-of -Call
Code: [Select]
            if (dfn_dcl_button2('Select precompilation type',simx
                                ,'da-&yes-ci ==covlxtxt',100,
                                 'no-&nu-net ==topovlexc',0,400,110)='y')
                       then maxibufe:=strcat(maxibufe,'#pragma hdrstop ("covlxtxt.pCh")'#13#10#13#10'')
               else Begin kCLEANScreenState:='F';               
                          maxibufe:=strcat(maxibufe,'#pragma hdrstop ("topovlex.pcH")'#13#10#13#10'');
                     End;

Code: Python  [Select][+][-]
  1.  
  2. { Lnk= c:\vlaxcompil\SRCC2LSP\Delphi.3\Z-INCS\I2\dfn_dcl_button2.i2
  3.   ;Nam:w.msgbox_yesno2.i2
  4.  Aprompt:str=comenzi(1st char = '#'
  5. 2.                   2th char = ordinea 1.prompt,edit,ok,cancel
  6.                                 ordinea 2.edit,prompt,ok,cancel
  7. 'o0.row_column)
  8.  
  9.  
  10.                order:int(0.row_column)
  11.                         (1.column_row)
  12.                         (2.boxed_row boxed_column)
  13.                         (3.boxed_column boxed_row)
  14.                         (4.boxed_row column)
  15.                         (5.row boxed_column)
  16.                         (6.boxed_column row)
  17.                         (7.column boxed_row)
  18.            order_question:int 2.upper ..6
  19.                  question:str(1.str si alignment for text)
  20.                is_default:int(0.no)(1.yes)
  21.                   yes_str:str(""."Yes")First char is alignment
  22.                yes_height:int(0.no)
  23.                 yes_width:int(0.no)
  24.                    no_str:str(""."No")First char is alignment
  25.                 no_height:int(0.no)
  26. }
  27.  

//            if (dfn_dcl_button2('Select type of sort',simx
//                                ,'da-&yes-ci ==topoLogical-sort',100,
//                                 'no-&nu-net ==ascending-ascii',0,400,110)='y')

« Last Edit: September 06, 2025, 11:00:16 pm by d2010 »

 

TinyPortal © 2005-2018