New Kubrick XML template applied

I finally got a few spare minutes to do some housekeeping on this blog, upgraded to the new Kubrick XML template (thanks to Erica, Kaie, and Michael). I liked the old two-tab template better, though, but had to upgrade to the new Blogger XML template because I wanted to take advantage of the new widget feature.

Hosting .NET controls in VB6

I recently ran into a need to interop a C# .NET user control with a VB6 form.

We all know that VB6 only allows you to reference a user control if it resides in an OCX.

The Interop Forms Toolkit, mentioned here, seems to be only good for VB.NET user controls.

Prior to this, I've been able to get by with dynamically adding the control via Controls.Add {COMClassname}, {ControlName}

But now, I need to be able to manipulate the control in design time.

So, based on the above experience, I created a very basic VB6 user control called DotNetControlWrapper. The tricks with this control are the following:

  • There's a public property called DotNetClassName, which is a COM class name of the .NET control.

  • It delegates resizing logic to the .NET control.

  • It exposes the .NET control via a DotNetObject property, thus allowing the user to sync the control's events if needed.



The bulk of DotNetControlWrapper.ctl looks like this:



Option Explicit

Private object As Object
Private ctlExtender As VBControlExtender
Private mstrDotNetClass As String

Public Property Get DotNetClassName() As String
DotNetClassName = mstrDotNetClass
End Property
Public Property Let DotNetClassName(ByVal clsname As String)
mstrDotNetClass = clsname
If mstrDotNetClass = "" Then Exit Property
' initialize the .NET control
If Not ctlExtender Is Nothing Then
Controls.Remove UserControl.Extender.Name + "_dotnet"
End If
Set ctlExtender = Controls.Add(mstrDotNetClass, UserControl.Extender.Name + "_dotnet")
ctlExtender.ZOrder 0
Set object = ctlExtender.object
End Property

Private Sub UserControl_Resize()
If object Is Nothing Then Exit Sub
ctlExtender.Move 0, 0, UserControl.Width, UserControl.Height
object.BringToFront ' Bring the .NET control to foreground
End Sub

Private Sub UserControl_Show()
If ctlExtender Is Nothing Then Exit Sub
ctlExtender.Visible = True
End Sub

Public Property Get DotNetObject() As Object
Set DotNetObject = object
End Property

Private Sub UserControl_Terminate()
If ctlExtender Is Nothing Then Exit Sub
Set ctlExtender = Nothing
object.Dispose
Set object = Nothing
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "DotNetClassName", mstrDotNetClass
PropBag.WriteProperty "Width", UserControl.Width
PropBag.WriteProperty "Height", UserControl.Height
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
On Error Resume Next
DotNetClassName = PropBag.ReadProperty("DotNetClassName")
Width = PropBag.ReadProperty("Width")
Height = PropBag.ReadProperty("Height")
End Sub


Open sauced Jaspersoft?

In the past, I've dabbled a bit with Jaspersoft's reporting engine, back in the days when it was still called Panscopic. I'm just getting back to working with Scope Server now as I'm revisiting an old project, did some checking and it turned out they've open sourced the product since early last year. Subscribed!

I Don’t Care How Your Program Works

Found this from the MSDN Blog: Why Software Sucks. It's an interesting title for a book by Harvard professor David S. Platt. The following snippet from his sample chapter really scratched my "itch":

I Don’t Care How Your Program Works

[A] mistake that programmers make when they design user interfaces is to force users to understand the internal workings of their programs. Instead of the programmer adjusting her user interface to the user’s thought processes, she forces the user to adjust to hers. Furthermore, she’ll usually see nothing wrong with that approach. “That’s how my program works,” she’ll say, puzzled that anyone would even ask the question of why her user interface works the way it does.
...
You shouldn’t have to know or care about her program’s internal workings to use it successfully, as you shouldn’t have to know or care whether your car’s engine uses fuel-injection or a carburetor in order to drive it.


As programmers, we tend to think like....duh...programmers, and often forget to think like users. Being able to make this leap is probably one of the distinguishing factors between a seasoned programmer and a rookie.

Note to Self: stop being a rookie.

Ctrl-Alt-Del via Remote Desktop Connection

Ever wonder how you could issue a Ctrl-Alt-Delete command to your remote desktop connection? Try Ctrl-Alt-End.

Yahoo! Pipes

Got the tip from Gav last night about Yahoo! Pipes and trying to check it out just now.

Too funny! Is it April already?