<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[My Visual Database — [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
		<link>https://myvisualdatabase.com/forum/viewtopic.php?id=7977</link>
		<atom:link href="https://myvisualdatabase.com/forum/extern.php?action=feed&amp;tid=7977&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed.]]></description>
		<lastBuildDate>Mon, 31 Jan 2022 13:32:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43836#p43836</link>
			<description><![CDATA[<p>Hi sparrow,</p><p>I haven&#039;t been able to experiment with it yet, but it looks like that covers both of my questions.</p><p>Thank you for sharing that site.</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Mon, 31 Jan 2022 13:32:53 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43836#p43836</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43824#p43824</link>
			<description><![CDATA[<p>--- POST edited ----<br />You can use MessageBox... (<a href="https://delphiexample.at.ua/publ/metod_messagebox/1-1-0-27">https://delphiexample.at.ua/publ/metod_ … x/1-1-0-27</a>) - rus<br /></p><div class="codebox"><pre><code>procedure Form2Cl (Sender: TObject; Action: TCloseAction);
begin
    if ((ff01 &lt;&gt; Form2.tbName.sqlValue) OR
    (ff02 &lt;&gt; Form2.dtpDate.sqlDate)) AND NOT (Form2.btnSave.Focused) then

       if MessageBox(&#039;YOUR MESSAGE&#039;,&#039;YOUR LABEL&#039;,MB_OKCANCEL + MB_ICONQUESTION + MB_DEFBUTTON2) =  IDCANCEL then Action := caNone;

end;</code></pre></div><p>if you use this code X dont work, becouse no button Cancel<br /></p><div class="codebox"><pre><code>procedure Form2Cl (Sender: TObject; Action: TCloseAction);
begin
    // Check for changes
    if ((ff01 &lt;&gt; Form2.tbName.sqlValue) OR
    (ff02 &lt;&gt; Form2.dtpDate.sqlDate)) AND NOT (Form2.btnSave.Focused) then

       if MessageBox(&#039;YOUR MESSAGE&#039;,&#039;YOUR LABEL&#039;,MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) =  IDNO then Action := caNone;
end;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (sparrow)]]></author>
			<pubDate>Sun, 30 Jan 2022 11:37:11 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43824#p43824</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43820#p43820</link>
			<description><![CDATA[<p>Hello again,</p><p>I have a few other related questions to add for this thread...</p><br /><p>1. Is it possible to disable the close button on the MessageDlg() window?&nbsp; And if not, is it possible to set which button to used as the default (for when the dialog is closed in this way)?</p><br /><p>For example:</p><p>I noticed that MVD has a confirmation dialog whenever you Clear a file from an DBFile component.&nbsp; And it will not allow the user to close that dialog without clicking one of the buttons.</p><p>Using the MessageDlg(), the user can still close the dialog without clicking one of the buttons which disrupts the script that was provided as a solution in this thread.</p><p>If it&#039;s not possible to disable the close button, is there a way to set or capture a default action when the dialog is closed?&nbsp; Anyone have any ideas for how to handle this?</p><br /><p>2. Does anyone know of a DialogType parameter for the MessageDlg() to show the question mark similar to the one used in the MVD dialog mentioned above?</p><p>The only list mentioned in <a href="http://myvisualdatabase.com/forum/viewtopic.php?id=1272">this thread</a> that I was able to find was from back in 2015.&nbsp; Is there one available now?</p><p>According to the <a href="http://www.delphibasics.co.uk/RTL.asp?Name=MessageDlg">Delphi Basics reference</a>, the mtConfirmation &quot;Displays an question mark&quot;.&nbsp; But, this isn&#039;t the case for MVD.&nbsp; Does anyone know of one for this?</p><p>---</p><p>I have a screenshot to illustrate my questions...</p><p>Thank you for any feedback!</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Sun, 30 Jan 2022 01:50:55 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43820#p43820</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43812#p43812</link>
			<description><![CDATA[<p>Hi derek,<br />.<br />I&#039;m starting to get the idea, and I appreciate the extra explanation.&nbsp; I&#039;ve seen that structure used in threads about customizing menus, but it was all new to me.&nbsp; I wanted to ask about it here since this was a little more simple use.<br />.<br />Thank you both again.</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Wed, 26 Jan 2022 13:09:47 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43812#p43812</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43810#p43810</link>
			<description><![CDATA[<p>Hi Joshua, Hi Sparrow,<br />Not quite - the &#039;@&#039; isn&#039;t required when you use your own procedures;&nbsp; however, the &#039;@&#039; IS required as a prefix when using one of your own written procedure as a <strong>replacement</strong> for the standard one associated with a particular action (such as &#039;formclose&#039; or selecting a menu options).<br />Have a look at the attached simple example which replaces the existing &#039;about&#039; option with your own procedure (&#039;aboutme&#039;).&nbsp; <br />Note how it can be called in 2 different ways.<br />1.&nbsp; from a normal button so can be referenced directly as &#039;aboutme&#039; with no need for &#039;@&#039;.<br />2.&nbsp; as a replacement for the pre-existing MVD menu option and so has to be referenced as &#039;@aboutme&#039;.<br />Hope that clarifies rather than confuses matters!<br />Derek.</p>]]></description>
			<author><![CDATA[null@example.com (derek)]]></author>
			<pubDate>Wed, 26 Jan 2022 00:17:36 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43810#p43810</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43809#p43809</link>
			<description><![CDATA[<p>Brilliant!<br />.<br />Precisely what I was after... even though I don&#039;t fully understand it.&nbsp; I&#039;m guessing that&#039;s just the syntax for calling a custom function/procedure.<br />.<br />Many thanks!</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Tue, 25 Jan 2022 22:19:07 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43809#p43809</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43808#p43808</link>
			<description><![CDATA[<p>yes</p><p>and your prog with X</p>]]></description>
			<author><![CDATA[null@example.com (sparrow)]]></author>
			<pubDate>Tue, 25 Jan 2022 21:28:11 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43808#p43808</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43805#p43805</link>
			<description><![CDATA[<p>Also sparrow... since you contributed the first solution in that thread I referenced, would you mind further explaining or giving me somewhere else to look so I can learn what you&#039;re doing in that statement:<br />.<br /></p><div class="codebox"><pre><code>Form1.OnClose := @frm1oncl;</code></pre></div><p>.<br />What is the @ symbol doing there?&nbsp; This is over my head, and I&#039;m curious to learn it.<br />.<br />On first glance, it seems like it may be creating an instance of the function or something..?</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Tue, 25 Jan 2022 20:36:21 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43805#p43805</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43804#p43804</link>
			<description><![CDATA[<p>Hi sparrow,<br />.<br />Okay, that&#039;s another option I didn&#039;t think of... haha!<br />.<br />Thank you for contributing my friend.</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Tue, 25 Jan 2022 20:25:26 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43804#p43804</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43803#p43803</link>
			<description><![CDATA[<p>Hi,<br />For verification, you can use the Form2_btnClose_OnClick event and not display the X button.</p>]]></description>
			<author><![CDATA[null@example.com (sparrow)]]></author>
			<pubDate>Tue, 25 Jan 2022 19:47:01 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43803#p43803</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Prompt User Before Closing Form(s) When Fields Have Changed]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=43802#p43802</link>
			<description><![CDATA[<p>Hi Folks!<br />.<br />I could use some help here, and I hope the topic is self-explanitory.<br />.<br />I&#039;m not able to troubleshoot this because I don&#039;t fully understand what&#039;s going on in this line:<br />.<br /></p><div class="codebox"><pre><code>Form2.OnClose := @Form2_OnClose;</code></pre></div><p>.<br />I&#039;ve attached a sample project for demonstration...<br />.<br />There are currently two unsolved issues:<br />.<br />1. When the user changes a field, and then reverts the field back to the original content, the confirmation does not show AND the form will not close (or respond) either.<br />.<br />2. The confirmation is showing even when the user clicks the save button.<br />.<br />Originally I was using the Close button&#039;s On_Click event to handle this.&nbsp; Then I noticed the user could simply click the window&#039;s X (close) button without any confirmation.&nbsp; So then I found <a href="http://myvisualdatabase.com/forum/viewtopic.php?id=7675">this thread</a> that would handle that, but I can&#039;t get it working properly.<br />.<br />At this point, I&#039;m almost ready to just settle with the first approach.&nbsp; I would appreciate any advice and/or suggestions.</p>]]></description>
			<author><![CDATA[null@example.com (joshuA)]]></author>
			<pubDate>Tue, 25 Jan 2022 17:26:04 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=43802#p43802</guid>
		</item>
	</channel>
</rss>
