tag:blogger.com,1999:blog-57414552024-03-08T07:52:38.330+13:00Idle Musings of a Delphi JunkieWelcome to the Blog of David Clegg. I am a hard-core Delphi fan, so most of my posts will probably reflect this.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.comBlogger74125tag:blogger.com,1999:blog-5741455.post-49052810668779072502007-09-14T16:22:00.000+12:002007-09-14T16:27:00.732+12:00Time to shut up shopThis will be my last post on this blog, as I've moved my meager blogging exploits to a <a href="http://blogs.codegear.com/dclegg">new home</a>. Feel free to mosey on over there for a full explanation. :-)Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com1tag:blogger.com,1999:blog-5741455.post-31145861726577016302007-08-23T12:41:00.000+12:002007-08-23T14:41:32.205+12:00Using VCL.NET with ECO IV in CodeGear RAD StudioAs part of the Highlander Beta Blogging initiative, I have been given permission from <a href="www.codegear.com">CodeGear</a> to demonstrate features and functionality of the up and coming <a href="www.codegear.com">CodeGear</a> RAD Studio product.<br /><br />As <a href="www.codegear.com">CodeGear</a> are also currently running a <a href="http://dn.codegear.com/article/36783">video competition</a>, I thought I'd use this unfair advantage to enter :-)<br /><br />The following two videos (they were one, but had to be split in order to comply with YouTubes 10 minute limit) demonstrate a simple Master Detail application created in <a href="http://www.capableobjects.com/products/ecoiv">ECO</a> using VCL.NET as the presentation framework. In the first video, the data is persisted to an XML file.<br /><br /><object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/7gL2EpmVquw"> </param> <embed src="http://www.youtube.com/v/7gL2EpmVquw" type="application/x-shockwave-flash" width="425" height="350"> </embed> </object><br /><br />The second video extends upon this to change the persistence to write the data in a BlackfishSQL database.<br /><br /><object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/0uODVLgOMq8"> </param> <embed src="http://www.youtube.com/v/0uODVLgOMq8" type="application/x-shockwave-flash" width="425" height="350"> </embed> </object><br /><br />I strongly encourage all readers/viewers to favour these videos. I can't guarantee any fame or fortune to come your way, but I will be sure to have a beer in your honour. Heck, if you ever get over to New Zealand, I may even be convinced to shout you one. :-)<br /><br />UPDATE: I have uploaded the original video to <a href="http://dn.codegear.com/article/36846">CodeGear Developer Network</a>. I would recommend watching this one rather than the two I submitted to YouTube. The content is the same, but there is no loss in resolution. Feel free to still vote for my YouTube submissions though. :-)Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com3tag:blogger.com,1999:blog-5741455.post-76560012671867048472007-07-12T16:49:00.002+12:002007-07-12T16:55:18.881+12:00A couple of YouTube funnies<ul><br /><li>If you're feeling thirsty, <a href="http://www.youtube.com/watch?v=qg1ckCkm8YI">Apple juice</a> is pretty good for you.</li><br /><li>Those <a href="http://www.youtube.com/watch?v=Xs3SfNANtig">wacky Trojans</a> are at it again.</li><br /></ul>Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-81801048626791784592007-06-27T09:06:00.000+12:002007-06-27T09:21:36.558+12:00Everybodys Free (to write software)I've decided to take the <a href="http://www.stevetrefethen.com/blog/DelphiVCLWisdom.aspx">challenge</a> issued by Steve Trefethan, and have extended his excellent list with my take:<br /><ul><br /><li>Learn to populate your user interface from the database without using TDataSet/TDataSource</li><br /><li>Learn to leverage the power of the Refactoring menu</li><br /><li>Learn how to write and leverage effective unit tests</li><br /><li>Write a Delphi for .NET application. You won't get cooties, I promise</li><br /><li>Write an ECO application</li><br /><li>Learn how to leverage interfaces to add runtime discoverable behaviours to classes</li><br /><li>Write an article and submit it to <a href="http://dn.codegear.com">Codegear Developer Network</a></li><br /><li>Learn another language. You will become a stronger Delphi developer for your efforts</li><br /><li>Point your local school or college to the <a href="http://www.turboexplorer.com/">Turbo Explorer</a> suite of products. For bonus points, offer to teach a Delphi programming course</li><br /><li>Unsubscribe from borland.public.delphi.non-technical</li><br /></ul>Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com10tag:blogger.com,1999:blog-5741455.post-40498137619989224422007-06-01T14:46:00.000+12:002007-06-01T15:05:10.576+12:00Inserting a record only onceA few weeks back, my boss showed me a technique he uses when inserting a record into a FireBird table, which caters for the scenario that the record may already be there and therefore shouldn't be inserted. It was one of those simple yet elegant solutions, and I've been meaning to share it here. Well, I'm waiting for a data import process to finish, so I thought I'd take the time to finally do this.<br /><br />The technique revolves around turning the concept of a left join on its head and using it to check for failure (i.e a null field value). Here is an example of what I'm talking about :-<br /><pre class="sourcecode"><br /><code class="keyword">insert</code> <code class="keyword">into</code> tax_category(category_description, tax_rate)<br /><code class="keyword">select</code> <code class="quote">'GST'</code>, <code class="quote">'12.5'</code> <code class="keyword">from</code> rdb$<code class="keyword">database</code><br /><code class="keyword">left</code> <code class="keyword">join</code> tax_category t<br /><code class="keyword">on</code> t.category_description = <code class="quote">'GST'</code><br /><code class="keyword">where</code> t.category_id <code class="keyword">is</code> <code class="keyword">null</code>;<br /></pre><br />The above snippet will attempt to insert a record into the tax_category table using a set of hard-coded values, but because of the left join and where clause, the recordset being used for the insert will be empty if the join finds an existing record in the table.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com23tag:blogger.com,1999:blog-5741455.post-71737947003697191752007-03-02T09:45:00.000+13:002007-03-02T10:07:43.294+13:00Hang on, help is on its wayI have been given permission from CodeGear to blog about some of the new features in the soon to be released Delphi 2007 for Win32, code named Spacely. It seemed like as good an excuse as any to wake this normally sleepy blog from its usual slumber.<br /><br />One of the major complaints with Delphi 2006 was the quality of the online help shipped with the product. I know personally that I find locating the information I require in the D2006 help to be a lot more cumbersome than in Delphi versions 7 and below. <br /><br />For instance, when looking up the help for a particular class, often related symbols are listed in the help but with no hyperlink, forcing you to search for that symbol individually as you peruse down the chain of responsibility for the class. And another pet peeve is how all symbols for a class are listed strictly in alphabetical order, rather than also being limited by scope.<br /><br />Thankfully, CodeGear have acknowledged this as a major issue, and have been taking significant steps to improve the situation. I am glad to say that the D2007 help has improved tremendously in this regard. As a little teaser, below I've attached screenshots showing the summary for the TCollectionItem class, along with details of all members. As a comparison, I've also included a screenshot of the same information from the D2006 help. For the benefit for readers who have not seen the D2006 help, these screenshots preceed the D2007 ones in each example (and are not covered in a big Beta version disclaimer :-)). A larger version of each of the below screenshots can be shown by clicking on them.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_EqwrN8doZxc/Rec-rYpf8CI/AAAAAAAAAA0/eKHF2cW0NiM/s1600-h/Help1.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_EqwrN8doZxc/Rec-rYpf8CI/AAAAAAAAAA0/eKHF2cW0NiM/s400/Help1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5037063623308996642" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_EqwrN8doZxc/Rec-1Ipf8DI/AAAAAAAAAA8/PlJpKhxUNXc/s1600-h/Help2.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_EqwrN8doZxc/Rec-1Ipf8DI/AAAAAAAAAA8/PlJpKhxUNXc/s400/Help2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5037063790812721202" /></a><br /><br />You'll note in the above screenshot that the class heirarchy is rendered in a graphical fashion. It is also important to note that each of the individual boxes representing a class in the inheritance tree is hyperlinked to the help summary for the class being shown.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_EqwrN8doZxc/Rec-SIpf8AI/AAAAAAAAAAk/91hksX7OAvc/s1600-h/Help3.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_EqwrN8doZxc/Rec-SIpf8AI/AAAAAAAAAAk/91hksX7OAvc/s400/Help3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5037063189517299714" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_EqwrN8doZxc/Rec-eYpf8BI/AAAAAAAAAAs/498rijigQ90/s1600-h/Help4.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_EqwrN8doZxc/Rec-eYpf8BI/AAAAAAAAAAs/498rijigQ90/s400/Help4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5037063399970697234" /></a><br /><br />In the above shot, you can clearly see that the members for the TCollectionItem class are grouped by visibility level. These sections can also be collapsed and expanded, as evidenced by the public methods section being collapsed in the screenshot. There is also additional information shown about each symbol in the class, such as whether it is a virtual method.<br /><br />Now, I don't expect a 100% perfect help system in their first attempt to resolve all the issues in the previous version, but it certainly seems that significant strides have been made in this area. So it seems the <a href="http://en.wikipedia.org/wiki/Little_River_Band">Little River Band</a> were right, and Help is on its way :-)Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com6tag:blogger.com,1999:blog-5741455.post-22752882063813424992007-02-13T22:31:00.000+13:002007-01-25T09:50:40.133+13:00I like to fiddleI was reminded once again this week of the usefulness of a tool I initially discovered a while ago when resolving a bug with <a href="http://cc.codegear.com">CodeCentral</a> downloading submissions in IE7. This handy little utility called <a href="http://www.fiddlertool.com/fiddler/">Fiddler </a> is an HTTP proxy which allows you to intercept and log all HTTP traffic between clients and servers. It also allows you to place breakpoints so request and response packets can be manually altered.<br /><br />This week I've been working on developing a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> web service client. I can't make the assumption that a timed out transmission wasn't actually received and processed at the server, so I needed to ensure I gracefully handled any timeouts when posting requests. The thing that made simulating this particular condition interesting was that I wanted certain requests to succeed and others to fail. And because I don't have control over the server, this would normally require writing my own dummy server or proxy app so I could simulate this behavior. But by using <a href="http://www.fiddlertool.com/fiddler/">Fiddler</a>, I was able easily to intercept all traffic to the server and prevent certain packets from getting through, which would then have the desired effect of a timeout being raised for those particular HTTP post operations.<br /><br />While this may be vastly under utilizing the power of <a href="http://www.fiddlertool.com/fiddler/">Fiddler</a>, it certainly served as a timely reminder to me how useful this tool is when developing HTTP based applications.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com1tag:blogger.com,1999:blog-5741455.post-77685426970883171362007-01-25T09:47:00.000+13:002007-01-25T09:50:40.160+13:00Tag, you're it!Firstly, I should apologise for taking so long to get to this. But better late than never, aye?<br /><br /><a href="http://blogs.codegear.com/jesperhogstrom/">Jesper Hogstrom</a> has tagged me, so it is now my turn to try and blog about 5 semi-interesting facts that might not be well known about me. Unfortunately, I've not <a href="http://blogs.codegear.com/nickhodges/archive/2006/12/20/30787.aspx">been in an FA18 while it's pushed through the sound barrier</a>, but I'll do my best to make this interesting.<br /><br />1. Working as a software developer was not my first career choice. I initially wanted to be a sound audio engineer, spending my days behind a mixing desk creating the next killer album. But because I am partially deaf in my left ear, I had to abandon that dream.<br /><br />2. I started my career as a bank teller, which was a vocation I did for about 6 years. When working for <a href="http://www.westpac.com.au/internet/publish.nsf/Content/PB+HomePage">Westpac</a> in Australia, the call came out for staff who wanted to be trained as computer programmers. The logic was that by doing so, the bank would groom a breed of programmers who also understand the needs of the business. In any case, this was the turning point in my career and helped me to become the Delphi Junkie that I am today.<br /><br />3. I lived in Singapore for 3 years, between 1977 and 1979. My dad taught at the school for the children of the New Zealand, Australian and British armed forces. His job also saw us living in a little town called <a href="http://en.wikipedia.org/wiki/Ardrossan%2C_South_Australia">Ardrossan</a> in South Australia for a year, and nearly had us living on the island of <a href="http://en.wikipedia.org/wiki/Niue">Niue</a> for a year.<br /><br />4. While not quite as fast as an FA18, I have piloted a Cessna once. I was given what I thought was a scenic flight as a Christmas present from my mother-in-law, but once I hopped in the plane, the pilot let me take over the controls for the whole flight. This included performing the take off and landing (with help, of course). I can see that flying would get very addictive very quickly.<br /><br />5. I am currently in the middle of a 'get fit' phase, which has me going for a morning run 4 days a week. I run about <a href="http://www.mapmyrun.com/route/new-zealand/auckland/143283371">2.2KM</a>, which may not seem like very far but is still enough of a challenge. I'm thinking about stepping up to <a href="http://www.mapmyrun.com/route/new-zealand/auckland/171719283">3.9KM</a> real soon now.<br /><br />Now to pass the mantle on to other Bloggers. I tag <a href="http://radioactivecode.com">Diego Barros</a>, <a href="http://blogs.codegear.com/chewy/">Chewy,</a> <a href="http://blogs.codegear.com/RichardVowles/">Richard Vowles</a> and <a href="http://blogs.codegear.com/MalcolmGroves/">Malcolm Groves<br /></a><br /><ol><li><br /></li></ol>Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-89972518824487877382007-01-01T00:20:00.000+13:002007-01-01T00:45:26.275+13:00I'm SpidermanI took the <a href="http://www.thesuperheroquiz.com/">Superhero quiz</a> today, and apparently I'm Spiderman :-<br /><br />"You are intelligent, witty, a bit geeky and have great power and responsibility."<BR><br /><IMG SRC="http://www.thesuperheroquiz.com/pics/spidy.gif"><br /><br><br />I'm quite chuffed with this result, as it dovetails nicely into my desire to increase my web development skills :-)Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1165519832493946182006-12-08T08:30:00.000+13:002006-12-08T08:30:32.493+13:00I've got a new jobNormally I wouldn't blog about getting a new job, but this particular one has attributes which I think make it worthy of bringing this relatively inactive blog back to life. It's not the fact that I'll be using Delphi 2006 in a fulltime capacity. Nor is it the fact that there is an ECO project on the horizon. Sure, they are both very attractive attributes, but the best thing about this job is that I'll be working with a gentleman known on the Delphi newsgroups as "Scout".<br /><br />Regulars to the borland.public.delphi.non-technical newsgroup will probably have read many of Scouts posts, which often revolve around a common theme. This theme is of the little guy battling the big guys (and winning) by using the power and productivity of Delphi. Below are a few of his posts :-<br /><br /><ul><br /><li><a href="http://groups-beta.google.com/group/borland.public.delphi.non-technical/msg/c55ea906b4d28a59">Skinning a cat & refining cat skinning the delphi way</a></li><br /><li><a href="http://groups-beta.google.com/group/borland.public.delphi.non-technical/msg/ecfaede4c47dcad8">About porting a DOS BP7 app to Delphi</a></li><br /><li><a href="http://groups-beta.google.com/group/borland.public.delphi.non-technical/msg/1ebcdeeb4e29309c">I shipped my first BDS2006-built system</a></li><br /><li><a href="http://groups-beta.google.com/group/borland.public.delphi.non-technical/msg/6c03dc1abe234922">My experience with ALM & Delphi</a></li><br /></ul> <br /><br />I am very excited to have the opportunity to work with someone who shares my passion for Delphi, and am relishing the challenges I will face as I enter what is a totally new application domain for me. And after meeting Scout in person, it seems that we share many of the same ideas in regards to application architectures and software development in general. Bring it on!Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com5tag:blogger.com,1999:blog-5741455.post-1151538308026219642006-06-29T11:45:00.000+12:002006-06-29T11:45:08.026+12:00Are you a Help Vampire?While browsing the Borland newsgroups this morning, I was intrigued by a line in Peter Below's signature stating "Don't be a vampire". Following the <a href="http://slash7.com/pages/vampires" title="Help Vampires">accompanying link</a> took me to a page which I could definitely relate to. It seems I've worked with one or two Help Vampires (and still do ;-)), and have certainly spotted my fair share on the newsgroups.<br> <br />It always boggles me why so many people don't Google for solutions before posting to newsgroups or online forums. I personally find that I very rarely come across a problem that hasn't already been solved, with the solution documented somewhere on the Internet. And for those <a href="http://www.borland.com/us/products/delphi/index.html" title="Borland Delphi 2006">Borland Developer Studio</a> users out there, you can always install my <a href="http://cc.borland.com/Item.aspx?id=22678" title="Google Search Open Tool">Google Search open tool</a> into the IDE, to make this process a little easier. It was originally written using C#Builder 1, and should hopefully work with all versions of the BDS lDE. Be warned it was my first ever open tool, and not my finest work by any means. But I find it functional enough to be a useful addition to my BDS setup.<br />Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1150356049232129082006-06-15T19:20:00.000+12:002006-06-15T19:20:49.276+12:00BDS 2006 CodeCentral open tool updatedI've updated the <a href="http://cc.borland.com/item.aspx?id=24005" title="BDS 2006 CodeCentral open tool">CodeCentral open tool for BDS 2006</a> to allow it to be loaded if BDS is launched using one of the single personality (e.g. C#Builder) shortcuts.<br><br />Be aware that there are some known niggles when loading BDS with some of the personalities. For example, the CodeCentral menu item requires two clicks to respond the first time it is chosen, and the forms won't be loaded as part of the initially loaded project desktop. Manually selecting the desktop in the comobox after the IDE has loaded will cause it to load all CodeCentral open forms correctly. I'll endevour to address these issues in a future release.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1150280552693931252006-06-14T22:22:00.000+12:002006-06-14T22:29:11.416+12:00CodeCentral web service open tool for D2005A D2005 version of the CodeCentral web service open tool has been <a href="http://cc.borland.com/item.aspx?id=24011" title="D2005 CodeCentral web service open tool">uploaded to CodeCentral</a>. I have also hopefully addressed issues that BDS 2006 Professional users were suffering with missing BPLs. So if you are a BDS Pro user who attempted to use the <a href="http://cc.borland.com/item.aspx?id=24005" title="BDS 2006 CodeCentral web service open tool">BDS 2006 version</a> of the open tool, please download it and let me know if you still have problems.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com2tag:blogger.com,1999:blog-5741455.post-1150097226886164112006-06-12T19:27:00.000+12:002006-06-12T19:27:06.956+12:00CodeCentral web service is liveFor the uninitiated, <a href="cc.borland.com" title="CodeCentral">CodeCentral</a> is an excellent online repository of source code, demo applications and other valuable programming resources. In additional to the web interface, a web service can now be accessed to search against the CodeCentral repository and download submissions. For all the goss, read the article <a href="http://bdn.borland.com/article/33517" title="CodeCentral web service article">here</a>.<br><br />For now the web service currently provides a read only view of the CodeCentral data, but there are plans for future versions to support rating and commenting of submissions, and allow the adding and editing of submissions.<br><br />In conjunction with the web service launch, an <a href="http://cc.borland.com/Item.aspx?id=24005" title="CodeCentral web service open tool">open tool</a> for BDS 2006 has also been developed. This allows CodeCentral to be searched without ever having to leave the comfy confines of the IDE.<br />Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com3tag:blogger.com,1999:blog-5741455.post-1148332257020098922006-05-23T09:10:00.000+12:002006-05-23T09:11:00.033+12:00New ECO Book ReleasedAlois Schmid has released an <a href="http://www.ecospace.de/en_ecobook.html">English translation</a> of his ECO book which was previously only available in German. I haven't had a chance to give it a detailed going over yet, but judging from the Table of Contents it certainly looks like it covers an impressive amount of material. Well done Alois! Your contribution is certain to be very well received by the ECO development community.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1146221678891088612006-04-28T22:54:00.000+12:002006-04-28T22:54:38.946+12:00Wohoo! Free Stuff!Looks like the kind folks at <a href="http://www.modelmakertools.com/" title="ModelMaker Tools">ModelMaker Tools</a> are having a bit of a <a href="http://www.modelmakertools.com/free-licenses.html" title="ModelMaker Tools giveaway">giveaway</a>. All you have to do is e-mail them with the ModelMaker product you'd like, along with a few other contact details, and they will be drawing 3 lucky winners on June 1st. See <a href="http://www.modelmakertools.com/free-licenses.html" title="ModelMaker Tools giveaway">here</a> for full details.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com1tag:blogger.com,1999:blog-5741455.post-1133309103997290762005-11-30T13:05:00.000+13:002005-11-30T13:05:03.996+13:00PocketCaddy gets the ECO treatment<p>A while ago I wrote an application to demonstrate the capabilities of the Delphi for .NET Compact Framework preview compiler. This application was designed to keep track of the scores for a round of golf for one or more players, and has been floating around on <a href="http://cc.borland.com/Item.aspx?id=23393">CodeCentral</a> for a while. It was even given a mention in <a href="http://blogs.borland.com/davidi/archive/2005/05/30.aspx">David Intersimone's blog</a>.</p><br /><p>One thing that became apparent very early on in the PocketCaddy development cycle was that it that it is extremely tedious to enter course and player data on a PocketPC device. I decided to use this as an excuse to finally dive head first into the ECO world, and set about creating an administration application which would allow data to be entered on a PC and downloaded to the PocketPC via a web service. I am pleased to announce that this is now downloadable from <a href="http://cc.borland.com/Item.aspx?id=23610">CodeCentral</a>. <br /><p>Because this was my first ECO application, I wanted to explore many aspects of ECO development, so as a result it will show examples of the following ECO technologies and techniques :-<br /><ul><br /><li>ECO Winforms application</li><br /><li>ECO web service application</li><br /><li>ECO sync server application used by the Winforms and web service applications to broker persistence requests to an Interbase database</li><br /><li>Traversing an ECO model at runtime and serializing to custom XML</li><br /><li>Custom AutoForms implementation (ported from an original <a href="http://www.droopyeyes.com/default.asp?mode=ShowProduct&ID=15">C# implementation</a> written by Peter Morris, with his kind permission)</li></ul></p><br /><p>Be aware that it was developed using Delphi 2006 and ECO III, so you may be unable to compile it in Delphi 2005. Nevertheless the code should still give insights into many techniques that will work with ECO II. Feel free to offer any feedback, but please be gentle. As I mentioned earlier, this was my first attempt at an ECO app :-)</p><br /><br /><br />Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com6tag:blogger.com,1999:blog-5741455.post-1132812967306559052005-11-24T19:16:00.000+13:002005-11-26T00:52:40.236+13:00Enumerating COM ports in Delphi for .NETI needed to enumerate all the available COM ports in a .NET application I was writing the other day. Because the 1.1 version of the .NET Framework has no inbuilt support for serial communications, this meant it was time to Google a solution. To my surprise there were surprisingly few hits, with the only usable solution described on a web site written in Chinese. Not to be discouraged, I used the <a href="http://babelfish.altavista.com/">AltaVista BabelFish translation service</a> to translate it to English, and below is the end result (after converting it from C# with the help of the <a href="http://dotnet.borland.com/babelclient/BabelClient.aspx">Borland BabelCode</a> web service). I customized it slightly so that either all ports on the system would be returned, or only COM ports (which is all that I was interested in at the time). I'm posting this here so an easy solution will be a mere Google away for all those English speaking Delphi programmers out there. :-)<br><br /><pre class="sourcecode"><code><br /><font color="#000000"><b>unit</b> AvailablePortsUnit;<br /><br /><b>interface</b><br /><br /><b>uses</b><br /> System.Runtime.InteropServices, System.Collections.Specialized;<br /><br /><b>type</b><br /> [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]<br /> PORT_INFO_1 = <b>record</b><br /> pName: <b>string</b>;<br /> <b>end</b>;<br /><br /><b>function</b> AvailablePorts(<b>const</b> AComPortsOnly: Boolean): StringCollection;<br /><br /><b>implementation</b></font><br /><br /><font color="#000000">[DllImport</font>(<font color="#9933CC">'winspool.drv'</font>,<font color="#000000"> CharSet=CharSet.Auto)]<br /><b>function</b> EnumPorts(AName: <b>string</b>; ALevel: Integer; ABuffer: IntPtr;<br /> ACbBuff: Integer; out ANeeded: Integer; out AReturned: Integer): Boolean; <b>external</b>;<br /><br /><b>function</b> AvailablePorts(<b>const</b> AComPortsOnly: Boolean): StringCollection;<br /><b>type</b><br /> TPortInfoArray = <b>array</b> <b>of</b> PORT_INFO_1;<br /><b>var</b><br /> lIndex: Integer;<br /> lComName: <b>string</b>;<br /> i: Integer;<br /> lCurrent: IntPtr;<br /> lPorts: TPortInfoArray;<br /> lBuffer: IntPtr;<br /> lNeeded: Integer;<br /> lReturned: Integer;<br /><b>begin</b><br /> Result := StringCollection.Create;<br /> lBuffer := IntPtr.Zero;<br /> EnumPorts(<b>nil</b>, 1, lBuffer, 0, lNeeded, lReturned);<br /> lBuffer := Marshal.AllocHGlobal((lNeeded + 1));<br /> <b>try</b><br /> EnumPorts(<b>nil</b>, 1, lBuffer, lNeeded, lNeeded, lReturned);<br /> SetLength(lPorts, lReturned);<br /> lCurrent := lBuffer;<br /> <b>for</b> i := 0 <b>to</b> lReturned - 1 <b>do</b><br /> <b>begin</b><br /> lPorts[i] := (PORT_INFO_1(Marshal.PtrToStructure(lCurrent, TypeOf(PORT_INFO_1))));<br /> <b>if</b> (<b>not</b> AComPortsOnly) <b>or</b> (lPorts[i].pName.StartsWith(</font><font color="#9933CC">'COM'</font><font color="#000000">)) <b>then</b><br /> <b>begin</b><br /> <b>if</b> AComPortsOnly <b>then</b><br /> <b>begin</b><br /> lIndex := lPorts[i].pName.IndexOf(</font><font color="#9933CC">':'</font><font color="#000000">);<br /> <b>if</b> (lIndex <> -1) <b>then</b><br /> lComName := lPorts[i].pName.Remove(lIndex, 1)<br /> <b>else</b><br /> lComName := lPorts[i].pName;<br /> <b>end</b><br /> <b>else</b><br /> lComName := lPorts[i].pName;<br /> Result.Add(lComName);<br /> <b>end</b>;<br /> lCurrent := IntPtr((Integer(lCurrent) + Marshal.SizeOf(TypeOf(PORT_INFO_1))));<br /> <b>end</b>;<br /> <b>finally</b><br /> Marshal.FreeHGlobal(lBuffer);<br /> <b>end</b>;<br /><b>end</b>;<br /><b>end</b>.<br /></code></pre><br /></font>Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1127170620567186952005-09-20T10:57:00.000+12:002005-09-20T10:57:00.566+12:00The Smart Device Framework has been freed!The <a href="http://www.opennetcf.org/sdf" title="OpenNetCF Smart Device Framework">Smart Device Framework</a> is an essential <a href="http://www.opennetcf.org/library/" title="Smart Device Framework Online Help">framework of classes</a> for anyone tackling any serious CF development. It plugs many of the functionality gaps left by the standard CF assemblies.<br /><br />This framework used to only be accessible to VS.NET 2003 users, as the SDF installer exited if it couldn't detect the presence of VS.NET.<br /><br />Thanks to Chris Tacke (a co-founder of <a href="http://www.opennetcf.org/CategoryView.aspx?category=Home" title="OpenNETCF.org">OpenNETCF.org</a>), this limitation can now be avoided, as the Smart Device Framework is now available as a binaries only download from the <a href="http://www.opennetcf.org/sdf" title="Smart Device Framework Downloads.">SDF download page</a>. The full source code for the SDF (C#) can also be downloaded if required.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1126997298216419052005-09-18T10:48:00.000+12:002005-09-18T22:04:45.903+12:00Excellent Delphi for .NET CF articleStefan Cruysberghs has published an excellent <a href="http://www.scip.be/index.php?Page=ArticlesDelphi15&Lang=EN">Delphi for .NET Compact Framework article</a> on his website. It expands upon my <a href="http://bdn.borland.com/article/0,1410,33066,00.html">Quickstart guide</a>, by explaining many of the differences between the compact and desktop versions of the .NET framework, and offers workarounds for some of the missing methods.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com1tag:blogger.com,1999:blog-5741455.post-1123706574581159752005-08-11T08:42:00.000+12:002005-08-11T08:42:54.580+12:00Now why didn't I think of that?I've recently had an <a href="http://bdn.borland.com/article/0,1410,33276,00.html" title="VCL.NET with ECO article">article</a> posted on BDN explaining how to use VCL.NET with <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a>. While I was relatively happy with it, the approach does lose any databinding support that using <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> with WinForms provides<br><br />In the <a href="nntp://newsgroups.borland.com/borland.public.delphi.modeldrivenarchitecture.eco" title="ECO Delphi newsgroup">ECO newsgroups</a> today, Kostas Terzides outlined how to use a TListConnector class to enable databinding standard VCL.NET databound controls to an ExpressionHandle. I've outlined his steps below :-<br><br /><br /><ul><li>Drop a TListConnector (from Borland.Vcl.ADONETDb namespace- it might not be installed by default) in the form and add a TDataSource and a TDBgrid (or your favorite 3rd party grid). Wire them all up.</li><br /><li>Add Borland.Eco.Handles to the uses clause (interface section)</li><br /><li>Add these private fields in the form:</li><br /><font face="Courier New" size=2><pre class="sourcecode"><code><br /> <font color="#000000"><b>private</b><br /></font> <font color="#003399"><i>{ Private declarations }</i></font><br /><font color="#000000"> FEcoSpace:TEcoSpace;<br /> FEhContact:ExpressionHandle;<br /> FRefHandle:ReferenceHandle;</font><br /></code></pre></font><br /><li>Add this in the OnCreate event handler of the form:</li><br /><font face="Courier New" size=2><pre class="sourcecode"><code><br /><font color="#000000"><b>procedure</b> TMainForm.FormCreate(Sender: TObject);<br /><b>begin</b><br /> FEcoSpace:=TEcoSpace.Create;<br /> FEcoSpace.Active:=True;<br /><br /> FRefHandle:=ReferenceHandle.Create;<br /> FRefHandle.EcoSpace:=FEcoSpace;<br /><br /> FEhContact:=ExpressionHandle.Create;<br /> FEhContact.RootHandle:=FRefHandle;<br /> FEhContact.Expression:=</font><font color="#9933CC">'Contact.allInstances'</font>;<br /><font color="#000000"><br /> ListConnector1.DataObject:=FEhContact.GetList;<br /> ListConnector1.Active:=True;<br /><b>end</b>;</font><br /></code></pre></font><br /><br /><li>Add this in the event handler for OnNewRecord of ListConnector1 (this is a little bit weird (the dataset gets automatically from dsInsert to dsEdit), but it is a quick and dirty solution. If someone has a better one please post):</li><br /><font face="Courier New" size=2><pre class="sourcecode"><code><br /><font color="#000000"><b>procedure</b> TMainForm.ListConnector1NewRecord(DataSet: TDataSet);<br /><b>begin</b><br /> Contact.Create(FEcoSpace);<br /> FEhContact.EnsureBindingList;<br /> ListConnector1.CheckBrowseMode;<br /> ListConnector1.Edit;<br /><b>end</b>;</font><br /></code></pre></font><br /></ul><br /><br /><br />Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com2tag:blogger.com,1999:blog-5741455.post-1122075299873043472005-07-23T11:34:00.000+12:002005-07-23T11:37:27.390+12:00VCL.NET support for ECO... a light winks onI'd love to have <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> support <a href="http://bdn.borland.com/article/0,1410,29460,00.html" title="VCL.NET">VCL.NET</a>, and was ruminating over this fact yesterday, when a thought dawned on me. The only thing that really makes <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> a WinForms technology is its support for .NET WinForms binding via the Reference/Expression/CurrencyManagerHandle components, and the EcoAutoForm stuff. The other underlying services and frameworks are not really dependant on WinForms at all.<br><br />For the life of me, I can't see why it wouldn't be feasible to use <a href="http://bdn.borland.com/article/0,1410,29460,00.html" title="VCL.NET">VCL.NET</a> as your presentation framework, and still have full access to the EcoSpace IPersistenceService, IUndoService, IDirtyListService, IOCLService etc. The only thing you'd lose is the ability to have your domain objects bound to your GUI, which isn't really a big deal to me as I was in the habit of manually populating from my BO classes with my last few projects anyway. Hang on...<br><br /><i>type, type, compile, mumble, type, compile..</i><br /><br><br />OK, now I've quickly thrown together a prototype to test my theory. It uses the assembly containing the model that my currently under construction WinForms and ASP.NET <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> apps use, and simply shows all instances of the Course class from the model in a TListView. It does, however use a PersistenceMapperClient to talk to my <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> server application, and this all worked out of the box (as expected). If anyone is interested (or actually reads this blog for that matter), feel free to <a href="mailto:dclegg@gmail.com">contact me</a> and I can send you a copy. Alternatively, it was posted to the <a href="nntp://newsgroups.borland.com/borland.public.attachments" title="Borland Public Attachments">borland.public.attachements</a> newsgroup, but be warned that posts there have a limited shelf life.<br><br /><br />Its only a proof of concept thing, but seems to strengthen my belief that there is no reason why <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO </a>and <a href="http://bdn.borland.com/article/0,1410,29460,00.html" title="VCL.NET">VCL.NET</a> are mutually exclusive. It only has the code for the <a href="http://bdn.borland.com/article/0,1410,29460,00.html">VCL.NET</a> app, and includes the binaries for the assembly containing my model, and for the <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> server (connection hardcoded to tcp://localhost:8000/PocketCaddyServer). The <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> Server has a PersistenceMapperBDP which is talking to an <a href="http://www.borland.com/us/products/interbase/index.html" title="InterBase">InterBase</a> database with the hardcoded path of POCKETCADDY.GDB (also included in the zip), but I see no reason why PersistenceMapperXML couldn't be used in the <a href="http://bdn.borland.com/article/0,1410,29460,00.html" title="VCL.NET">VCL.NET</a> client for testing. I only chose to use my <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> server to further re-inforce the whole proof of concept deal.<br><br /><br />And since coding this app, I've had <a href="http://groups-beta.google.com/group/borland.public.delphi.modeldrivenarchitecture.eco/browse_frm/thread/d5ce2fa333a48de5/5e6a846e8415e81f#5e6a846e8415e81f" title="confirmation">confirmation</a> from the <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> architects that there is nothing wrong with this plan at all, and the only thing you lose is support for databinding to your GUI. So if that isn't really an issue, there is no real reason to not use <a href="http://bdn.borland.com/article/0,1410,29460,00.html" title="VCL.NET">VCL.NET</a> for <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> apps today.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com4tag:blogger.com,1999:blog-5741455.post-1121251900200941542005-07-13T22:51:00.000+12:002005-07-13T22:55:38.630+12:00What a blast!Well, I managed to come through my <a href="http://bdn.borland.com/article/0,1410,33109,00.html" title="24 Hours of Delphi">24 Hours of Delphi </a>interview largely unscathed. As it turns out, the majority of the discussion centered around the forthcoming <a href="http://www.borland.com/us/products/delphi/index.html" title="Delphi">Delphi</a> for .NET Compact Preview compiler. It seems there is quite a bit of interest in the community for this one. I was fortunate to get a sneak peek at this, when <a href="http://blogs.borland.com/johnk/" title="John Kasters blog">John Kaster</a> from <a href="http://www.borland.com/" title="Borland">Borland</a> Developer Relations asked me to write a <a href="http://bdn.borland.com/article/0,1410,33066,00.html" title="Delphi for .NET CF Preview Article">CF Preview Quick Start article</a>.<br><br />I mentioned in the chat that I'd been working on a PocketPC application called <a href="http://blogs.borland.com/davidi/archive/2005/05/30/4621.aspx" title="David I PocketCaddy blog entry">PocketCaddy</a>. I've now uploaded this to <a href="http://cc.borland.com/item.aspx?id=23393" title="PocketCaddy CodeCentral submission">CodeCentral</a>. This is very much an evolving product, and I'm currently working on a PC based data entry <a href="http://www.borland.com/us/products/delphi/eco.html" title="Enterprise Core Objects">ECO</a> WinForms app, and <a href="http://www.borland.com/us/products/delphi/eco.html" title="Enterprise Core Objects">ECO</a> web service to expose this data to the PocketPC device. So as they say, stay tuned...Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1121222260247378252005-07-13T14:37:00.000+12:002005-07-13T16:09:59.553+12:00OK, now this is getting a little scaryI've been slated to take part in Borlands <a href="http://bdn.borland.com/article/0,1410,33109,00.html" title="24 Hours of Delphi">24 Hours of Delphi</a> marathon tonight. I must say the enormity of this didn't really sink in until I noticed my name in an <a href="http://biz.yahoo.com/bw/050712/125796.html?.v=1" title="Borland Press Release">official Borland press release</a>.<br><br />After all, I'm just a mere Delphi Junkie who spends <strike>a little</strike> <strike>a few hours</strike> a fair chunk of his life on the Borland newsgroups. It is indeed a great honor to be considered interview worthy, especially considering the lofty company I'll be keeping in this event.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0tag:blogger.com,1999:blog-5741455.post-1118489578509054242005-06-11T23:32:00.000+12:002005-06-22T22:22:10.553+12:00Showing a true read-only DataGridI had an interesting situation the other day where I wanted to use a WinForms DataGrid to display a read-only list of some <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> classes. I soon discovered that there is no easy way to support having a DataGrid where the entire row is selected when a record is clicked. Even though the DataGrid is read-only, an individual column can still get focus, with the caret painted and the contents highlighted.<br><br />Normally to get around this problem I would revert to using a ListView, where getting this behaviour is easy. But as the DataGrid was being used in an <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> WinForms application, I wanted to still use it so I could take advantage of the EcoFormExtender functionality offered when doing so. This includes being able to add, edit and delete <a href="http://www.borland.com/us/products/delphi/eco.html" title="ECO">ECO</a> objects without writing a single line of code.<br><br />After a bit of judicial Googling, I found that I should be able to get the behaviour I wanted by creating a DataGridTextBoxColumn descendant and overriding its Edit method. Below is the code for this :-<br /><pre class="sourcecode"><code><br /><font color="#000000"><b>procedure</b> TDataGridUnselectableCellColumn.Edit(ASource: CurrencyManager;<br /> ARowNumber: Integer; ABounds: Rectangle; AReadOnly: Boolean; AText: <b>string</b>;<br /> ACellIsVisible: Boolean);<br /><b>begin</b><br /> <b>if</b> (FSelectedRow > -1) <b>and</b> (FSelectedRow < ASource.List.Count) <b>then</b><br /> DataGridTableStyle.DataGrid.UnSelect(FSelectedRow);<br /> FSelectedRow := ARowNumber;<br /> DataGridTableStyle.DataGrid.Select(FSelectedRow);<br /><b>end</b>;</font><br /></code></pre><br />This is all well and good, but I don't have design-time support for this TDataGridUnselectableCellColumn class, and I don't really want to stuff around too much to see if it is feasible to create a DataGrid descendant just so I can get it. To get around this problem, I created a base form containing a DataGrid which calls the below method on the WinForm.Load event :-<br /><pre class="sourcecode"><code><br /><font color="#000000"><b>procedure</b> TDataGridForm.InitializeGridColumns;<br /><b>var</b><br /> lTableStyle: DataGridTableStyle;<br /> lSourceColumn: DataGridColumnStyle;<br /> lDestColumn: TDataGridUnselectableCellColumn;<br /><b>begin</b><br /> lTableStyle := DataGridTableStyle.Create;<br /> <b>if</b> dgMain.TableStyles.Count = 1 <b>then</b><br /> <b>begin</b><br /> <b>for</b> lSourceColumn <b>in</b> dgMain.TableStyles[0].GridColumnStyles <b>do</b><br /> <b>begin</b><br /> lDestColumn := TDataGridUnselectableCellColumn.Create;<br /> lDestColumn.Alignment := lSourceColumn.Alignment;<br /> lDestColumn.HeaderText := lSourceColumn.HeaderText;<br /> lDestColumn.NullText := lSourceColumn.NullText;<br /> lDestColumn.PropertyDescriptor := lSourceColumn.PropertyDescriptor;<br /> lDestColumn.MappingName := lSourceColumn.MappingName;<br /> lDestColumn.Width := lSourceColumn.Width;<br /> lTableStyle.GridColumnStyles.Add(lDestColumn);<br /> <b>end</b>;<br /> dgMain.TableStyles.Clear;<br /> dgMain.TableStyles.Add(lTableStyle);<br /> <b>end</b>;<br /><b>end</b>;</font><br /></code></pre><br />So I now have an easy way to have a read-only display of a list of my ECO objects, simply by descending from this TDataGridForm and configuring the DataGrid.TableStyles property to contain the column mappings for the class attributes I wish to display. Not the most elegant solution for sure, but one I can live with for now.Davehttp://www.blogger.com/profile/06345522383537221090noreply@blogger.com0