SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample illustrates drop down buttons and popup menus.
The source code is located at C:\Program Files (x86)\Softelvdm\SftButton OCX 3.0\Samples\Visual Studio - VB.NET\Popup\Form1.vb or C:\Program Files\Softelvdm\SftButton OCX 3.0\Samples\Visual Studio - VB.NET\Popup\Form1.vb (on 32-bit Windows versions).
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click Application.Exit() End Sub Private WorldIndex As Integer = 0 Private Sub SetImage() ' Update the button with the next image in the image list ' to get the spinning globe effect AxSftButton4.Image1.NETImageObject = ImageList1.Images(WorldIndex) WorldIndex = WorldIndex + 1 If WorldIndex >= ImageList1.Images.Count() Then WorldIndex = 0 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' Update the button bitmap every so often to get the ' spinning globe effect SetImage() End Sub Private Sub menuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem1.Click MessageBox.Show("Default Action selected") End Sub Private Sub menuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem2.Click MessageBox.Show("Action 1 selected") End Sub Private Sub menuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem3.Click MessageBox.Show("Action 2 selected") End Sub Private Sub menuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem4.Click MessageBox.Show("Action 3 selected") End Sub ' In order to support .NET 1.0 through the latest, we use TrackPopupMenu ' to nicely right-align the popup menu (Windows API), because the ' ContextMenu class doesn't support defining the alignment Public ReadOnly TPM_RIGHTALIGN As Integer = 8 Public ReadOnly TPM_TOPALIGN As Integer = 0 Public ReadOnly TPM_LEFTBUTTON As Integer = 0 <DllImport("user32.dll")> _ Public Shared Function TrackPopupMenu(ByVal Handle As IntPtr, _ ByVal uFlags As UInt32, ByVal x As Integer, ByVal y As Integer, _ ByVal nReserved As Integer, ByVal hwnd As IntPtr, ByVal prcRect As IntPtr) As IntPtr End Function Private Sub AxSftButton1_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton1.ClickEvent ' Invoke the default action, because the button was clicked menuItem1_Click(AxSftButton1, New System.EventArgs) End Sub Private Sub AxSftButton2_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton2.ClickEvent ' Invoke the default action, because the button was clicked menuItem1_Click(AxSftButton1, New System.EventArgs) End Sub Private Sub AxSftButton3_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton3.ClickEvent ' Invoke the default action, because the button was clicked menuItem1_Click(AxSftButton1, New System.EventArgs) End Sub Private Sub AxSftButton4_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton4.ClickEvent ' Invoke the default action, because the button was clicked menuItem1_Click(AxSftButton1, New System.EventArgs) End Sub Private Sub AxSftButton5_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton5.ClickEvent ' Invoke the default action, because the button was clicked menuItem1_Click(AxSftButton1, New System.EventArgs) End Sub Private Sub AxSftButton1_DropDownClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton1.DropDownClick ' The drop down button was clicked. Display a popup menu ' right-aligned with the right edge of the button Dim pt As Point = New Point(AxSftButton1.Location.X + AxSftButton1.Size.Width, _ AxSftButton1.Location.Y + AxSftButton1.Size.Height) pt = PointToScreen(pt) AxSftButton1.CancelMode() TrackPopupMenu(ContextMenu1.Handle, Convert.ToUInt32(TPM_RIGHTALIGN Or TPM_TOPALIGN Or TPM_LEFTBUTTON), pt.X, pt.Y, 0, Me.Handle, IntPtr.Zero) End Sub Private Sub AxSftButton2_DropDownClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton2.DropDownClick ' The drop down button was clicked. Display a popup menu ' right-aligned with the right edge of the button Dim pt As Point = New Point(AxSftButton2.Location.X + AxSftButton2.Size.Width, _ AxSftButton2.Location.Y + AxSftButton2.Size.Height) pt = PointToScreen(pt) AxSftButton2.CancelMode() TrackPopupMenu(ContextMenu1.Handle, Convert.ToUInt32(TPM_RIGHTALIGN Or TPM_TOPALIGN Or TPM_LEFTBUTTON), pt.X, pt.Y, 0, Me.Handle, IntPtr.Zero) End Sub Private Sub AxSftButton3_DropDownClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton3.DropDownClick ' The drop down button was clicked. Display a popup menu ' right-aligned with the right edge of the button Dim pt As Point = New Point(AxSftButton3.Location.X + AxSftButton3.Size.Width, _ AxSftButton3.Location.Y + AxSftButton3.Size.Height) pt = PointToScreen(pt) AxSftButton3.CancelMode() TrackPopupMenu(ContextMenu1.Handle, Convert.ToUInt32(TPM_RIGHTALIGN Or TPM_TOPALIGN Or TPM_LEFTBUTTON), pt.X, pt.Y, 0, Me.Handle, IntPtr.Zero) End Sub Private Sub AxSftButton4_DropDownClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton4.DropDownClick ' The drop down button was clicked. Display a popup menu ' right-aligned with the right edge of the button Dim pt As Point = New Point(AxSftButton4.Location.X + AxSftButton4.Size.Width, _ AxSftButton4.Location.Y + AxSftButton4.Size.Height) pt = PointToScreen(pt) AxSftButton4.CancelMode() TrackPopupMenu(ContextMenu1.Handle, Convert.ToUInt32(TPM_RIGHTALIGN Or TPM_TOPALIGN Or TPM_LEFTBUTTON), pt.X, pt.Y, 0, Me.Handle, IntPtr.Zero) End Sub Private Sub AxSftButton5_DropDownClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftButton5.DropDownClick ' The drop down button was clicked. Display a popup menu ' right-aligned with the right edge of the button Dim pt As Point = New Point(AxSftButton5.Location.X + AxSftButton5.Size.Width, _ AxSftButton5.Location.Y + AxSftButton5.Size.Height) pt = PointToScreen(pt) AxSftButton5.CancelMode() TrackPopupMenu(ContextMenu1.Handle, Convert.ToUInt32(TPM_RIGHTALIGN Or TPM_TOPALIGN Or TPM_LEFTBUTTON), pt.X, pt.Y, 0, Me.Handle, IntPtr.Zero) End Sub