The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for the ‘Delphi XE2’ Category

Run batch file from Delphi IDE (via: Stack Overflow)

Posted by jpluimers on 2013/05/29

In pre-Galileo versions of Delphi it was easy to run a .BAT or .CMD file as a main project file: just press F9.

Thanks to iManBiglary for posting how to do this in modern Delphi versions. Paraphrased:

Add the file path to cmd.exe (easieist is to add $(ComSpec) which expands the %ComSpec% environment variable) in the tools menu, with /c$EDNAME as the parameter.
In addition, you can tell the IDE to save your file before running the external tool with the $SAVE macro

One of the things you can do with this is add a project containing a batch file that starts to assemble your build results to create a deployment set.

–jeroen

via: Run batch file from Delphi IDE – Stack Overflow.

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Leave a Comment »

Delphi XE2: spontaneous Product or License Validation Error | General

Posted by jpluimers on 2013/05/24

Every once in a while an AV in Delphi manifests itself in a very odd way.

Usually it is refactoring, code completion or any of the ‘insight’ features doing odd things.

This time, it got me into a Product or License Validation Error | General:

Product or License Validation Error

Your Embarcadero product or license can’t be validated.

If you see this page when you’re using a valid license and official version of the software, please submit an installation support case for further assistance.

If you need a trial license and official trial software download, visit our Trial Downloads page.

To purchase a product license and receive a certified download, please see our How to Buy page.

Too bad the error hard-quits Delphi, thereby loosing all your work since the last save. Even more reason to safe often.

None of the reasons mentioned in Starting Delphi or C++ Builder results in Product or License Validation Error applied.

Restarting Delphi XE2 solved the problem.

–jeroen

Posted in Delphi, Delphi XE2, Development, Software Development | 7 Comments »

DataSnap in the Cloud – DelphiFeeds.com

Posted by jpluimers on 2013/05/22

On my research list (Thanks Uwe!): DataSnap in the Cloud – DelphiFeeds.com.

It shows you how to do DataSnap from the Azure clound, including getting some of the default Delphi database demos to work on SQL Server (erm, SQL Azure).

–jeroen

Posted in Delphi, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Leave a Comment »

Don’t pass interfaces between application architectures over a DLL boundary

Posted by jpluimers on 2013/05/15

It is unwise to pass objects allocated in one framework over a DLL boundary to a different framework.

In the case of Using C dll in delphi return nothing, someone tries to pass an Interface to some memory in the C side over to Delphi.

Unless that interface is COM based, don’t do that!

In a more general way: don’t pass memory allocated on the DLL side over to the client side, no matter what kind of client you have.

From the DLL, either pass simple types, or fill buffers allocated at the client side.

Edit:

There was a nice Delphi DLL return string from C# … .NET 4.5 Heap Corruption but .NET 4.0 works? Explain please? – Stack Overflow question explaining in detail what to do for strings in a specific case: use the COM heap on the Delphi side using CoTaskMemAlloc (actually it uses the OLE task memory allocator as the Old New Thing explains).

–jeroen

via: Using C dll in delphi return nothing – Stack Overflow.

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Delphi, Delphi 1, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 5 Comments »

A few notes on Delphi, WSDL and SOAP: passing nil values, Document/Literal versus RPC Encoded

Posted by jpluimers on 2013/05/14

I had some notes on Delphi WSDL and SOAP peculiarities somewhere, but I misplaced them.

Luckily, I found some links that explain most of my notes well:

–jeroen

Posted in Conference Topics, Conferences, Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Event, SOAP/WebServices, Software Development | Leave a Comment »

Some Delphi & C#/.NET links on XML related stuff

Posted by jpluimers on 2013/05/02

for my link archive:

–jeroen

Posted in .NET, C#, Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 1 Comment »

FMX is not a VCL replacement

Posted by jpluimers on 2013/05/01

This is more elaborate English version of a short Dutch message I recently sent to explain the differences between VCL and FMX:

Do not regard FMX as a replacement for VCL: they are different kinds of frameworks.

VCL is a wrapper around Windows Controls. In itself, it has not much functionality: it exposes the underlying Windows functionality. The exception are data aware controls that provide basic functionality for writing data aware applications. There is a huge 3rd party market for extending VCL support, for instance providing extra Windows functionality, enriching data aware behaviour (look at all those fancy data aware grids), and many more.

FMX  is the FireMonkey X-platform framework. Major functionalities are vector based 2D, 3D drawing and controls, and support for styles and composition.

When introducing FMX in Delphi XE2, Embarcadero also introduced a new way of data binding that is shared with FMX and VCL. FMX extends this a bit to some basic data aware controls.

Gone are most of the platform specific features like drag & drop, full blown Windows Shell ListViews, etc. There are some controls that manifests themselves differently on each supported platform (like Pickers), but most of that is currently left to the 3rd party FMX component market.

So if you want FMX to replace VCL, then be prepared for quite some shopping in the 3rd party market.

CLX tried to be a full blown cross platform VCL replacement, but that didn’t work very well.

–jeroen

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Development, FireMonkey, OS X FMX, Software Development | Tagged: , , , , , , | 1 Comment »

Delphi static class methods are assignment compatible with plain old function pointers

Posted by jpluimers on 2013/04/24

So I won’t forget, as the  [WayBackstatic in different languages varies in meaning:

[WayBack] Static on class methods makes them assignment compatible with plain old function pointers.

Thanks Moritz Beutel for initially posting this.

–jeroen

via:

related:

  • [Archive.isFacebook – Delphi developer: static class methods
  • [WayBack] Delphi 2007: Methods; Class Methods:

    Like class methods, class static methods can be accessed without an object reference. Unlike ordinary class methods, class static methods have no Self parameter at all. They also cannot access any instance members. (They still have access to class fields, class properties, and class methods.) Also unlike class methods, class static methods cannot be declared virtual.

    Methods are made class static by appending the word static to their declaration.

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 5 Comments »

delphi – How to simulate Windows Theme behaviour when TComboBox uses csOwnerDrawFixed or csOwnerDrawVariable? – Stack Overflow

Posted by jpluimers on 2013/04/17

Some notes if I ever want to do something like this.

In this case I worked around it by having the Items include different text (since I had object pointers in the TStrings anyway) so I could stick to the csDropDown Style.

A very easy way to show different string values than the Items is to set the Style property fromcsDropDown to csOwnerDrawFixed as Andreas Rejbrand has answered a few years ago.

The thing is: as soon as you do that, you loose Windows Theming support.
The same limitation applies to using csOwnerDrawVariable

These two Style values get translated into adding the CBS_OWNERDRAWFIXED orCBS_OWNERDRAWVARIABLE (in addition to CBS_DROPDOWNLISTstyles of the Windows COMBOBOX control.

In turn, CBS_OWNERDRAWFIXED or CBS_OWNERDRAWVARIABLE cause you to instantly loose the Windows theming support.

When you do full custom painting like a colour picker, that is all fine. But when you only want to replace the drawn text, it is not.

The Windows COMBOBOX control does not seem to have a way around this, so I’m wondering: how can you simulate the Windows theming from Delphi?

I assume it has to do with DrawThemedBackground, but it has been a while since I’ve done serious Delphi Control work, so any pointers on how to get started there are fine too (even if they invalidate my assumption).

share|edit|close|delete|flag
75% accept rate
1
Just change the text in the control and let Windows do the work. – David Heffernan Sep 9 at 11:08
@DavidHeffernan That is a lot of work, so I wonder if simulating the theming is less work. And it would be a good exercise to learn more about how the theming support actually functions. – Jeroen Wiert Pluimers Sep 9 at 11:14
2
up voted
I cannot imagine that ComboBox1.Items.Assign is harder than working out theming. Very easy to get themed painting wrong as you can see from the VCL. Windows gets it right. – David Heffernan Sep 9 at 11:38
@DavidHeffernan The problem is not the Assign, but the mapping back to what I want. But I appreciate your point. Just waiting to see if someone comes with an answer into the theming direction and if not, work on the mapping. – Jeroen Wiert Pluimers Sep 9 at 12:21
1
up voted
Can you work it out by reading the code for TComboBoxStyleHook. – David Heffernan Sep 9 at 13:13
I tried, not much success yet, but when I do, I will post. First some non work though (: – Jeroen Wiert PluimersSep 9 at 13:24
1
up voted
As david says, I really don’t see the point of your question. You’re doing it the hard slow way, instead of the fast easy way (Just change the item text?) – Warren P Sep 10 at 3:21
I simplified the question a lot. Doing the reverse mapping requires me to enumerate over all items, which I’d rather not do (especially since I’d need abstract that for multiple not so similar kinds of occasions that are in different parts of the class hierarchy). – Jeroen Wiert Pluimers Sep 10 at 11:03
 
@JeroenWiertPluimers But you need to do that mapping at some point. The text has to come from somewhere. – David Heffernan Sep 10 at 12:09
@DavidHeffernan But now I need to do the reverse mapping… It’s not impossible like a trapdoor, but it is impractical. But probably less impractical than doing the theming. – Jeroen Wiert Pluimers Sep 10 at 14:19
1
up voted
If you can work the text out to paint it, you can work the text out to stuff into the combo box items. – David Heffernan Sep 10 at 14:42
@DavidHeffernan stuffing the text into the items isn’t the problem. The reverse (getting the right underlying item back from that text) is. That’s my mapping problem, hence the reference to the trapdoor. – Jeroen Wiert Pluimers Sep 10 at 15:14
 
OK, now I understand. I guess at this point you wished you had a better separation between business logic and UI! – David Heffernan Sep 10 at 15:15
I usually want, as most code I maintain at clients has very bad separation. But in this case the separation is quite OK. The Business Layer gives me a TStrings with the Objects filled (it is pre-Delphi-2009, so no generics yet). That’s why I can get out the Text sou easy (: First I need to finish about a week of .NET work though. – Jeroen Wiert Pluimers Sep 10 at 16:03
 
I actually wish that I had a completely VCL-implementation of TComboBox if only due to the issues in the Standard Control ComboBox setting its item height however it wants. If I was stuck in your situation, I think I’d almost write my own TExtComboBox and its own VCL styles feature. – Warren P Sep 10 at 20:45
The comments by @DavidHeffernan did give me some thought. Since the Object instance references are already in the TStrings, I wrote a small function to return a new temporary TStrings that has the string values with the captions I needed and keep the Object references. Since it has the same item ordering, and same Object references I don’t need any mapping at all. Just need to make sure I free the new TStrings at the right moment. – Jeroen Wiert Pluimers Sep 10 at 21:24

add comment

–jeroen

via: delphi – How to simulate Windows Theme behaviour when TComboBox uses csOwnerDrawFixed or csOwnerDrawVariable? – Stack Overflow.

Posted in Delphi, Delphi XE2, Delphi XE3, Development, Software Development | 3 Comments »

Delphi + ADO + dBase – Stack Overflow

Posted by jpluimers on 2013/04/10

For my research queue:

I should look at the below ConnectionStrings to access dBase with ADO from Delphi, If I ever need to do that.

Thanks Cromulent for asking, Nelson for editing and Pieter for answering:

Microsoft dBase ODBC driver

Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;OLE DB Services = -1;Extended Properties=dBase IV;Dbq=c:\mypath

doing operations like ADOTable1.Open are very fast (good) but GetIndexNames returns nothing (bad).

Microsoft Jet OLEDB 4.0 driver

Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;OLE DB Services=-1;Data Source=c:\mypath

doing operations like ADOTable1.Open are exceedingly slow (bad) while GetIndexNames does return index names the way it should (good).

How do I get both speed and the index info via ADO for the dBase tables?

Microsoft Paradox Driver 7.x

“We use the following connection string which works really well.”

Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="Driver={Microsoft Visual FoxPro Driver};UID=;SourceDB=c:\mypath;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"

–jeroen

via Delphi + ADO + dBase – Stack Overflow.

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 8 Comments »