Jump to content

Recommended Posts

Posted
I have a problem when I try to destroy a TUniTabSheet that wire added to a UniPageControl1. The scenario is the following: In UniTabSheet will be added to a frame. In this frame I have a preparation method for the same, which is not satisfactory if the UniTabSheet should be destroyed. What happens is that when this method fails preparation, UniTabSheet not being destroyed in any way. I've tried numerous methods and nothing. What is wrong?
And for some reason it can not Diser, any message that is triggered in the frame of the preparation method, is not shown.
 
procedure TMainForm.CriaFrame;
var FrC : TUniFrameClass;
    Fr : TUniFrame;
    tb:TUniTabSheet;
begin
         FrC := TUniFrameClass(FindClass(Classframe));
                if frc <> nil then
                begin
                     tb := TUniTabSheet.Create(Self);
                     tb.Closable := True;
                     tb.PageControl := UniPageControl1;
                     tb.Caption := 'teste';
                     tb.Tag := CriaFrameRec.Tag;
                     Fr := FrC.Create(tb);
                     if fr <> nil then
                     begin
                          Fr.Align := alClient;
                          Fr.Parent := tb;
                          if datamodel.link.Util.ExecutaMetodo(fr,'prepara') then
                          begin
                               tb.Caption := CriaFrameRec.Grupo.Titulo;
                               tb.TabVisible := True;
                               UniPageControl1.ActivePage := tb;
                          end else
                          begin
                               FreeAndNil(fr);
                                //tb.close;
                               //tb.TabVisible := False;
                               //tb.Visible := false;
                               for count := UniPageControl1.PageCount-1 downto 0 do
                               begin
                                    if UniPageControl1.Pages[count].Tag = CriaFrameRec.Tag then
                                    begin
                                         UniPageControl1.Pages[count].FreeOnRelease;
                                         //UniPageControl1.Pages[count].Close;
                                         //UniPageControl1.Pages[count].Destroy;
                                         Break;
                                    end;
                               end;
                               UniPageControl1.Refresh;
                               count := UniPageControl1.PageCount;
                               //tb.close;
                               {fr.Free;
                               tb.Free;
                               tb := nil;}
                          end;
              end;
 
end;
---------------------------------------------------------------------
frame:
 
function TframeVendaFastFoodMC.Prepara: boolean;
begin
         result := false;
         MessageDlg('teste.',mtWarning,mbOKCancel);
end;

 

 

class function TUtil.ExecutaMetodo(const Instance: Tobject;
  MethodName: string): Boolean;
type TInicializa = function :Boolean of object;
var Routine: TMethod;
    Inicializa :TInicializa;
begin
     Try
        Result := false;
        if (Instance <> nil) and (MethodName <> '') then
        begin
             Routine.Data := Pointer(Instance);
             Routine.Code := Instance.MethodAddress(MethodName);
             if Routine.Code <> nil then
             begin
                  Inicializa := TInicializa(Routine);
                  Result := Inicializa;
             end;// else
        end;
     except
        raise;
     end;
end;

post-1670-0-86856500-1467216509_thumb.jpg

Posted
I have discovered the cause of the problems. This is already reported in another post regarding the combobox component. This component has a bug that needs to be corrected urgently. "C is not a constructor"

If we add this component in frame, form, etc. and you try to destroy this object is the ajax error "c is not a constructor."

 


Posted

Hi,

If I understand correctly you
If you want destroing a Frame right after creating it, as Farshad said, is not a valid practice in uniGUI

 

Please decide before creating the frame

Posted
Any solution to tell this? I tried to destroy the combo component form before the destroy, but still occurs ajax exception "C is not a constructor." In the server I scored to suppress ajax error, but for some reason with this option, the messages should be shown the process, they are also suppressed.

The error occurs if you add a combobox in a frame, and this frame is destroyed.

An alternative would be to create the I frame, even if the process is not valid, then control and for taime so that it is closed without detruir. However this is not ideal

Posted

In the frame there is data that needs to be loaded and validated. If that fails the continuity must be aborted. You can not check this before. Therefore, the frame preparation method. However only noticed problems with Tunicombox component, which for some reason it seems that something is still running even after the destruction of the frame.

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