Jump to content

Ian Branch

Members
  • Content Count

    850
  • Joined

  • Last visited

  • Days Won

    2

Ian Branch last won the day on September 25 2021

Ian Branch had the most liked content!

Community Reputation

80 Excellent

Technical Information

  • Delphi-Version
    Delphi 11 Alexandria

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ian Branch

    wuppdi Welcome Page for Delphi 11 Alexandria?

    Perfect. Thank you. Follow up.. Getting this error when I go to close an App I am editing, or trying to close Delphi. Running D11.2. Need to use Task Manager to close Delphi.
  2. Ian Branch

    wuppdi Welcome Page for Delphi 11 Alexandria?

    Hi @gkobler, I have one tiny preference... In a favorite's folder I have my Project Group and Projects. It would be really nice, and this is a personal preference, no obligation, if when sorting the projects the the group was the first entry. I'm sure others would have a different preference.. Regards Ian
  3. Ian Branch

    Any advantage to using FastMM5??

    Hi David, I wasn't expecting insights into my own programs performance. Rather, I was seeking the experiences of others. I have tossed the coin and removed FastMM5 att and loaded it to the Customer. We shall see if they notice anything. Ian
  4. Ian Branch

    Any advantage to using FastMM5??

    Hi David, You know, as I was writing the item I thought to myself.. The first thing someone is going to say is "it depends". 🙂 I don't believe timing it on my dev PC is not going to reveal anything useful one way or the other, compared to the real-world usage on a LAN with diverse workstation OSs, RDP & WEB access usage. And, I don't feel it is good practice to use the Customers as test agents for something like this. Ian
  5. Ian Branch

    Any advantage to using FastMM5??

    Hi Team, In the 'Old' days I used FastMM4 in lieu of Delphi's MM because there was tangible performance, amongst other, benefit. Since then, Emba has incorporated aspects of FastMM4 to improve their own Delphi MM. Nevertheless I moved to FastMM5 when it was released and have incorporated it in every App since. I know I don't use FastMM5 to its fullest. FWIW I use EurekaLog for debugging/logging. All my Apps are simple Win32 Apps with only the occasional foray into a single thread for a database or background process. So, to my question, given the current state of play of Delphi's MM, I use D11.2 now, is using FastMM5 of any benefit to me/my Apps or am I simply including it because I always have, to no benefit?? As a side note: EurekaLog actually accommodates FastMM5 so that may be an influencing factor, or it may be simply to ride on some aspect of FastMM5... Regards & TIA, Ian
  6. Ian Branch

    Close App on PC Shutdown??

    Hi Angus, Pat, I have a working solution the minimizes the amount of changes I have to make to other Apps. I made some changes to Pat's code to facilitate this. procedure TMainForm.CloseDB; var TS: TTimeSpan; StartDateTime, FinishDateTime: TDateTime; lUsersLogWritten: Boolean; sAction: string; begin // if dmC.DBC1.Connected then begin // // ' check savepoints or cache status? CancelEditsInsertsInDatamodules; CancelEditsInsertsInOpenForms; // CloseOpenForms; // Pat says Boo! // dmC.DBC1.CloseDataSets; // end; // case iTerminateAction of 0: sAction := 'Logged Out'; 1: sAction := 'Timed Out'; 2: sAction := 'Browser Closed'; 3: sAction := 'PC Shut Down'; end; // dmC.UsersLog.IndexName := 'SessionKey'; dmC.UsersLog.Open; // if dmC.UsersLog.FindKey([sSessionKey]) then begin // dmC.UsersLog.Edit; // dmC.UsersLog.FieldByName('Action').AsString := sAction; dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime := now; StartDateTime := dmC.UsersLog.FieldByName('StartDateTime').AsDateTime; FinishDateTime := dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime; TS := TTimeSpan.Subtract(FinishDateTime, StartDateTime); dmC.UsersLog.FieldByName('Duration').AsString := Format('%.3d:%.2d:%.2d:%.2d', [TS.Days, TS.Hours, TS.Minutes, TS.Seconds]); dmC.UsersLog.Post; // lUsersLogWritten := True; // end; // dmC.UsersLog.Close; // DBWReg.WriteString('Session Key', 'DBiWorkflow', ''); // dmC.DBC1.Close; dmC.DBS1.Close; dmC.DBE1.Close; // if iTerminateAction = 0 then begin // if not lUsersLogWritten then TaskMessageDlg('Workflow Closing error!', 'Note:- The Users Log was NOT updated. Workflow will now close..', mtError, [mbOK], 0); // end; // enlightenedCanClose := True; // Close; // end; procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin // CanClose := enlightenedCanClose; // SendMessage(Handle, EM_SETMODIFY, WPARAM(True), 0); // or have a MS product open that needs saved // if not CanClose then begin // if (GetSystemMetrics(SM_SHUTTINGDOWN) > 0) then begin // iTerminateAction := 3; CloseDB; // app is being closed by workstation shutdown // end; // enlightenedCanClose := True; // end; // end; My thanks to both of you for your input/education. Regards, Ian
  7. Ian Branch

    Close App on PC Shutdown??

    Hi Pat, Well I'm surprised! It seems the logging, Codesite, was influencing/affecting it and preventing the flow of the program continuing... 😞 Some more experimenting to happen. Regards, Ian
  8. Ian Branch

    Close App on PC Shutdown??

    Hi Pat, I replaced FormCloseQuery per above. I found an end; in the wrong place but commented out that section att anyway, and added some additional logging to CloseDB. procedure TMainForm.CloseDB(const ditto: string); var TS: TTimeSpan; StartDateTime, FinishDateTime: TDateTime; lUsersLogWritten: Boolean; begin // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('Enter CloseDB.'); {$ENDIF} // // if dmC.DBC1.Connected then // begin // // //{$IF Defined(ELogging) or Defined(Codesite)} // LogMessage('DBC1 is connected att.'); //{$ENDIF} // // // ////' check savepoints or cache status? // CancelEditsInsertsInDatamodules; // CancelEditsInsertsInOpenForms; // //end; // // // ///CloseOpenForms; ///Pat says Boo! // // // dmC.DBC1.CloseDataSets; // // // end; // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('dmC.UsersLog.IndexName := SessionKey'); {$ENDIF} // dmC.UsersLog.IndexName := 'SessionKey'; dmC.UsersLog.Open; // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('if dmC.UsersLog.FindKey([sSessionKey]) then'); {$ENDIF} // if dmC.UsersLog.FindKey([sSessionKey]) then begin // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('dmC.UsersLog.Edit;'); {$ENDIF} // dmC.UsersLog.Edit; // //case iTerminateAction of dmC.UsersLog.FieldByName('Action').AsString := ditto; dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime := now; StartDateTime := dmC.UsersLog.FieldByName('StartDateTime').AsDateTime; FinishDateTime := dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime; TS := TTimeSpan.Subtract(FinishDateTime, StartDateTime); dmC.UsersLog.FieldByName('Duration').AsString := Format('%.3d:%.2d:%.2d:%.2d', [TS.Days, TS.Hours, TS.Minutes, TS.Seconds]); dmC.UsersLog.Post; // lUsersLogWritten := True; // end; // dmC.UsersLog.Close; // DBWReg.WriteString('Session Key', 'DBiWorkflow', ''); // dmC.DBC1.Close; dmC.DBS1.Close; dmC.DBE1.Close; // if iTerminateAction = 0 then begin // if not lUsersLogWritten then TaskMessageDlg('Workflow Closing error!', 'Note:- The Users Log was NOT updated. Workflow will now close..', mtError, [mbOK], 0); // end; // enlightenedCanClose := True; // close; // // end; end; It is only logging/showing "Enter CloseDB", no further. I am going to turn off the logging and see if that is affecting it in some way. Will advise.
  9. Ian Branch

    Close App on PC Shutdown??

    Interesting. I tried again and got this .. but no further.
  10. Ian Branch

    Close App on PC Shutdown??

    @Pat Foley I have implemented this att.. procedure TMainForm.CloseDB(const ditto: string); var TS: TTimeSpan; StartDateTime, FinishDateTime: TDateTime; lUsersLogWritten: Boolean; begin // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('Enter CloseDB.'); {$ENDIF} // if dmC.DBC1.Connected then begin {$IF Defined(ELogging) or Defined(Codesite)} //LogMessage(IndexText[0]); LogMessage('DBC1 is connected att.'); {$ENDIF} // ////' check savepoints or cache status? CancelEditsInsertsInDatamodules; CancelEditsInsertsInOpenForms; //end; // ///CloseOpenForms; ///Pat says Boo! // dmC.DBC1.CloseDataSets; // dmC.UsersLog.IndexName := 'SessionKey'; dmC.UsersLog.Open; // if dmC.UsersLog.FindKey([sSessionKey]) then begin dmC.UsersLog.Edit; // //case iTerminateAction of dmC.UsersLog.FieldByName('Action').AsString := ditto; dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime := now; StartDateTime := dmC.UsersLog.FieldByName('StartDateTime').AsDateTime; FinishDateTime := dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime; TS := TTimeSpan.Subtract(FinishDateTime, StartDateTime); dmC.UsersLog.FieldByName('Duration').AsString := Format('%.3d:%.2d:%.2d:%.2d', [TS.Days, TS.Hours, TS.Minutes, TS.Seconds]); dmC.UsersLog.Post; // lUsersLogWritten := True; // end; // dmC.UsersLog.Close; // DBWReg.WriteString('Session Key', 'DBiWorkflow', ''); // dmC.DBC1.Close; dmC.DBS1.Close; dmC.DBE1.Close; // if iTerminateAction = 0 then begin // if not lUsersLogWritten then TaskMessageDlg('Workflow Closing error!', 'Note:- The Users Log was NOT updated. Workflow will now close..', mtError, [mbOK], 0); // end; enlightenedCanClose := True; close; end; end; procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('Enter FormCloseQuery.'); {$ENDIF} // CanClose := enlightenedCanClose; // {$IF Defined(ELogging) or Defined(Codesite)} if CanClose then LogMessage('Can Close.') else LogMessage('Can Not Close.'); {$ENDIF} // SendMessage(Handle, EM_SETMODIFY, WPARAM(True), 0); //or have a MS product open that needs saved // if not CanClose then begin if (GetSystemMetrics(SM_SHUTTINGDOWN) > 0) and not dmC.DBC1.Connected then closeDB('Workstation shut down'); // app is being closed by workstation shutdown // enlightenedCanClose := True; Close; end; end; From Codesite logging, neither CloseDB or FormCloseQuery are entered when I shut down the PC with the App running. 😞 May be a Win 11 thing. Ian
  11. Ian Branch

    Close App on PC Shutdown??

    Hi Guys, I am going to try each and see which is my best option. @Sherlock Where is this from - "Message.Unused", Delphi tells me "Message" is an undeclared identifier. Regards, Ian
  12. Ian Branch

    Change order of experts in GExperts Expert Manager

    Tks Thomas. Appreciated. Ian
  13. Ian Branch

    Close App on PC Shutdown??

    Gentlemen, Thank you for your patience and contributions. Very much appreciated and educational. As it was then and still is now, this is not an area I have any expertise in. Does it show? 😉 I will work with your suggestions. Regards & Tks again, Ian
  14. Ian Branch

    Close App on PC Shutdown??

    Hi Sherlock, Yes I did go back to that and I am just as confused now as I was then. I have the closing actions on the OnCloseQuery event. Under normal circumstances it works fine, but when the User shuts down their PC while the App is running/open it doesn't. The following is my OnCloseQuery.. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var TS: TTimeSpan; StartDateTime, FinishDateTime: TDateTime; lUsersLogWritten: Boolean; begin // if GetSystemMetrics (SM_SHUTTINGDOWN) > 0 then iTerminateAction := 3; // app is being closed by a system shutdown // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('iTerminateAction = '+IntToStr(iTerminateAction)); {$ENDIF} // lUsersLogWritten := False; // LTI1.ShowBalloonHint('Closing Workflow Database...', 'Any Open Edits and/or Inserts are being cancelled and the Database closed.'); // if dmC.DBC1.Connected then begin // {$IF Defined(ELogging) or Defined(Codesite)} LogMessage('DBC1 is connected att.'); {$ENDIF} // CancelEditsInsertsInDatamodules; CancelEditsInsertsInOpenForms; end; // CloseOpenForms; // dmC.DBC1.CloseDataSets; // dmC.UsersLog.IndexName := 'SessionKey'; dmC.UsersLog.Open; // if dmC.UsersLog.FindKey([sSessionKey]) then begin dmC.UsersLog.Edit; // case iTerminateAction of 0: dmC.UsersLog.FieldByName('Action').AsString := 'Logged Out'; 1: dmC.UsersLog.FieldByName('Action').AsString := 'Timed Out'; 2: dmC.UsersLog.FieldByName('Action').AsString := 'Browser Closed'; 3: dmC.UsersLog.FieldByName('Action').AsString := 'System Shutdown'; end; // dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime := now; StartDateTime := dmC.UsersLog.FieldByName('StartDateTime').AsDateTime; FinishDateTime := dmC.UsersLog.FieldByName('FinishDateTime').AsDateTime; TS := TTimeSpan.Subtract(FinishDateTime, StartDateTime); dmC.UsersLog.FieldByName('Duration').AsString := Format('%.3d:%.2d:%.2d:%.2d', [TS.Days, TS.Hours, TS.Minutes, TS.Seconds]); dmC.UsersLog.Post; // lUsersLogWritten := True; // end; // dmC.UsersLog.Close; // DBWReg.WriteString('Session Key', 'DBiWorkflow', ''); // dmC.DBC1.Close; dmC.DBS1.Close; dmC.DBE1.Close; // if iTerminateAction = 0 then begin // if not lUsersLogWritten then TaskMessageDlg('Workflow Closing error!', 'Note:- The Users Log was NOT updated. Workflow will now close..', mtError, [mbOK], 0); // end; // end; It doesn't work on my Win 11 PC. Happy to have the error of my ways pointed out. Regards, Ian
  15. Ian Branch

    Close App on PC Shutdown??

    Thanks Guys, Angus - I will have a look at the component. Peter - In FormCloseQuery, how can I tell if it was triggered by WM_QUERYENDSESSION ? Regards, Ian
×