Leaderboard
Popular Content
Showing content with the highest reputation on 01/18/23 in Posts
-
Destroy or clean TSaveDialog after save
Lajos Juhász replied to Zazhir's topic in Algorithms, Data Structures and Class Design
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; -
Does ChatAI make StackOverflow obsolete ?
dummzeuch replied to david_navigator's topic in Tips / Blogs / Tutorials / Videos
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.) -
Delphi 11.2 unofficial LSP patch
Lars Fosdal replied to Brandon Staggs's topic in Delphi IDE and APIs
Any company would add such a disclaimer when releasing unofficial "patches". It means: If it didn't work, don't blame us. -
How to detect if a Dialog is open/running?
Anders Melander replied to Ian Branch's topic in General Help
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; -
Does ChatAI make StackOverflow obsolete ?
David Heffernan replied to david_navigator's topic in Tips / Blogs / Tutorials / Videos
I think the answer to the original question is no -
Help installing TProcess on Delphi Sydney 10.4
Lajos Juhász replied to UtopicLabs's topic in General Help
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). -
Delphi 11.2 unofficial LSP patch
pyscripter replied to Brandon Staggs's topic in Delphi IDE and APIs
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. -
Delphi 11.2 unofficial LSP patch
Stefan Glienke replied to Brandon Staggs's topic in Delphi IDE and APIs
Why would LSPServer affect anything that dcc32/64 do? -
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:
-
In App Purchase (consumable and subscription)
Brian Evans replied to Joe Sansalone's topic in Cross-platform
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) -
Destroy or clean TSaveDialog after save
programmerdelphi2k replied to Zazhir's topic in Algorithms, Data Structures and Class Design
try some like this: -
Destroy or clean TSaveDialog after save
Lajos Juhász replied to Zazhir's topic in Algorithms, Data Structures and Class Design
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. -
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.
-
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
-
Destroy or clean TSaveDialog after save
programmerdelphi2k replied to Zazhir's topic in Algorithms, Data Structures and Class Design
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!