Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/18/23 in all areas

  1. 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;
  2. dummzeuch

    Does ChatAI make StackOverflow obsolete ?

    Sorry, I couldn't resist letting ChatGPT write a reply to this: (I'll try to resist in the future though because I don't want this to escalate into a thread that consists of ChatGPT generated stuff only.)
  3. Lars Fosdal

    Delphi 11.2 unofficial LSP patch

    Any company would add such a disclaimer when releasing unofficial "patches". It means: If it didn't work, don't blame us.
  4. Anders Melander

    How to detect if a Dialog is open/running?

    I'm not sure I understand your description, but you might: Check Application.ModalLevel to determine if a (Delphi) modal dialog is active. Check Screen.ActiveForm to determine exactly which form is currently active. or simply avoid the problem altogether by not executing the timer code while a modal dialog is active: procedure TMyForm.TimerAlertMessageTimer(Sender: TObject); begin TTimer(Sender).Enabled := False; try var FormAlertMessage := TFormAlertMessage.Create(Self); try FormAlertMessage.ShowModal; finally FormAlertMessage.Free; end; finally TTimer(Sender).Enabled := True; end; end; or procedure TMyForm.TimerAlertMessageTimer(Sender: TObject); begin if (Application.ModalLevel > 0) then exit; // Modal dialog is active; Punt! var FormAlertMessage := TFormAlertMessage.Create(Self); try FormAlertMessage.ShowModal; finally FormAlertMessage.Free; end; end;
  5. David Heffernan

    Does ChatAI make StackOverflow obsolete ?

    I think the answer to the original question is no
  6. Lajos Juhász

    Help installing TProcess on Delphi Sydney 10.4

    The repository doesn't contains the files to install the component. You can use it from code (hint there are demo projects to show how you can use it).
  7. pyscripter

    Delphi 11.2 unofficial LSP patch

    FWIW, I have tried the unofficial LSP patches and I could no longer debug programs. So I went back to the original dlls and debugging was available again.
  8. Stefan Glienke

    Delphi 11.2 unofficial LSP patch

    Why would LSPServer affect anything that dcc32/64 do?
  9. aehimself

    I get value=none

    This is the second post where you are simply being rude and offending everyone around you. I learned it a long time ago but it's not clearly documented, but a solution can be found by hovering over a user's name:
  10. Brian Evans

    In App Purchase (consumable and subscription)

    Read the help topics and use the events not some Sleep/ProcessMessages messages loop. Using the iOS In-App Purchase Service - RAD Studio (embarcadero.com) Using the Google Play In-app Billing Service - RAD Studio (embarcadero.com) There is also a demo that includes in app purchases: FMX.CapitalIAP Sample - RAD Studio Code Examples (embarcadero.com)
  11. 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.
  12. vfbb

    Upload Google Play android FMX app problem

    You should edit your AndroidManifest.template.xml (You can found it template in your dproj folder after the first compilation to android platform), and not the final AndroidManifest in deploy path.
  13. Mustafa ֍zgun

    Integrate AAR SDK in FMX Android app

    Hi https://docwiki.embarcadero.com/RADStudio/Sydney/en/Adding_A_Java_Library_to_Your_Application_Using_the_Project_Manager https://stackoverflow.com/questions/39450528/adding-a-java-library-file-aar-in-rad-studio-10-seattle
  14. confused code! try create your "Excel" just one time... out any procedure! for example, before any use in your unit. Then, when all end, just free it!
×