.NET controls in Microsoft Access

Creating ActiveX objects in Visual Basic .NET is easy from Visual Studio 2008. There are a few checkboxes to tick, and a class attribute to add. But if you are doing an ActiveX control for use in let’s say an Microsoft Access application, there are some requirements that must be met, otherwise Access will not list your control. Of course, Microsoft gives you a template for this, and then you´re off. Thanks to Håkan Ståhl for pointing out this template to me.

Create a VB6 Interop UserControl project. The project that is shown on the screenshot below uses the standard name InteropUserControlLibrary1. I already hold a control. To rename the control, rename all three files (the vb file, the manifest and the bitmap). When the vb file is renamed, you will be asked if you want to rename the references too. Do that. Finally, fix the broken references in the manifest file (enter the new name in the progid attribute and the name attribute). Now you´re on your way. You can add a test project to the solution and start coding. The control is registered when you compile the project.

Photoname 2.0

I haven’t done much coding the last few days. I have spent my time with my family, working with my podcast, changing employer requires some attention after office hours as well. However, I am working on a version 2.0 of Photoname. I have decided to use a much more Explorer like appearance and I imagine that this change will reduce the number of questions I get on the application. I imagine that people actually like Photoname, but the outdated GUI might be an unnecessary obstacle.

Tonight, I will start editing episode 7 of the pod cast and tomorrow is first day at my new job.

Monkeybone: The Line instruction

There are two alternative ways to use the Line instruction in a Monkeybone image (a text file with .mob ending). You can either use named arguments or a list of coordinates. This example demonstrates both alternatives. The first V symbol is drawn using named arguments, the rest of the symbols are drawn using coordinate lists.

Clear 290x200 #a0a0a0
//Draw a V symbol using named arguments.
Line #000000 X1:10 Y1:10 X2:40 Y2:190
Line #000000 X1:40 Y1:190 X2:70 Y2:10
//Draw a V symbol using a polyline.
Line #000000 (80,10) (110,190) (140,10)
//A closed triangle.
Line #000000 (150,10) (180,190) (210,10) AutoClose
//A filled triangle.
Line #000000 (220,10) (250,190) (280,10) Filled

If you are using the Monkeybone .NET library, this code is used to produce a .mob file that contains one simple line and a polyline. To view the picture, open the output file in Monkeybone Viewer. The code requires a reference to the Monkeybone.dll.

Using Sw As New Monkeybone.MonkeyboneWriter("C:\Lines.mob", 200, 200, Drawing.Color.White)

   'Create a line by passing X1, Y1, X2 and Y2 to the constructor of the Line class.
   Dim SimpleLine As New Monkeybone.Instructions.Line(10, 190, 190, 190)
   SimpleLine.Color = Drawing.Color.Black
   Sw.WriteLine(SimpleLine)

   'Create a line by passing an array of coordinates to the constructor.
   Dim Points() As System.Drawing.Point = {New System.Drawing.Point(20, 20), _
      New System.Drawing.Point(180, 20), _
      New System.Drawing.Point(180, 180)}
   Dim PolyLine As New Monkeybone.Instructions.Line(Points)
   PolyLine.Color = Drawing.Color.Red
   Sw.WriteLine(PolyLine)

End Using

Finally, if you are using the Monkeybox control (named MBox1 in the example below) to display graphics directly on the screen, the following code displays one simple line on screen, together with the Monkeybone source code in a message box.

'Set the background color.
MBox1.BackColor = Color.White

'Add a red line to the monkeybox.
MBox1.AddLine(Color.Red, 10, 10, 90, 90)

'Redraw is not trigged by adding and instruction.
MBox1.Invalidate()

'Display the source code.
MessageBox.Show(MBox1.GetSource())

QXT version 1.2

The possibility to save the currently loaded XML document is added.

A new option is added to the Options dialog that lets users choose if XML editing i allowed in the loaded document (“Allow XML editing”).

When the “Allow XML editing” option is checked, you can double click on a attribute to change its value.

Open the XQT download page.

Switch between connections in QTool

I have added a new feature to the simple portable SQL Server query tool, QTool, that I made some time ago (here). Now, you can enter several connections strings in the Connection String tab, and use a drop down list to choose what connection you want your query to run on.

Additionally, you can add a name to the connection by typing a name followed by a colon in front of the connection string for a more clean display in the drop down list.

You can download it from here.

Photoname Portable, the command line arguments

These are the command line arguments that control the actions of pnp.exe, that you can send to it:

-fld [folder]

Renames all images in a specific folder. Specify the folder with images you want to rename, or type start to search for images in the same folder that pnp.exe is started from. Starting pnp.exe like this (from the command prompt):

pnp.exe -fld start

…has the same effect as double clicking it and type:

Rename Folder Start

Also, starting pnp.exe like this:

pnp.exe -fld “C:\Temp”

…has the same effect as double clicking it and type:

Rename Folder “C:\Temp”

-fle [filename]   Gives the specified file a new name. The file must be a jpg file that isn’t already renamed according to the Photoname convention.
-h Shows the available command line arguments.

Download Photoname Portable (25kb).

Hur används den portabla versionen av Photoname?

This is basically a Swedish version of this post.

Photoname Portable

The portable version of Photoname (pnp.exe) doesn’t have a GUI, but it is pretty simple to use anyway. You can either start it from the command interface and pass arguments to it to tell it what to do, or you can double click on it, and then tell it what to do. If you want to control pnp.exe from another application, you must know what arguments you can pass to it.

So, pnp.exe is a portable, lightweight GUI-less version of Photoname.
Some of the commands that you can run if you start it without arguments, that is, just by double clicking it:

Load {Filename} loads an image into memory. If the path or filename contains a space, you need quotation marks around it. Example:

Load "C:\Images\CW005132.jpg"

To view information about the loaded image, type Info. If you provide a filename, that file is loaded and info about that file is displayed. Example:

Info

Info "C:\Images\CW005133.jpg"

To rename one single file, use Rename File {Filename}. Example:

Rename File "C:\Images\CW005134.jpg"

If you ignore the filename, the currently loaded file will be renamed. To rename all files, use Rename Dir {Directory name}. Example:

Rename Dir "C:\Images"

Files that already match the RegEx pattern \d{14}_\d*\.(jpg|jpeg) will be ignored. If photodate is missing in the file, the change date will be used instead. The renamed file will be unloaded from memory in the process of renaming.

Photoname Portable can only handle full path, not relative paths.

For each file that Photoname Portable tries to rename, the output will be a text line that starts with “Ok.” for successful name change and “Rename failed.” for unsuccessful name change.

If you want to use the portable version to rename all images that need renaming, without any tricky typing, you can just type Dir? in the command prompt. Photoname Portable will ask you for a directory, do the name changes and then exit. Example:

Dir?

If you are automating Photoname Portable from another application, consider not sending “Dir?” to it. ;-) The folder browser might show up behind the console window.

Download Photoname Portable (25kb).

Photoname Portable soon introduced

I haven’t done much coding the last few weeks. I am in the process of changing jobs, and the new podcast is of course taking much of my time. My next update however, will be about my new portable lightweight version of Photoname. The portable version doesn’t have a GUI, but a rich set of command line arguments and a simple command line interface of its own.

In the meantime, this is something I can totally relate to: Top 10 Things That Annoy Programmers

Our skeptic podcast is climbing in Sweden

Our skeptic podcast is now #6 in Sweden according to iTunes. Thanks to my colleges Andreas, Carl Johan, John, Jon, Maria, Pekka and Peter for a great job, and to the listeners for showing interest in skepticism!

http://www.skeptikerpodden.se/