Jump to content

Ian Branch

Members
  • Content Count

    1282
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Ian Branch

  1. Ian Branch

    Close App on PC Shutdown??

    Interesting. I tried again and got this .. but no further.
  2. 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
  3. 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
  4. Ian Branch

    Change order of experts in GExperts Expert Manager

    Tks Thomas. Appreciated. Ian
  5. 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
  6. 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
  7. 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
  8. Ian Branch

    Close App on PC Shutdown??

    Hi Team, I am advised, although I take it with a grain of salt, that they shut down the PC rather than just turn it off. Angus, what is the component you use please? Ian
  9. Ian Branch

    Problem logging into gmail..

    Hi Team, Win 11, D11.2, Indy as it came with D11.2. I am trying to receive emails from GMail so I can process them. I have the following code.. ..... with POP3 do begin Host := 'pop.gmail.com'; Username := 'MyUserName@gmail.com'; Password := 'MyPassword'; Port := 995; IOHandler := IdSSLIOHandlerSocketOpenSSL; UseTLS := utUseImplicitTLS; end; with IdSSLIOHandlerSocketOpenSSL do begin Destination := 'pop.gmail.com:995'; SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; Host := 'pop.gmail.com'; Port := 995; DefaultPort := 0; end; POP3.Connect; .... When run and it attempts to connect I get an error. "Username and password not accepted." I have verified and even reset my gmail password to no avail. I am clearly missing something, or is it a GMail thing.... Thoughts, suggestions, education appreciated. Regards & TIA, Ian
  10. Ian Branch

    Problem logging into gmail..

    Would I be correct in assuming that the same thing applies to IMAP??
  11. Ian Branch

    Problem logging into gmail..

    Tks rvk. What a PITA.
  12. Ian Branch

    Change the order of loading??

    Would it be possible for the Expert Manager to change the order of loading of Experts? I ask this in the suspicion that the order of loading will dictate which Expert functionality/hotkey will have priority. Ian
  13. Ian Branch

    Change the order of loading??

    Thank you. Appreciated. Ian
  14. Ian Branch

    TTimer limit..

    Hi Team, I just ran up against the limit of TTimer in 32bit. 4,294,967,295. 😞 I need to 'TTimer' to 15,000,000,000. Why 15,000,000,000? Because the Timer is being used to set an 8hour limit on the operation of an App. No, I can't go to 64bit. The Customer only has 32bit OS. 😞 Thoughts, suggestions appreciated. Regards & TIA, Ian
  15. Ian Branch

    Ctrl-Alt-F sometimes doesn't

    Hi Team, D11.1, latest GExperts, Win 11. Sometimes the Ctrl-Alt-F hot key sequence calls the Delphi DebugFPUCommand, and other times it does what I want, calls the GExpertsToolsEditorExportCodeFormatter. What dictates which will be called and when?? Regards, Ian
  16. Ian Branch

    Ctrl-Alt-F sometimes doesn't

    GExperts 'IDE Menu Shortcuts' allowed me to remove the Delphi Ctrl-Alt-F function so only the GExperts Ctrl-Alt-F is valid now. All good.
  17. Ian Branch

    Change the order of loading??

    So. Also related to an earlier Ctrl-Alt-F issue.. GExperts 'IDE Menu Shortcuts' allowed me to remove the Delphi Ctrl-Alt-F function so only the GExperts Ctrl-Alt-F is valid now. All good.
  18. Ian Branch

    The Delphi 11.2 release thread

    Updated from 11.1 to 11.2 using the on-line installer. It deinstalled 11.1 OK but when it went to start to install 11.2 it kept falling over giving an error about loading Parnassus Bookmarks. I deleted the Bookmarks registry entry at Computer\HKEY_CURRENT_USER\Software\Embarcadero\BDS\22.0\Experts and the install worked. I reinstalled the GetIt stuff and am back in business. 🙂
  19. Ian Branch

    TTimer limit..

    OK. I have resolved this issue by hard coding an 8 hour time limit. The App is a Dashboard that is displayed on a screen at the start of the day. No user interaction required. At the start of the App I note the date/Time. There is a 60 second timer in the App doing something else. I put a test at the start of the Timer's event to test " if MinutesBetween(Now, dtStartDateTime) >= 480 then Close;" That should resolve what I believe is the underlying IdleTimer issue. The App resides on a Win 2012 Server. It is accessed and displayed in a Browser via the Web using Cybele's ThinFinity. I suspect that something in the Browser-ThinFinity-Server sequence is causing the App and therefore the IdleTimer to believe that something, either a keyboard or mouse, action has occurred, thus resetting the IdleTimer.
  20. Ian Branch

    TTimer limit..

    OK. Just to put your minds at ease. 1. I am getting too old for this stuff...... 2. The TTimer is only running to 60 secs, then it increments a minutes counter until the minutes counter reaches the Idle Minutes limit. So. It's not the timer, something else must be keeping the App 'Alive' even though the User isn't actually doing anything. Back to the drawing board.
  21. Ian Branch

    TTimer limit..

    OK. I have got myself confused here. 😞 8 hours = 480 minutes = 28,800 secs = 28,800,000 microsecs. (interval) Hmmm. Then the TTimer should be handling it correctly with a limit of 4,294,967,295. OK. I need to look elsewhere to find out why it isn't working at 8 hours. Thank you all for your contributions, Apologies for any inconvenience. Ian P.S. I just checked the actual in-App setting. Yes, I had 480 minutes.
  22. Ian Branch

    TTimer limit..

    So I was jus coming back to add that the TTimer is in an App Idle component. It is a slightly modified version of the unit in ccLib by David Cornelius on GitHub. It looks for keyboard and/or mouse activity and if it doesn't see any for the time out period, 8 hours (240min), then it closes the App.
  23. Ian Branch

    TTimer limit..

    Hi Mike, Thanks for the suggestion, I will see if that is practical. The TTimer functionality is within an Idle Timeout component, I don't really want to mess with the internals if I can avoid it. Ian
  24. Ian Branch

    Ctrl-Alt-F sometimes doesn't

    Thanks Thomas, Tried moving GExperts up the 'tree' didn't seem to change what I am experiencing. 😞 It does seem to be related to where the cursor is in the source code. For example, If I have the cursor in the Uses area it formats. If the cursor is in the Type area it pulls the Debug dialog. If I move the cursor down to support code/functions, it formats. If I move the cursor to the TMainForm.Function/Procedure code area, it pulls the Debug window. Sigh! 😉 Regards, Ian
  25. Ian Branch

    Application virtualization (RDP)

    No, sorry. My Customer uses a simple Win 2012 Server.
×