Cornamuse

If you are interested in making a cornamuse which is a rennaisance wind instrument similar to a crumhorn then click here.

 

Delphi

Years ago I wrote a simple clipart viewer in VB3 in order to teach myself how to write programs. Later I rewrote this as a way of teaching myself Delphi. Originally the program used an array of image components, the metafiles were loaded in using:

image.picture.loadfromfile();

and copied to clipboard using:

clipboard.assign(image.picture);

The Delphi version had two major faults, the first was obvious. When copying the metafile to the clipboard and pasting it into another application the aspect ratio was lost. I found a Microsoft article

HOWTO: Call Clipboard API from Visual Basic 4.0 (Q159823)

describing how to do this using Windows ApIs but I wasn't capable of translating this into Delphi at first but eventually succeeded. Note the VB3 version doesn't have this problem.

Click on this link for wmf copy code. If you use wide.wmf, it is interesting that the text is correct after passing through the clipboard but not before.

wmf copy

wide.wmf



The second fault which I only discovered recently was that the more pictures that were viewed, the more system resources were used up and these were not returned when the program was exited. The only way to get them back was to restart Windows. The way I have got round this is a bit suspect but was inspired by another Microsoft article

Q156696
BUG: EMF Playback into DC Causes Memory Leak in GDI

This article isn't really very helpful. Another article

Q257523
BUG: Resource Leak Occurs When You Display WMF Files in a PictureBox

wasn't much help either but showed that the W31 APIs have a different problem to the W9 ones.

The essence of the fix is that "PlayEnhMetaFile is called into a region without clipping" by manipulating the values of the MetaFilePict structure. Having incorporated the fix into my WMF viewer I think that it now takes longer to update each page. On a fast computer you may not notice the difference.

Click on this link for wmf display code.

wmf display

There must be a simpler way to get round this problem using W31 APIs as the VB3 version doesn't have this problem either.

The Delphi program had an extra feature added to it, to be able to start MSDraw, an ole program which comes with Microsoft Works. The main difficulty I had was that it was not correctly registered and progress only occurred after Works had been reinstalled. I did not use it as an ole server but used the clipboard to transfer the metafiles. MSDraw is good for doing little changes to metafiles. The software for this was just two lines. In the form.show was:

olecontainer1.CreateObject('msdraw',false);

In the menu.click was:

olecontainer1.doverb(ovShow);

Both lines could have been in the menu.click routine but MSDraw opened slightly quicker doing it this way. There was an olecontainer on the form with visible set to true, it doesn't work with visible set to false. In order to make it not show on the form the width, height, left and top were all set to zero.

 

 


 

Useful comments and ideas can be sent to :

postmaster@tuning.free-online.co.uk

 

last updated 06/10/2008

 

 

 

Counter