Jump to content

Lajos Juhász

Members
  • Content Count

    817
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Lajos Juhász


  1. When the user moves outside the rect you want to move the rectangle to the first position thus the AnimateFloat should be corrected:

     

    procedure TForm2.Rectangle2MouseLeave(Sender: TObject);
    begin
       Rectangle2.AnimateFloat('Position.y', 222.0, 5, TAnimationType.InOut,
        TInterpolationType.Linear);
    //  Rectangle2.Position.y := (Rectangle1.Position.Y + 200);
    end;

    Now you can easily see the real problem. As the rectangle is moved the mouse will get outside the rectangle and that will trigger the mouse leave event. To solve this you can change the height of the rectangle to 300.

    • Like 1

  2. 1 hour ago, programmerdelphi2k said:

    FreeAndNil(frmMainSIG.frmSIG.dlgFileSave);

    What a great suggestion to free a component from a form. That's a huge NO. If it's in a try ... finally it must be a local reference not a global one. programmerdelphi2k as others wrote please make sure that your reply brings something to the topic here the goal is to help and not to reply to every post.

     

    If a reference is freed in a code it should be local:

     

    var
      dlgFileSave: TSaveDialog;
    
    begin
      dlgFileSave:=TSaveDialog.create(nil);
      try
        ...
      finally
        dlgFileSave.Free;
      end;   
    end;

    The code to save csv is almost how it should be, the problem there is that the wrong reference is freed. Instead of frmMainSIG.frmSIG.dlgFileSave the saveCSV should be freed. 

     

    var
      Excel: Variant;
      Linha, i : Integer;
      mostrar : boolean;
      caminho, edtCaminhoRelatorio, nome, extensao, saveDir: string;
      saveCSV: TSaveDialog;
      f: TextFile;
    
    begin
      if not frmImovel.qryPesq.IsEmpty then
        begin
        if Application.MessageBox('Deseja acompanhar o Excel carregando as informações?', 'Opção',MB_YESNO+MB_ICONINFORMATION) = mrYes then
          begin
            mostrar := true;
            showMessage('Não clique no Excel até que o procedimento termine, isso interrompe o carregamento.');
          end
          else
          begin
            mostrar := false;
            showMessage('O Excel está oculto gerando as informações. Clique em "OK" para continuar. O sistema ficará desabilitado até que termine.');
          end;
    
          frmSig.jvAlertaProgress.MessageText := 'Iniciado!';
          frmSig.jvAlertaProgress.Execute;
          frmExportarImovel.progressBarQry.Max := frmImovel.qryPesq.RecordCount;
    
          frmImovel.qryPesq.First;
          Excel := CreateOleObject('Excel.Application');
          Excel.Workbooks.Add;
          Excel.Visible := mostrar;
          Linha := 1;
    
          for i := 0 to frmImovel.qryPesq.FieldCount - 1 do
            Excel.WorkBooks[1].Sheets[1].Cells[Linha,i+1] := frmImovel.qryPesq.Fields[i].DisplayName;
            Linha := 2;
    
          while not frmImovel.qryPesq.Eof do
          begin
            for i := 0 to frmImovel.qryPesq.FieldCount - 1 do
              Excel.WorkBooks[1].Sheets[1].Cells[Linha,i+1] := frmImovel.qryPesq.Fields[i].Text;
    
              frmImovel.qryPesq.Next;
              Linha:=Linha+1;
              atualizaTela;
          end;
    
          Excel.Visible := false;
          sleep(100);
    
          // Salvar como CSV
          saveCSV:= TSaveDialog.Create(nil);
          try
            saveCSV.Title:= 'Salvar como CSV';
            saveCSV.Filter:= 'Arquivo CSV|*.csv';
            saveCSV.DefaultExt:= 'csv';
            saveCSV.FilterIndex:= 1;
    
            if saveCSV.Execute then
            begin
              AssignFile(f, saveCSV.FileName);
            end;
    
            Excel.ActiveWorkbook.saveas(saveCSV.FileName);
            Excel.Workbooks[1].Close;
            Excel.Quit;
            Excel := Unassigned;
    
            showMessage('Arquivo CSV salvo com sucesso!');
    
            frmSig.jvAlertaProgress.MessageText := 'O Relatório foi Gerado com Sucesso!';
            frmSig.jvAlertaProgress.Execute;
    
            progressBarQry.Position := 0;
            lblProgresso.Caption := '0 de 0';
            lblProgresso.Refresh;
    
            if Application.MessageBox('Deseja abrir o arquivo?', 'Opção', MB_YESNO+MB_ICONINFORMATION) = mrYes then
              ShellExecute(Handle, 'open', PChar(saveCSV.FileName), nil, nil, SW_SHOWNORMAL);
           finaly
             saveCSV.Free;
           end;  
          end
          else
            showMessage('Tabela não possui dados para serem exportados!');
    end;

     

     

    • Like 2
    • Haha 1

  3. 12 minutes ago, Zazhir said:

    After a click in this buttons, what I need to do is to destroy the frmMainSIG.frmSIG.dlgFileSave, to when I click in another button, the component are clean and ready to use!

    The line that "breaks" my code, only after a already generate the first file, is the if not frmImovel.qryPesq.IsEmpty then (first line).

    How can I do that, because the FreeAndNil method is not working for this case 😞

    Please define "the component are clean and ready to use". You can reuse the dialog component without freeing it. In this case your freeing it and set the reference to nil (freeandnil) then try to access a nil object reference.

     

    You cannot do that. Just remove FreeAndNil. In case you would like to use a fresh dialog object just use a local variable instead of a global one then you can free it at the end of the procedure/method wherever this code snippet was copied from.

     

     

    • Like 1

  4. You can simply achieve that by changing that option and then recompile your source.

     

    Seriously you believe we can see your monitor and to read what you're doing?! You should give enough information. We don't know which database you're using and what you're doing. In SQL there is no concept of temporary primary key. You have only two options when you create a database table. The table has a key or it doesn’t (you can also create a primary key and later drop it).

     


  5. 52 minutes ago, angusj said:

    Bernie, it seems that you're trying to maintain 100% quality which defeats the purpose of the JPEG format, since you'll get virtually no compression.

    I would disagree here, my test bmp was 2.55MB in jpeg it's 277Kb.

     

    16 hours ago, BennieC said:

    However, I cannot get the codec to perform the compression.  My code looks as follows

    You should give more details. For example what is the error message or exception you receive. Please do not forget we are no hackers and have no access to your environment (cannot hack into your computer to see your display). If it's possible always post a minimal test case that we can copy and compile.

     

    I've tested with this code:

     

    procedure TForm1.Button1Click(Sender: TObject);
    var
      NewBitmap: TBitmap;
      CodecParams : TBitmapCodecSaveParams;
      MS1 : TMemoryStream;
      Surf: TBitmapSurface;
      JpgQuality : TBitmapCodecSaveParams;
    
    begin
      ms1:=TMemoryStream.Create;
      try
        newBitmap:=Tbitmap.Create;
        newBitmap.LoadFromFile('d:\original.bmp');
    
        JpgQuality.Quality := 100;
    
        MS1.Position := 0;
        Surf := TBitmapSurface.Create;
        try
          Surf.assign(NewBitmap);
          // use the codec to save Surface to stream
            if not TBitmapCodecManager.SaveToStream(
                             MS1,
                             Surf,
                             '.jpg', @JpgQuality) then
    
              raise EBitmapSavingFailed.Create(
                    'Error saving Bitmap to jpg');
    
    
          ms1.Position:=0;
          ms1.SaveToFile('d:\original_bmp.jpg');
        finally
          Surf.Free;
        end;
      finally
        ms1.Free;
      end;
    end;

     

    • Like 1

  6. I used Default on record maybe once or twice. On the other side I rarely have a chance to use records. Nowdays it's almost always a class I am working with. 

     

    Generally speaking, when it's important for readability I do like to initialize a variable/field/record just to have a cleare code when I have to revisit it. 

    • Thanks 1

  7. 1 hour ago, Vandrovnik said:

    Shall I translate it for myself as "Give us your money for new versions (you can pay for 1, 2 or even 3 years), but we will not tell you what you get for your money."?

     

    Yes of course. Also that they find no interest in publishing when we can expect a point release (including bug fixes). You bought what you bought (without support you get 0 bugfix) if there is a bug you're a developer and should write your code that will overcome the bugs.

    This is not acceptable for Windows but it's working as updates/new version from MS doesn't requires changes in the toolchain. On the other side mobile platforms with every new version require an update in the toolchain they cannot support new OS releases.

     

    If you're using Delphi for an application you just have to figure out your developing cycle without knowing when you can expect bug fixes or new version with updates that you could use.


  8. 1 hour ago, Brandon Staggs said:

     

    Can someone explain the rationale for putting beta versions of Delphi behind a "premium" subscription, instead of just opening it up to any subscribers who are willing to beta test Delphi?

     

    Why not? It's a priviledge to get access to some kind of "road map information". Their task is also to help to complete the version. This it's premium service of the customers towards the company!

    • Like 1
    • Haha 3
×