Update secondary form without changing primary focus

3

I've developed a program in Delhi that has two forms , one with a grid and another with a map, the operation is simple: of the vehicle is updated on the map, the problem is that every time I call the procedure on the map form to update the position I lose the focus of the form containing the grid , and even if I throw the focus back ugly the windows changing colors due to losing focus.

How can I update the data in the secondary window without having to focus on it?

    
asked by anonymous 03.02.2014 / 05:45

3 answers

1

Try this:

procedure BotãoFormGridClick(Sender: TObject);
begin

   FormulárioMapa.Visible := False; // Oculta o form, fazendo com que qualquer 
                                   // foco não seja executado
   FormulárioMapa.ProcedimentoMapa(); // Executa seu procediemnto
   FormulárioMapa.Visible := True; // Não usar um 'Show()'. Com o visible, 
                                   // ele volta a aparecer sem executar um foco

end;
    
03.02.2014 / 11:14
1

As per an answer on stackoverflow.com, you can do a window not having the focus activated on it overwriting the CreateParams function and in C # looks like this:

private const int WS_EX_NOACTIVATE = 0x08000000;
protected override CreateParams CreateParams
{
    get
    {
        CreateParams createParams = base.CreateParams;
        createParams.ExStyle = WS_EX_NOACTIVATE;
        return createParams;
    }
}

Since this article from delphi.about.com, we have this function can be about written in Delphi as follows:
1

private
procedure CreateParams
 (var Params: TCreateParams); override;

2nd

procedure TForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);

{ -- seu código aqui -- }

end;

The chances are that if you can reproduce the function shown in C # in Delphi you will get the same result as the change.

    
03.02.2014 / 11:27
-1

You can use this implementation ( link ). Basically you sign a message and every time it occurs, it triggers an action and can even send an object. If you are having trouble using it please let me post an example.

    
03.02.2014 / 20:55