Wednesday, July 6, 2011

Set ComboBox dropdown height in Visual Basic 6 (VB6) ComboBox control

Here is a useful piece of code to set the ComboBox dropdown height for VB6 ComboBox control.


Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Public Sub SetComboHeight(oComboBox As ComboBox, lNewHeight As Long)
    Dim oldscalemode As Integer
    ' This procedure does not work with frames: you cannot set the ScaleMode to vbPixels, because
    ' the frame does not have a ScaleMode Property.
    ' To get round this, you could set the parent control to be the form while you run this procedure.
    If TypeOf oComboBox.Parent Is Frame Then Exit Sub
    ' Change the ScaleMode on the parent to Pixels.
    oldscalemode = oComboBox.Parent.ScaleMode
    oComboBox.Parent.ScaleMode = vbPixels
    ' Resize the combo box window.
    MoveWindow oComboBox.hwnd, oComboBox.Left, oComboBox.Top, oComboBox.Width, lNewHeight, 1
    ' Replace the old ScaleMode
    oComboBox.Parent.ScaleMode = oldscalemode
End Sub


I've found this code on the web.
I would like to thanks to the original developer :-)

Friday, July 1, 2011

Reblog: +=1, -=1 not atomic operations at VB.net « George Birbilis @zoomicon

This is something that bit me sometime ago: seems +=1 and -=1 aren’t atomic operations at VB.net and other .NET languages (not sure for C++) although modern CPUs have INC and DEC instructions at least for integers (maybe IL – intermediate language [for .NET compilers' target "theoretical" machine spec] – doesn’t define such?)

You have to use the class System.Threading.Interlocked and specifically the Increment and Decrement methods it has...

Patterns for Parallel Programming (free downloadable pdf book by Microsoft) Understanding and Applying Parallel Patterns with the .NET Framework 4 - VB and C#

Here you can find a free downloadable PDF boook (118 pages) from microsoft, that talk about common pattern for parallel programming in .Net 4.0, VB and C#

Download link: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=19222