Synopse Open Source - Tag - TaskDialogmORMot MVC / SOA / ORM and friends2024-02-02T17:08:25+00:00urn:md5:cc547126eb580a9adbec2349d7c65274DotclearSynTaskDialog.pas version for Lazarusurn:md5:8be4f490f9315ca9a52060993ce7da0c2015-03-09T12:19:00+01:002015-03-09T12:21:06+01:00AB4327-GANDIOpen Source librariesblogCrossPlatformDelphiFreePascalLazarusLCLLinuxMaxOSXTaskDialog <p>Just to share a commit of some interest to FPC/Lazarus users.</p>
<p>Ondrej Pokorny (aka "reddwarf" in our forums) did send to us a nice
implementation of our <code>SynTaskDialog.pas</code> unit, compatible with
Lazarus.</p>
<p>Since it is incompatible with the current state of the other <em>mORMot</em>
UI units (which are still VCL-based), we have included the source in the
<a href="https://github.com/synopse/mORMot/tree/master/SQLite3/Samples/ThirdPartyDemos/Ondrej/SynTaskDialog4Lazarus">
Third Party subfolder</a> of our source code repository.<br />
Direct link is <a href="https://github.com/synopse/mORMot/tree/master/SQLite3/Samples/ThirdPartyDemos/Ondrej/SynTaskDialog4Lazarus">https://github.com/.../SynTaskDialog4Lazarus</a></p>
<p>Resulting unit is cross-platform, as stated by the following
screenshots:</p>
<p><a href="https://blog.synopse.info?post/public/ScreenShots/SynTaskDialogMacOSX.png"><img src="https://blog.synopse.info?post/public/ScreenShots/.SynTaskDialogMacOSX_m.jpg" alt="" title="SynTaskDialog for Lazarus on Mac OSX, Mar 2015" /></a></p>
<p><a href="https://blog.synopse.info?post/public/ScreenShots/SynTaskDialogLinux.png"><img src="https://blog.synopse.info?post/public/ScreenShots/.SynTaskDialogLinux_m.jpg" alt="" title="SynTaskDialog for Lazarus on Linux, Mar 2015" /></a></p>
<p>Feedback is <a href="http://synopse.info/forum/viewtopic.php?id=2410">welcome on our forum, as
usual</a>.</p>64 bit compatibility of mORMot unitsurn:md5:9d1ba8b507caed3b92b88cf852a20b2e2013-03-07T17:19:00+01:002013-03-23T10:10:42+01:00AB4327-GANDImORMot Framework64bitasmblogDatabaseDelphifactoryhttp.sysi18ninterfaceJSONMetaDatamockmORMotobjectORMParsingPDFRestRTTIsessionSOASourceSQLSQLite3stubSynDBTaskDialogTestingUnicodeUserInterfaceVirtualTableWCFweak pointers<p>I'm happy to announce that <em>mORMot</em> units are now <a href="http://synopse.info/fossil/info/fb893df6fe">compiling and working great in 64
bit mode</a>, under Windows.<br />
Need a Delphi XE2/XE3 compiler, of course!</p>
<p><img src="http://3.bp.blogspot.com/_FUNuXxCxZA8/SqFBDD93GVI/AAAAAAAABIs/-M7J7YivsPM/s400/Marmot.JPG" alt="" /></p>
<p>ORM and services are now available in <em>Win64</em>, on both client and
server sides.<br />
Low-level <em>x64</em> assembler stubs have been created, tested and
optimized.<br />
UI part is also available... that is grid display, reporting (with <em>pdf</em>
export and display anti-aliasing), ribbon auto-generation,
<code>SynTaskDialog</code>, i18n... the main <em>SynFile</em> demo just works
great!</p>
<p>Overall impression is very positive, and speed is comparable to 32 bit
version (only 10-15% slower).</p>
<p>Speed decrease seems to be mostly due to doubled pointer size, and some less
optimized part of the official Delphi RTL.<br />
But since <em>mORMot</em> core uses its own set of functions (e.g. for
JSON serialization, RTTI support or interface calls or stubbing), we were able
to release the whole 64 bit power of your hardware.</p>
<p>Delphi 64 bit compiler sounds stable and efficient. Even when working at low
level, with assembler stubs.<br />
Generated code sounds more optimized than the one emitted by
<em>FreePascalCompiler</em> - and RTL is very close to 32 bit mode.<br />
Overall, VCL conversion worked as easily than a simple re-build.<br />
Embarcadero's people did a great job for VCL <em>Win64</em> support, here!</p> <p><em>SQlite3</em> works great in 64 bit mode.</p>
<p>You can find our own 3.7.16 version of the <em>SQlite3</em> external
library, to be used in 64 bit mode, from <a href="http://synopse.info/files/SQLite3-64.7z">SQLite3-64.7z</a>, since there is no
official <em>Win64</em> library released yet in <a href="http://sqlite.org">http://sqlite.org</a><br />
No problem so far, and pretty good performance.<br />
Jut a weird bug about <code>SQLITE_TRANSIENT</code> constant, which should be
<code>pointer(integer(-1))</code> instead of <code>pointer(-1)</code> when
working with virtual tables columns - but nothing to care of in your user code,
since the framework will handle it for you.</p>
<p>I suspect some part of official <code>System.RTTI.pas</code> unit as
provided in XE2/XE3 is broken in <em>Win64</em>.<br />
For instance, I think it does not handle a method returning a string.<br />
Our <code>mORMot.pas</code> implementation has been tested with the same
regression code as in 32 bit mode.</p>
<p>Your own tests and feedback are welcome!<br />
Feedback and detailed tests results are <a href="http://synopse.info/forum/viewtopic.php?id=1153">available in our
forum</a>!</p>Open Source SynTaskDialog unit for XP,Vista,Sevenurn:md5:c6110bd5d1356274b8d3591e18ee42c92011-03-05T09:20:00+01:002011-03-08T21:56:03+01:00AB4327-GANDIOpen Source librariesblogDelphiTaskDialogUnicodeUserInterface<p>A task dialog is a dialog box that can be used to display information and
receive simple input from the user. Like a message box, it is formatted by the
operating system according to parameters you set. However, a task dialog has
many more features than a message box.</p>
<p>Windows provides a generic task dialog available since Vista/Seven. But
there is none available with previous versions of Windows, i.e. Windows XP or
2K.</p>
<p>This unit (licensed under a MPL/GPL/LGPL tri-license) will use the new
TaskDialog API under Vista/Seven, and emulate it with pure Delphi code and
standard themed VCL components under XP or 2K. It will compile from Delphi
6 up to XE, and is Unicode ready.</p> <h4>The SynTaskDialog unit</h4>
<p>Our task dialog is mainly implemented in the TTaskDialog record/object type
and methods.</p>
<p>The emulation code is very simple, and only uses standard VCL components.
With the theming enabled (don't forget to add XPMan as one of your units, or
set our {$R Vista.res} resource), it renders very nicely under XP.</p>
<p>Our task dialog has some additional features, which are not available by
default in the Vista/Seven TaskDialog: we have direct field edition or
selection (using a TEdit or a TComboBox), without any difficult callback system
to implement. Just fill the Selection property, or set the new tdfQuery flag to
enable those features (see sample code below).</p>
<p>In order to use it, create a TTaskDialog object/record on the stack. The
Delphi compiler will initialize all its string parameters to '' (it's a SHAME
that since Delphi 2009, objects are not initialized any more: we have to define
this type as object before Delphi 2009, and as record starting with Delphi
2009).</p>
<p>Then set the appropriate string parameters, and call Execute() with all
additional parameters.</p>
<p>After execution, RadioRes/SelectionRes/VerifyChecked can be used to reflect
the diverse results states.</p>
<p>See the comments in the unit souce code about all available properties and
parameters.</p>
<h4>Hello world</h4>
<p>Here is a typical usage:</p>
<pre>
<code>var Task: TTaskDialog;
begin
Task.Inst := 'Saving application settings';
Task.Content := 'This is the content';
Task.Radios := 'Store settings in registry'#10'Store settings in XML file';
Task.Verify := 'Do no ask for this setting next time';
Task.VerifyChecked := true;
Task.Footer := 'XML file is perhaps a better choice';
Task.Execute([],0,[],tiQuestion,tfiInformation,200);
ShowMessage(IntToStr(Task.RadioRes)); // 200=Registry, 201=XML
if Task.VerifyChecked then
ShowMessage(Task.Verify);
end;
</code>
</pre>
<p>Note that you don't need to put a Create/Free and a try..finally block to
protect the TTaskDialog instance. The Delphi compiler will do all the work for
us.</p>
<p>Here is the result under a Windows Seven 64 bit computer:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog01.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog01.png, mar. 2011" />And here is the same dialog created from
our Emulated pure Delphi code:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog02.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog02.png, mar. 2011" /></p>
<p>Here is a selection task dialog, with "Command links" buttons, in native
Seven:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog03.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog03.png, mar. 2011" />And here is the window as created with
the VCL emulation code:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog04.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog04.png, mar. 2011" /><br />
Note that we use plain TBitBtn components here, so the rendering is a bit
diverse. But the User Experience won't change much from a Native dialog...</p>
<p>After having selected the 2nd command link button, i.e. with an ID of 101,
we display a simple ShowMessage like dialog under Seven:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog05.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog05.png, mar. 2011" />And here is the emulated version:</p>
<p><img src="https://blog.synopse.info?post/public/TaskDialog06.png" alt="" style="margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto; display: block;" title="TaskDialog06.png, mar. 2011" /></p>
<h4>How to replace the VCL Dialogs unit functions</h4>
<p>Here is some source code which may help you use the new task dialog instead
of the VCL Dialogs unit:</p>
<pre>
<code>procedure ShowMessage(const Msg, Inst: string; Error: boolean=false);
const
IconError: array[boolean] of TTaskDialogIcon = (tiInformation, tiError);
var Task: TTaskDialog;
begin
Task.Inst := Inst;
Task.Content := Msg;
Task.Execute([cbOK],mrOk,[],IconError[Error]);
end;</code>
</pre>
<pre>
<code>function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
var Task: TTaskDialog;
begin
Task.Inst := ACaption;
Task.Content := APrompt;
Task.Query := Value;
result := Task.Execute([cbOk,cbCancel],0,[tdfQuery],tiQuestion)=mrOk;
if result then
Value := Task.Query;
end;</code>
</pre>
<pre>
<code>function InputSelect(const ACaption, APrompt, AItemsText, ASelectedText: string): integer;
var Task: TTaskDialog;
begin
result := -1;
if AItemsText='' then
exit;
Task.Inst := ACaption;
Task.Content := APrompt;
Task.Selection := AItemsText;
Task.Query := ASelectedText;
if Task.Execute([cbOk,cbCancel],0,[],tiQuestion)=mrOk then
result := Task.SelectionRes;
end;
</code>
</pre>
<p>I think we have here the simpliest Task Dialog unit available for Delphi,
all for free!<br />
:)</p>
<h4>Reference material</h4>
<p>Check the <a href="http://msdn.microsoft.com/en-us/library/bb760441(v=VS.85).aspx">general
presentation about the TaskDialog</a>, from the Microsoft POV.</p>
<p>Here can be found the details <a href="http://msdn.microsoft.com/en-us/library/bb760544(v=VS.85).aspx">about the
Microsoft implementation API</a> used in this unit.</p>
<h4>One step further</h4>
<p>This unit was developped for the User Interface of our SQlite3 Framework,
which is an Open Source ORM framework, based on a multi-tier architecture and a
RESTful approach.</p>
<p>E.g. in the SQLite3UILogin unit, you'll find additional functions and usage
of this unit. See also the sample application available in the "Samples\08 -
TaskDialog" folder.</p>
<h4>Forum and technical support</h4>
<p>Additional information, and support is <a href="http://synopse.info/forum/viewtopic.php?id=253">available from our web
site</a>.</p>
The unit is available to download from <a href="http://synopse.info/files/SynTaskDialog.zip">this direct link</a>.
<p>If you find any bug, or need some enhancements, feel free to contribute to
this project. Enter the Open Source zone!</p>