* * *

Author Topic: Windows - Application won't come out of the background  (Read 1471 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 4233
Re: Windows - Application won't come out of the background
« Reply #15 on: August 08, 2017, 03:08:12 pm »
If you don't save you will loose your work... that has nothing to do with "Application.Terminate", if you use "Close" you loose it too...
Yes, but that's a completely different subject....Handle OnClose. Terminate skips OnClose AND onCloseQuery, as I demonstrate.
Quote
...and I can outsmart almost everyone (by accident?  ;D O:-)).
Quote
You are confusing outsmart with exactness !!!
As I said before I stick to my example... that's it...
Application.terminate is don't use.... But anyway... did you actually run my application a few times? NO! It is not exact, it is exactly the opposite... of exact... D*mb* Application.terminate kills your data (as my example shows too, try kill). Fine with me, as long as I am not your customer....<this is not grumpy it is a reaction to sheer stupidity  >:( >:( >:( >:( >:D >:DO:-)
Some others (no noobs or average, plz, don't mingle) must knock some sense into you, I am not the violent type.. 8-) O:-) :'(

- try just save after change, then exit. No data loss
- try mod and then exit... (two options, test them both), no data loss in either case...
- try kill menu option (YOURS.. >:() : you WILL loose your data... And that happens to be the one that is your favorite. Slap on hand. With stick.
Now, get the point? First lesson in software design (can be improved in further lessons)
« Last Edit: August 08, 2017, 04:35:03 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

RAW

  • Sr. Member
  • ****
  • Posts: 411
Re: Windows - Application won't come out of the background
« Reply #16 on: August 08, 2017, 06:01:58 pm »
OK, let's have a look:
Quote
// CanClose := true; ?????????????????? What is this ????
  if Memo1.Modified then
    if Application.MessageBox('Do you want to save your work?','Text is modified',MB_YESNO) = idYes then
      CanClose := DoSave;
This is nice, would save me one boolean var and works nice...

DoSave is working but without TFileStream it's not good enough... anyway that's another topic... take a look at TFileStream !  :P

Code: Pascal  [Select]
  1. Application.MainForm.Close;
This is not working with my example !!!!
OK, maybe it's better to repeat this just in case you haven't noticed that...

THIS DOESN'T WORK WITH MY EXAMPLE !!!!
THIS DOESN'T WORK WITH MY EXAMPLE !!!!
THIS DOESN'T WORK WITH MY EXAMPLE !!!!
THIS DOESN'T WORK WITH MY EXAMPLE !!!!


What should I say: It's not your fault you are from HOLLAND... so it's not your fault... take your time and read this in peace and quiet without disturbances.
One day you'll understand it... yeah... maybe ...  :P :P :P :P :P :P :D :D :D :D :D :D :D :D

As I said ... it's just not your fault.... can happen...

EDIT:
btw:
Quote
And that happens to be the one that is your favorite. Slap on hand. With stick.
Quote
// SAVE whatever you have to save...
// FREE whatever you have to free...
Application.Terminate;
My favorite way is always safe (saved...)... yeah... just put your glasses on and use your hearing devices...
« Last Edit: August 08, 2017, 07:10:42 pm by RAW »
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.6.4 FPC 3.0.2

Thaddy

  • Hero Member
  • *****
  • Posts: 4233
Re: Windows - Application won't come out of the background
« Reply #17 on: August 08, 2017, 09:41:36 pm »
@RAW

Well, I let this open for review.
- You added code
- I added code. And a full project..

Don't be disappointed if I win..... I demonstrated the stupidity (the Kill menu item), you merely demonstrated a useless call to something that was happening anyway..... >:D
And kills safe programming....

Eloquent! (not silly) readers, please review the code... O:-) O:-) O:-) O:-) 8-) 8-) 8-) 8-) 8-)
As an EXAMPLE of how to properly close a program as lesson 1. Nothing more....
Quote
My favorite way is always safe (saved...)... yeah... just put your glasses on and use your hearing devices...
BTW: always saving may be against the users wishes??? Just the next  mistake you made...

One of the moderators should split this discussion off...Note it is relevant, but has no longer to do with the original question.
That was already answered. But this is about proper design.
« Last Edit: August 08, 2017, 09:55:38 pm by Thaddy »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Thaddy

  • Hero Member
  • *****
  • Posts: 4233
Re: Windows - Application won't come out of the background
« Reply #18 on: August 08, 2017, 10:02:08 pm »
I am also sure both RAW and me can take a bit of shouting.... ;D So don't worry... 8-) Both fun and educational. (the latter part I will do).
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

GetMem

  • Hero Member
  • *****
  • Posts: 2209
Re: Windows - Application won't come out of the background
« Reply #19 on: August 08, 2017, 10:17:21 pm »
@Thaddy, @RAW
I was dying after I read this. In the end, all I could think was: damn these guys need to get outside.  :D

RAW

  • Sr. Member
  • ****
  • Posts: 411
Re: Windows - Application won't come out of the background
« Reply #20 on: August 09, 2017, 02:09:52 am »
 :D hmmm, outside... I can do "outside" very well (2 or 5 seconds.. done).... but I don't like "outside" very much... in addition it wouldn't help against the hardheaded way of thinking of this du(t)chess...
And it was maybe a good thing to reconsider my OnCloseQuery-behaviour...

That has of course nothing to do with the necessity of App-Terminate in my example...  :P
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.6.4 FPC 3.0.2

technipixel

  • Sr. Member
  • ****
  • Posts: 351
    • TechniPixel Solutions
Re: Windows - Application won't come out of the background
« Reply #21 on: August 09, 2017, 04:04:20 am »
LOL.... you guys are hilarious! 8)

In VB6,VB.NET "KILL" is very similar to "KILL PROCESS", like on Windows...
It wipes out the app regardless of data state.

I have always made a habit of NOT USING Kill (Terminate in LAZ) in any apps whether VB or LAZ

I prefer the CloseQuery because it's best to check your data before closing.
Of course if your app has no data to check.... then that is another story.... use it if you want too.

I think "Terminate" (Kill) only necessary in extreme cases where you need to kill the app completely - instantly

:-X
Even so, I still prefer the Close method
And if I use "Exit" menu, I just begin the close query anyways similar to how both of you do it.

Not taking sides...  :P
Just expressing my preference.

I love learning from you knowledgeable guys. And watching you spar is great!
Keep it up... a lot of us newbies enjoy it!
 ;D
Lazarus 1.6 w/FPC-3.0 • Windows 7 • 10G RAM • NIV-GForce GT 640 Graphics Card
Newbie coming from VB6, VBA, .NET (C# & VB)
Other languages: sql, php, html, CSS, javascript, actionscript.

SymbolicFrank

  • Sr. Member
  • ****
  • Posts: 291
Re: Windows - Application won't come out of the background
« Reply #22 on: August 09, 2017, 09:10:22 am »
I have had managers which insisted that I crashed my application with a stack dump the moment I encountered something that was not exactly as expected. Like a substring function that gets parameters that fall outside the boundaries of the string. Stack dump! Terminate!

RAW

  • Sr. Member
  • ****
  • Posts: 411
Re: Windows - Application won't come out of the background
« Reply #23 on: August 09, 2017, 02:42:29 pm »
Application.Terminate is definitely not a KILL.
It frees all my forms and all my components very well, so in my eyes it's far away from a KILL even if TERMINATE sounds a lot like ARNOLD SCHWARZENEGGER...

Terminate <> immediately !!!

Application.Terminate <> TerminateProcess !!!

Even HALT() does a little bit of cleanup...

Take a look at Application.MainForm.Close and see what happens there...  :)

Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.6.4 FPC 3.0.2

technipixel

  • Sr. Member
  • ****
  • Posts: 351
    • TechniPixel Solutions
Re: Windows - Application won't come out of the background
« Reply #24 on: August 09, 2017, 06:48:04 pm »
Application.Terminate is definitely not a KILL.
It frees all my forms and all my components very well, so in my eyes it's far away from a KILL even if TERMINATE sounds a lot like ARNOLD SCHWARZENEGGER...

Terminate <> immediately !!!

Application.Terminate <> TerminateProcess !!!

Even HALT() does a little bit of cleanup...

Take a look at Application.MainForm.Close and see what happens there...  :)

Agreed... I guess I didn't explain it enough.
I was more or less just saying it doesn't use CloseQuery from what I understand
Lazarus 1.6 w/FPC-3.0 • Windows 7 • 10G RAM • NIV-GForce GT 640 Graphics Card
Newbie coming from VB6, VBA, .NET (C# & VB)
Other languages: sql, php, html, CSS, javascript, actionscript.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus