Imports AxSftButtonLib25
Imports SftButtonLib25
Imports Softelvdm.OLEConvert
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents label4 As System.Windows.Forms.Label
Friend WithEvents label3 As System.Windows.Forms.Label
Friend WithEvents label2 As System.Windows.Forms.Label
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents button1 As System.Windows.Forms.Button
Friend WithEvents menuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents menuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents menuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents menuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents AxSftButton3 As AxSftButtonLib25.AxSftButton
Friend WithEvents AxSftButton2 As AxSftButtonLib25.AxSftButton
Friend WithEvents AxSftButton1 As AxSftButtonLib25.AxSftButton
Friend WithEvents AxSftButton5 As AxSftButtonLib25.AxSftButton
Friend WithEvents AxSftButton4 As AxSftButtonLib25.AxSftButton
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents SftHelperComponent1 As Softelvdm.OCXHelper.SftHelperComponent
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.label4 = New System.Windows.Forms.Label
Me.label3 = New System.Windows.Forms.Label
Me.label2 = New System.Windows.Forms.Label
Me.AxSftButton5 = New AxSftButtonLib25.AxSftButton
Me.AxSftButton4 = New AxSftButtonLib25.AxSftButton
Me.AxSftButton3 = New AxSftButtonLib25.AxSftButton
Me.AxSftButton2 = New AxSftButtonLib25.AxSftButton
Me.AxSftButton1 = New AxSftButtonLib25.AxSftButton
Me.label1 = New System.Windows.Forms.Label
Me.button1 = New System.Windows.Forms.Button
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.menuItem1 = New System.Windows.Forms.MenuItem
Me.menuItem2 = New System.Windows.Forms.MenuItem
Me.menuItem3 = New System.Windows.Forms.MenuItem
Me.menuItem4 = New System.Windows.Forms.MenuItem
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.SftHelperComponent1 = New Softelvdm.OCXHelper.SftHelperComponent(Me.components)
CType(Me.AxSftButton5, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxSftButton4, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxSftButton3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxSftButton2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxSftButton1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'label4
'
Me.label4.Location = New System.Drawing.Point(184, 176)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(184, 56)
Me.label4.TabIndex = 19
Me.label4.Text = "Also notice the flicker-free display as the bitmap is updated in the SftButton co" & _
"ntrol on the left."
'
'label3
'
Me.label3.Location = New System.Drawing.Point(184, 112)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(184, 56)
Me.label3.TabIndex = 18
Me.label3.Text = "The drop down button is enabled using the ButtonStyle property."
'
'label2
'
Me.label2.Location = New System.Drawing.Point(184, 48)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(184, 56)
Me.label2.TabIndex = 17
Me.label2.Text = "A few samples demonstrating the use of the drop down button to display a popup me" & _
"nu."
'
'AxSftButton5
'
Me.AxSftButton5.Location = New System.Drawing.Point(136, 136)
Me.AxSftButton5.Name = "AxSftButton5"
Me.AxSftButton5.OcxState = CType(resources.GetObject("AxSftButton5.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftButton5.Size = New System.Drawing.Size(40, 24)
Me.AxSftButton5.TabIndex = 16
Me.AxSftButton5.TabStop = False
'
'AxSftButton4
'
Me.AxSftButton4.Location = New System.Drawing.Point(32, 184)
Me.AxSftButton4.Name = "AxSftButton4"
Me.AxSftButton4.OcxState = CType(resources.GetObject("AxSftButton4.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftButton4.Size = New System.Drawing.Size(128, 56)
Me.AxSftButton4.TabIndex = 15
Me.AxSftButton4.TabStop = False
'
'AxSftButton3
'
Me.AxSftButton3.Location = New System.Drawing.Point(32, 136)
Me.AxSftButton3.Name = "AxSftButton3"
Me.AxSftButton3.OcxState = CType(resources.GetObject("AxSftButton3.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftButton3.Size = New System.Drawing.Size(88, 32)
Me.AxSftButton3.TabIndex = 14
Me.AxSftButton3.TabStop = False
'
'AxSftButton2
'
Me.AxSftButton2.Location = New System.Drawing.Point(32, 88)
Me.AxSftButton2.Name = "AxSftButton2"
Me.AxSftButton2.OcxState = CType(resources.GetObject("AxSftButton2.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftButton2.Size = New System.Drawing.Size(112, 32)
Me.AxSftButton2.TabIndex = 13
Me.AxSftButton2.TabStop = False
'
'AxSftButton1
'
Me.AxSftButton1.Location = New System.Drawing.Point(32, 40)
Me.AxSftButton1.Name = "AxSftButton1"
Me.AxSftButton1.OcxState = CType(resources.GetObject("AxSftButton1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxSftButton1.Size = New System.Drawing.Size(112, 32)
Me.AxSftButton1.TabIndex = 12
Me.AxSftButton1.TabStop = False
'
'label1
'
Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label1.Location = New System.Drawing.Point(8, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(272, 32)
Me.label1.TabIndex = 11
Me.label1.Text = "SftButton/OCX And Popup Menus"
'
'button1
'
Me.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.button1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.button1.Location = New System.Drawing.Point(304, 8)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(64, 24)
Me.button1.TabIndex = 10
Me.button1.Text = "Close"
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem1, Me.menuItem2, Me.menuItem3, Me.menuItem4})
'
'menuItem1
'
Me.menuItem1.Index = 0
Me.menuItem1.Text = "Default Action"
'
'menuItem2
'
Me.menuItem2.Index = 1
Me.menuItem2.Text = "Action 1"
'
'menuItem3
'
Me.menuItem3.Index = 2
Me.menuItem3.Text = "Action 2"
'
'menuItem4
'
Me.menuItem4.Index = 3
Me.menuItem4.Text = "Action 3"
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32)
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.White
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 200
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.button1
Me.ClientSize = New System.Drawing.Size(376, 262)
Me.Controls.Add(Me.label4)
Me.Controls.Add(Me.label3)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.AxSftButton5)
Me.Controls.Add(Me.AxSftButton4)
Me.Controls.Add(Me.AxSftButton3)
Me.Controls.Add(Me.AxSftButton2)
Me.Controls.Add(Me.AxSftButton1)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.button1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.Text = "Softel vdm, Inc. - Popup Sample"
CType(Me.AxSftButton5, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxSftButton4, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxSftButton3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxSftButton2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxSftButton1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
'--locate-marker--
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
End Class