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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...