Jump to content

Recommended Posts

[PT-BR]

Boa Tarde,

Estou com o seguinte problema: preciso passar uma procedure/function para ser executada como callBack de um form devido caso em que o EnableSynchronousOperations não atende ao esperado.

Essa implementação ficaria como?

Abaixo segue a ideia de como estou tentando fazer, porém sem sucesso.

Obs.: o código abaixo  é apenas um esboço para facilitar o entendimento do problema.

[ENG]

Good afternoon,

I am having the following problem: I need to pass a procedure / function to run as a form return in case the EnableSynchronousOperations does not meet expected.

This implementation would look like?

Below is an idea of how I am trying to do, but to no avail.

Note: The code below is just a sketch to make it easier to understand the problem.

/// Eu Criei uma classe com algo parecido com o seguinte
TCallBack = procedure(Sender: TComponent; Res: Integer) of object;

TFrmDialogs = class(TUniForm)

  function MessageBox(const Text: string; pCallBack: TCallBack=Nil): Integer;
end;

function MessageBox(const Text: string; pCallBack: TCallBack=Nil): Integer;
var
  vMsg: TFrmDialogs;
begin
  vMsg.Text := vMsg;

  if Assigned(pCallBack) then
  begin
    Result := vMsg.ShowModal(pCallBack);
  end
  else
    Result := vMsg.ShowModal();
end;



/// Aqui eu executo onde eu preciso (no caso em outra classe)
procedure TDataModulo.DoReconectarCallBack(Sender: TComponent; Res: Integer);
begin
   if Res <> 6 then
      // Não clicou Yes
   else
   begin
      // Clicou Yes
   end;
end;

procedure TDataModulo.Acao;
begin
  MessageBox('Minha Mensagem!', DoReconectarCallBack);
end;

Desde já obrigado à quem puder ajudar :D


[EDITED]
Esqueci de colocar o problema

I forgot to put the problem

[dcc32 Error] uAnDialogs.pas(112): E2010 Incompatible types: 'Integer' and 'procedure, untyped pointer or untyped parameter'

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...