Jump to content

Recommended Posts

Posted

Bom dia,
criei um procedimento para criar abas em tempo de execução, mas tem uma tela que as vezes dá erro...
não consegui identificar o motivo...

Na minha tela tenho um unidbgrid com os eventos: OnCellClick, OnDblClick, OnFieldImage e OnSetCellValue.
Em OnDblClick eu chamo um procedimento que cria um UniTabShet em um UniPageControl.

procedure TFormConsultaContasReceberVencidas2.UniDBGrid1DblClick(
  Sender: TObject);
begin
  inherited;
  if uniDBGrid1.CurrCol = uniDBGrid1.Columns.Items[0].Index then begin
    if not qryTotalizado.IsEmpty then begin
      isFechaAba := True;
      criarAba(TFormCadastroCliente2, 'Cadastro de Clientes', 'CLIEA13ID = ' + QuotedStr(qryTotalizadoCLIEA13ID.AsString), EmptyStr);
    end;
  end;
  if uniDBGrid1.CurrCol = uniDBGrid1.Columns.Items[5].Index then begin
    DSMasterSys := dsTotalizado;
    criarAba(TFormCadastroClienteHistorico2, 'Cadastro Cliente Histórico', 'CLIEA13ID = ' + QuotedStr(qryTotalizadoCLIEA13ID.AsString), 'Cliente ' + qryTotalizadoCLIEA60RAZAOSOC.AsString)
  end;
end;

procedure criarAba(frame: TUniFrameClass; tituloTab, filtro, titulo: String);
var
  tab: TUniTabSheet;
  FCurrentFrame: TUniFrame;
  qryTemplate: TFDQuery;
  tabName: String;
begin
  try
    tab := getAba(frame, FormPrincipal.upcPrincipal);
    if tab <> nil then
    begin
      if frame = TFormCadastroCliente2 then
      begin
        if isFechaAba then
        begin
          isFechaAba := False;
          tab.Close;
        end
        else
        begin
          FormPrincipal.upcPrincipal.ActivePage := tab;
          Exit;
        end;
      end
      else
      begin
        FormPrincipal.upcPrincipal.ActivePage := tab;
        Exit;
      end;
    end;

    FormPrincipal.ShowMask('Aguarde...');
    UniSession.Synchronize();

    tab := TUniTabSheet.Create(FormPrincipal.upcPrincipal);

    if frame.ClassName.Contains('TFrmCadastro') then
      tabName := StringReplace(frame.ClassName, 'TFrmCadastro', 'tab', [rfReplaceAll, rfIgnoreCase])
    else if frame.ClassName.Contains('TFrame') then
      tabName := StringReplace(frame.ClassName, 'TFrame', 'tab', [rfReplaceAll, rfIgnoreCase])
    else if frame.ClassName.Contains('TFrm') then
      tabName := StringReplace(frame.ClassName, 'TFrm', 'tab', [rfReplaceAll, rfIgnoreCase])
    else
      tabName := 'tab' + frame.ClassName;

    tab.Name := tabName;
    tab.caption := tituloTab;
    tab.PageControl := FormPrincipal.upcPrincipal;
    tab.OnClose := FormPrincipal.TabClose;
    tab.Closable := True;

    FCurrentFrame := TUniFrameClass(frame).Create(tab);

    if not Trim(titulo).IsEmpty then begin
      if Trim(FCurrentFrame.Hint).IsEmpty then
        FCurrentFrame.Hint := titulo
      else
        FCurrentFrame.Hint := titulo + ' - ' + FCurrentFrame.Hint;
    end;

    if FCurrentFrame.FindComponent('lblTitulo') <> nil then
      (FCurrentFrame.FindComponent('lblTitulo') as TUniLabel).caption := FCurrentFrame.Hint;
    qryTemplate := (FCurrentFrame.FindComponent('qryTemplate') as TFDQuery);

    if qryTemplate <> nil then begin
      if filtro.IsEmpty then
        qryTemplate.MacroByName('filtro').Value := qryTemplate.Fields.Fields[0].FieldName + ' IS NULL'
      else
       qryTemplate.MacroByName('filtro').Value := filtro;
       qryTemplate.Open();
    end;

    FCurrentFrame.Align := alClient;
    FCurrentFrame.Parent := tab;
    FormPrincipal.pnlEsquerdo.Width := 210;
    FormPrincipal.upcPrincipal.ActivePage := tab;
  finally
    FormPrincipal.HideMask;
  end;
end;

https://ibb.co/KwBwMhb


Obs: Nem sempre o erro acontece, acontece de vez em quando!

Se alguém souber o motivo e puder me ajudar a ficarei grato.

Posted
4 minutes ago, Sherzod said:

Olá,

Em primeiro lugar, especifique qual edição e compilação do uniGUI você está usando?

Version: 1.90.0 build 1501

Posted
26 minutes ago, Sherzod said:

Com que frequência o erro ocorre?
Você pode atualizar para a versão mais recente e verificar?

occurs randomly, apparently when I remove the snippet below it works correctly:

FormPrincipal.ShowMask('Wait...');

UniSession.Synchronize();

But I don't know if it really has anything to do with the problem.

I am currently unable to update to the latest version...

  • 2 weeks later...
Posted
On 29/11/2022 at 14:37, Sherzod said:

Com que frequência o erro ocorre?
Você pode atualizar para a versão mais recente e verificar?

would you know any other possible solution to solve this problem?

  • 2 weeks later...
  • 9 months later...
Posted

@Sherzod@Hayri ASLAN@Farshad Mohajeri

I see that there are several posts related to "showmask".

I'm also having problems using synchronize and I see that it's better not to use it, but when should it really be used? Because there are some situations where some things only work with it.

Ex: I click on the menu to call a form/frame but immediately click on another option. This sometimes works but sometimes generates an error with something called "tabconfig" that I've seen other related posts about this with no response.
This seems like the wrong thing to do, but we develop systems for other users, and these users do unimaginable things and we need to try to create solutions to avoid this.

Another situation is to keep a mask active until I actually order it to stop (hide), for example:

- I click on unitreemainmenu - mask is displayed;
- open a form/frame;
- process some queries;
- I hide the mask;

This doesn't work, because when activating the mask of a UniDBGrid, for example, which is linked to one of the queries, the first mask (referring to the menu click) is already interrupted.

I don't know if I managed to make myself understood, but basically, it's the same thing I've seen in other posts, but there was also no continuity.

PS: It's not just me with this question and of course, I could be doing something wrong but I can't find the solution and that's why I'm asking for help.

  • Like 1
  • Upvote 1
Posted

I have showmask enabled in a unitreemenu.

How could I do it so that when I click on a SUBMENU the showmask is not displayed?

In other words, I want the showmask to be shown only when clicking on an option without submenus.

Posted
On 10/14/2023 at 9:18 PM, mikromundo said:

I have showmask enabled in a unitreemenu.

How could I do it so that when I click on a SUBMENU the showmask is not displayed?

In other words, I want the showmask to be shown only when clicking on an option without submenus.

If possible, make a simple testcase to check.

  • 2 weeks later...
Posted

I'm also having freezes, in my case it's a frame with a grid, the mask is on the grid, several times it freezes and remains frozen for a few seconds, until released

  • 1 year later...

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...