Saturday, July 25, 2009

ATFileNotification V1.1.4


ATFileNotification is a non-visual component, which allows to watch for files/directories changes and to fire an event when change occurs.
It is improved version of fisFileNotification component. Improvements are:

Component made Unicode compatible
FileName property added: you can watch for changes in a single file
Attempt to make component thread-safe (need feedback about it)

AutoCorrect Components v1.0

What does the code do exactly?

Implements for TCustomEdit and TCustomCombo descendents a large sub-set of the AutoCorrect functionality had by ‘proper’ word processors. Specifically, the following is implemented:

User-defined ‘replace text as you type’ entries, including formatted ones if the active control is a rich edit.
TWo INitial CApitals correction, with an exception list that is automatically added to when the user immediately undoes a correction.
Conversion of ’straight’ quotes into ‘curly’ (‘smart’) quotes.
Conversion of hyphens to dashes: two hyphens in a row (–) turn into an em-dash, a hyphen with a space either side ( – ) becomes an en-dash with a space either side.
Conversion of 1/2 to ½, 1/4 to ¼, and 3/4 to ¾.
Auto-indentation for rich edit controls — in other words, allows the user to set the active paragraph’s left- and first-indent properties by tabbing and backspacing.
How does it work?

In essence, the code works by trapping the KeyPress method (OnKeyPress event) of the active control, testing for a trigger key that will lead to correction testing proper kicking in. The initial trapping, however, is ‘manual’ in the sense that the TAutoCorrectEngine component does not actively ‘seek out’ key press events — it needs to be told about them.

What’s the quickest way to see it in action?

Download the code from here (EDN registration required — it’s free and relatively easy to do though), open up the ‘AutoCorrect demo and design-time package’ project group, and run the last project listed (AutoCorrectDemo.dpr). Since the TAutoCorrectEngine component is created at runtime for the demo, no installation is required.

How do I use the code myself?

Firstly, compile and install the design-time package, dclCCRAutoCorrect.dpk. This should lead to five new components being added to the component palette: TAutoCorrectEngine, TComboBoxWithAutoCorrect, TEditWithAutoCorrect, TMemoWithAutoCorrect and TRichEditWithAutoCorrect.
Ensure CCR.AutoCorrect.dcu and CCR.AutoCorrect.Consts.dcu end up somewhere in your library paths — the easiest way to do this is to add the component’s directory as a library path itself. In Delphi 2007, you do this by going to ToolsOptions, Environment Options -> Delphi Options -> Library – Win32, and clicking on the ellipsis button for ‘Library path’.
Create a new VCL forms application and add a TAutoCorrectEngine component to the main form; double click the component to add some custom ‘replace-as-you-type’ entries.
Add one or more TxxxWithAutoCorrect controls to the form, and assign their AutoCorrectEngine property to the TAutoCorrectEngine component.
Compile and run.
But I don’t want to use your custom descendants of TEdit, TRichEdit, etc.!

No problem — you’ll just have to do a bit of manual work, calling as appropriate the KeyDownOccurred, KeyPressOccurred and UndoOccurred methods of the TAutoCorrectEngine component. The last of these is best done by defining an undo action (i.e., a TAction with Ctrl+Z as its shortcut), UndoOccurred being called immediately after the undo operation is performed. As for the other two, you can either handle the OnKeyXXX events of the controls themselves or (if you set KeyPreview to True) the parent form — in the second case, pass ActiveControl as the first parameter to KeyXXXOccurred. See the main demo for an example of all this — the process is simpler than it may sound.

The small print

Target Delphi versions: separate versions for Delphi 7 on the one hand, and Delphi 2006 or greater on the other, are included in the ZIP — both versions’ functionality and implementation are almost identical however.

Turbo Delphi Explorer compatibility: since you don’t need to install TAutoCorrectEngine to actually use it, and adding custom entries at runtime is pretty easy. Check out the main demo, which doesn’t use a design-time instance of the component and so can be open and run from inside the Turbo Delphi IDE.

Rich edit bugs: note that the TRichEditWithAutoCorrect class works around bugs in the underlying DLL the VCL’s TCustomRichEdit wraps. Specifically, v1 of the DLL (used until Delphi 2009) uncurls smart quotes when they are streamed or pasted in, and v1 to v3 of the DLL don’t load en- and em-dashes correctly, loading them as hyphens.

Saturday, May 23, 2009

We have huge amounts of memory and concurrent programming is an exception

It's quite amazing to hear Anders advocating bloat in a world where most of the world still has bad internet connections and hate large downloads, mobile phones prefer 1MB applications over 10MB apps, where RAM can be a bottleneck, where battery life is always too short and where many large organizations struggle with bad performance.

I recently had the chance to see the standard configuration for virtual servers in a large organization. In order to improve network traffic, the standard network adapter is limited to 10Mbit/sec.

Add-in Express 2009 for Office and VCL

Visual designers and components of Add-in Express in combination with a perfect Delphi compiler provide you with the best platform for Office development. Add-in Express makes it equally easy to build toolbars, menus and sub-menus for Microsoft Office 2000 – 2003, customize the Office 2007 Ribbon using the Office 2007 Ribbon designer as well as to create custom static and contextual ribbon tabs, task panes, navigation pane and reading pane, Office Menu and Quick Access Toolbar.

Add-in Express for Delphi implements all interfaces and techniques required by supported technologies, you write functional code only. Another key benefit of Add-in Express is version neutrality – you write the plug-in code once and get a secure Microsoft Office extension that works for all applications and versions.

Plug-in types: COM add-ins, smart tags, real-time data servers
Office versions: Office 2000, 2002, 2003, 2007
Applications: Outlook, Word, Excel, PowerPoint, Access, Publisher, Project, MapPoint, InfoPath, Visio
IDEs: Delphi 5, 6, 7, 2006, 2007, 2009
Windows Vista ready

Wednesday, May 20, 2009

DataSnap the fastest multi-tier development

The new approach was introduced with RAD Studio 2009 (including Delphi & C++Builder) and was based on a NON-COM/DCOM approach. The new approach used JSON (JavaScript Object Notation) http://www.json.org/ housed on a TCP/IP message layer wrapped in the DataSnap technology.

What makes this approach great is that it is simple to implement:


  1. Create a DataSnap Server

    1. Create a VCL Form application

    2. Add the 3 DataSnap Server components

    3. Connect the Server components

    4. Add a ServerModule (this is where the developer exposes business logic and data from the backend storage)

    5. Connect the ServerModule to the Server components for the wire protocol and transfer of information

  2. Create a client (generic client)

    1. Create a VCL form application, Web application, ASP.NET (Prism) application

    2. Drop a TSQLConnection component

    3. Set the connection properties (3 in all)

    4. Right-mouse click on the TSQLConnection and generate Client Proxy

    5. Use Proxy to connect to the remote server and call logic at will

    6. Expose information on client

  3. Done

This is a nine minute demo with explanations, 5 without… at best and IMO, it is the fastest multi-tier approach out there compared to JEE, CORBA, RMI, COM/DCOM, or plain old RPC.


This approach isolates the database layer to the middle tier; there is no reason for the client to know that you are even connecting to a backend database. The exposure of business logic is as simple as writing public functions and the building of the actual server is a form and three (3) components. There are no 7 helper files like with Java’s EJB, or 3 helper files with CORBA, or IDL/RIDL with COM/DCOM, and you surely don’t have to define each side of the communication like with RPC.


So there must be a downside to the technology… there always is… isn’t there? As far as I can see today, there are no advert downsides. There is no royalty to use it, it is simple to understand, it helps to reduce database connections, it very fast, it scales well, and it uses open protocols. What is not to like?


Now could there be more features added or could it even become simpler to use in future releases of the feature/functionality? Sure, but then again, if you are a diehard Delphi/C++Builder developer you already know that we don’t rest on the past implementation we are always trying to push the technology to the next level.


This leads to the next item; I’m going to be publishing the roadmap for RAD Studio very soon and also an audio recording of the presentation. There will be more details about where the technology of DataSnap is going in the future and should give every Delphi/C++Builder/Prism developer some great piece of mind to see the investment being put into our beloved product with Embarcadero!