Microcontrollers for MenuItems

I have been working my way through Jeremy Miller’s excellent Build Your Own CAB Series (which would be even better if he felt like finishing!) and was very interested by the article on controlling menus with Microcontrollers. After reading it and writing a version of it myself, I came to the conclusion that some parts of it seem to be wrong. All of the permissioning is done based on the menu items which fire ICommands, and several menu items could use the same ICommand....

May 29, 2009 · 5 min

Generics to the rescue! Again!

I was writing a component at work that has many events that all need to be thread safe, and was getting annoyed at the amount of duplicate code I was writing: Public Event FilterStart(ByVal sender As Object, ByVal e As EventArgs) '... Private Delegate Sub OnFilterCompleteDelegate(ByVal sender As Object, ByVal e As FilterCompleteEventArgs) '... Private Sub OnFilterComplete(ByVal sender As Object, ByVal e As DataAccess.LoadEventArgs) If _parent.InvokeRequired Then _parent.Invoke(new OnFilterCompleteDelegate(AddressOf OnFilterComplete), new Object() {sender, e}) Else RaiseEvent FullResultsStart(sender, e) End If End Sub '....

May 22, 2009 · 2 min

Finally, I have used a Model View Controller!

Today I actually managed to use a Model View Controller in an application. I have been looking for an opportunity to use one fore a while, and have been reading a lot about them (Jeremy Miller’s Build Your Own CAB Series has been a very good guide). The type of MVC I like most (so far) is the Passive View type, where the View does almost nothing, and has no link to the Model:...

May 18, 2009 · 2 min

Creating Non resizable controls

A control I was recently developing required being non-resizable when on the form. When the application is running, this would be easy enough, just set its AutoSize property to False, and don’t dock the control. However, this leaves the problem of resizing in the designer. You could override the resize event of the control, but for reasons outlined earlier, such as flickering, I decided against this. Somewhere on the internet (where else…?...

April 13, 2008 · 2 min

VB.NET & C# Fixed height User Controls

Another problem I came across recently was fixed height user controls. Someone at work had created a fixed height user control, by putting the following code in the paint event: Me.Width = 20 Now while for the majority of cases this works, it doesn’t if you dock the control to the left or right of the form, as each time the Layout Engine tries to stick the top of the control to the top of the parent and the bottom of the control to the bottom of the parent, it fires the Paint() event....

March 29, 2008 · 2 min