Aumentar tamanho da fonte
16/12/2005
0
MessageDlg(´Numero de Pedido Não Cadastrado - Favor Verificar !!´, mtWarning,[mbOK],0);
Alguem tem alguma sugestão ???
Rogerio Amorim
Rogerio_amorim
Posts
16/12/2005
Adriano Santos
[b:f2de84a633]Rogerio[/b:f2de84a633] um [url=http://forum.clubedelphi.net/viewtopic.php?t=71435&highlight=]tópico [/url]semelhante foi aberto estes dias o qual participei passando minha própria MessageDlg. Nele foi demostrado como mudar o botão [b:f2de84a633]default[/b:f2de84a633] da MessageDlg. Podemos seguir a mesma linha, mas o problema é o tamanho da caixa de mensagem. É fácil aumentar a fonte e a caixa também, o problema é posicionar o(s) botão(ôes) no centro da MessageDlg personalizada. Dá uma olhada:
function Dc_MessageDlgFont(Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; IndiceHelp: LongInt; AFontSize: Integer; DefButton: TMOdalResult = mrNone; Portugues: Boolean = True): Word; var I: Integer; Mensagem: TForm; begin Mensagem := CreateMessageDialog(Msg, AType, Abuttons); Mensagem.Width := 300; Mensagem.HelpContext := IndiceHelp; with Mensagem do begin for i := 0 to ComponentCount - 1 do begin if (Components[i] is TButton) then if (TButton(Components[i]).ModalResult = DefButton) then ActiveControl := TWincontrol(Components[i]); {Procura o label e altera o tamanho} if ((Components[i] is TLabel)) and (AFontSize > 0 ) then TLabel(Components[i]).Font.Size := AFontSize; end; if Portugues then begin if Atype = mtConfirmation then Caption := ´Confirmação´ else if AType = mtWarning then Caption := ´Aviso´ else if AType = mtError then Caption := ´Erro´ else if AType = mtInformation then Caption := ´Informação´; end; end; if Portugues then begin TButton(Mensagem.FindComponent(´YES´)).Caption := ´&Sim´; TButton(Mensagem.FindComponent(´NO´)).Caption := ´&Não´; TButton(Mensagem.FindComponent(´CANCEL´)).Caption := ´&Cancelar´; TButton(Mensagem.FindComponent(´ABORT´)).Caption := ´&Abortar´; TButton(Mensagem.FindComponent(´RETRY´)).Caption := ´&Repetir´; TButton(Mensagem.FindComponent(´IGNORE´)).Caption := ´&Ignorar´; TButton(Mensagem.FindComponent(´ALL´)).Caption := ´&Todos´; TButton(Mensagem.FindComponent(´HELP´)).Caption := ´A&juda´; end; Result := Mensagem.ShowModal; Mensagem.Free; end;
Repare que eu procuro o label dentro da mensagem e altero sua fonte se o parâmetro for maior que 0 (0 coloquei como se fosse o tam. default).
{Procura o label e altera o tamanho} if ((Components[i] is TLabel)) and (AFontSize > 0 ) then TLabel(Components[i]).Font.Size := AFontSize;
Podemos aumentar o tamanho da tela:
Mensagem.Width := 300;
Mas faça o teste e vai notar que fica ´feio´.
Use assim a função:
procedure TForm1.Button2Click(Sender: TObject); begin Dc_MessageDlgFont(´Esta é a mensagem de teste.´, mtInformation, [mbOk], 0, 12, mrOk, True); end;
Se algum camarada quiser se aventurar e montar um algoritimo ou saiba outra técnica de centralizar os botões...ficaria bem legal.
16/12/2005
Adriano Santos
16/12/2005
Rogerio_amorim
Vou dar uma olhada na função.
Rogerio Amorim
16/12/2005
Emerson Nascimento
function Dc_MessageDlgFont(Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; IndiceHelp: LongInt; AFontSize: Integer; DefButton: TMOdalResult = mrNone; Portugues: Boolean = True): Word; var I, Ajuste, BotaoMax, BotaoMin, LarguraMax: integer; Mensagem: TForm; begin Mensagem := CreateMessageDialog(Msg, AType, Abuttons); Mensagem.Width := 300; Mensagem.HelpContext := IndiceHelp; with Mensagem do begin for i := 0 to ComponentCount - 1 do begin if (Components[i] is TButton) then if (TButton(Components[i]).ModalResult = DefButton) then ActiveControl := TWincontrol(Components[i]); {Procura o label e altera o tamanho} if ((Components[i] is TLabel)) and (AFontSize > 0 ) then TLabel(Components[i]).Font.Size := AFontSize; end; if Portugues then begin if Atype = mtConfirmation then Caption := ´Confirmação´ else if AType = mtWarning then Caption := ´Aviso´ else if AType = mtError then Caption := ´Erro´ else if AType = mtInformation then Caption := ´Informação´; end; end; if Portugues then begin TButton(Mensagem.FindComponent(´YES´)).Caption := ´&Sim´; TButton(Mensagem.FindComponent(´NO´)).Caption := ´&Não´; TButton(Mensagem.FindComponent(´CANCEL´)).Caption := ´&Cancelar´; TButton(Mensagem.FindComponent(´ABORT´)).Caption := ´&Abortar´; TButton(Mensagem.FindComponent(´RETRY´)).Caption := ´&Repetir´; TButton(Mensagem.FindComponent(´IGNORE´)).Caption := ´&Ignorar´; TButton(Mensagem.FindComponent(´ALL´)).Caption := ´&Todos´; TButton(Mensagem.FindComponent(´HELP´)).Caption := ´A&juda´; end; BotaoMax := -1; BotaoMin := Mensagem.Width; LarguraMax := -1; for i := 0 to Mensagem.ComponentCount-1 do if Mensagem.Components[i] is TButton then begin BotaoMax := Max(BotaoMax,TButton(Mensagem.Components[i]).Left); BotaoMin := Min(BotaoMin,TButton(Mensagem.Components[i]).Left); LarguraMax := Max(LarguraMax,TButton(Mensagem.Components[i]).Width); end; Ajuste := ((Mensagem.Width - ((BotaoMax + LarguraMax) - BotaoMin)) div 2) - BotaoMin; for i := 0 to Mensagem.ComponentCount-1 do if Mensagem.Components[i] is TButton then TButton(Mensagem.Components[i]).Left := TButton(Mensagem.Components[i]).Left + Ajuste; Result := Mensagem.ShowModal; Mensagem.Free; end;
Clique aqui para fazer login e interagir na Comunidade :)