routine in Delphi for Lazarus lazarus / 13-General ---------------------------------------------------------------------- silviogs · 2006-05-31 14:48 Hi friends it would like to change this routine for lazarus. Somebody could help? Code: [Select] unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, StdCtrls; type   TForm1 = class(TForm)     Button1: TButton;     Memo1: TMemo;     procedure Button1Click(Sender: TObject);   private     function Dc_MessageDlgCheck(Msg: String; AType: TMsgDlgType;       AButtons: TMsgDlgButtons; IndiceHelp: Integer;       DefButton: TMOdalResult; Portugues, Checar: Boolean;       MsgCheck: String; Funcao: TProcedure): Word;     { Private declarations }   public     { Public declarations }   end; var   Form1: TForm1; implementation {$R *.dfm} function TForm1.Dc_MessageDlgCheck(Msg :String; AType: TMsgDlgType; AButtons : TMsgDlgButtons;   IndiceHelp : LongInt; DefButton : TMOdalResult; Portugues: Boolean; Checar : Boolean; MsgCheck : String; Funcao : TProcedure) : Word; var    I         : Integer;    Mensagem  : TForm;    Check     : TCheckBox; begin      Check := Nil;      Mensagem := CreateMessageDialog(Msg, AType, Abuttons);      Mensagem.HelpContext := IndiceHelp;      with Mensagem do begin         for i :=0 to ComponentCount -1 do begin            if (Components[i] is TButton) then begin               if (TButton(Components[i]).ModalResult = DefButton) then begin                  ActiveControl := TWincontrol(Components[i]);               end;            end;         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';           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;      End;      if Checar then begin         Mensagem.ClientHeight := Mensagem.ClientHeight + 20;         Check  := TCheckBox.Create(Mensagem);         Check.Parent  := Mensagem;         Check.Left    := 15;         Check.Top     := Mensagem.ClientHeight - 20;         Check.Visible := True;         Check.Caption := MsgCheck;         Check.Width   := Mensagem.ClientWidth - 10;      end;      Result := Mensagem.ShowModal;      if Check.Checked then Funcao;      Mensagem.Free; end; procedure TForm1.Button1Click(Sender: TObject);   procedure MinhaFuncao;   begin     Form1.Memo1.Lines.Clear;     Form1.Memo1.Lines.Add('Ok. O usuário clicou no checkbox');   end; begin   if Dc_MessageDlgCheck('Marque o CheckBox abaixo e veja que a função declarada no botão é acionada.' +     #13#10 + 'E ainda note que os botões da MessageDlg estão em português sem ter que traduzir do Dialogs.pas' + #13#10 +     'Aproveitando, veja que da pra deixar o segundo botão como Padrão' + #13#10#13#10 +     'Clique no botão "SIM" para ver o efeito.',     mtInformation,[mbYes,mbNo],0,mrNo,True,     True,'Clique aqui para atualizar o Memo1',@MinhaFuncao) = mrYes then begin     ShowMessage('Veja o Memo na tela do exemplo caso tenha marcado o checkbox');   end; end; end. respectfully Silvio Guedes Edited by Matthijs. I placed code tags for better readability of the code. ---------------------------------------------------------------------- SergKam · 2006-05-31 18:30 What stop you? ---------------------------------------------------------------------- silviogs · 2006-05-31 19:51 Hi friends Unit1.pas(48,18) Error: Identifier not found "CreateMessageDialog" Unit1.pas(83,34) Hint: Type size mismatch, possible loss of data / range check error Unit1.pas(88,4) Fatal: Syntax error, "." expected but ";" found in delphi CreateMessageDialog is used (Msg, AType, Abuttons) but is not finding the function that it substitutes. Thank you very much Silvio Guedes ---------------------------------------------------------------------- Legolas · 2006-05-31 22:39 IIRC lazarus does not have any CreateMessageDialog function. You should make a new form that acts like a message dialog and use it instead CreateMessageDialog.