Click here to Skip to main content
15,886,007 members
Articles / Programming Languages / Visual Basic

Build Mobile PC Awareness lnto Mobile PC agnostic Windows Forms apps using Inheritance.

Rate me:
Please Sign up or sign in to vote.
4.19/5 (8 votes)
18 May 2007CPOL6 min read 35K   714   17  
Easily incorporate ink, power, network and size awareness into a Windows Form Application. The "Black Jack Card Game Starter Kit" is used as an example of a Mobile PC unaware app that is converted into a Mobile PC app by inheriting from the MobilePCAwareForm included with the download.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MobilePCAwareForm
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        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.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MobilePCAwareForm))
        Me.PowerStatusPictureBox = New System.Windows.Forms.PictureBox
        Me.NetworkStatusPictureBox = New System.Windows.Forms.PictureBox
        Me.pwrStatusNotifyIcon = New System.Windows.Forms.NotifyIcon(Me.components)
        Me.pwrIconsImageList = New System.Windows.Forms.ImageList(Me.components)
        Me.MobileToolTip = New System.Windows.Forms.ToolTip(Me.components)
        Me.netwrkIconsImageList = New System.Windows.Forms.ImageList(Me.components)
        CType(Me.PowerStatusPictureBox, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.NetworkStatusPictureBox, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'PowerStatusPictureBox
        '
        Me.PowerStatusPictureBox.Anchor = System.Windows.Forms.AnchorStyles.None
        Me.PowerStatusPictureBox.BackColor = System.Drawing.Color.Transparent
        Me.PowerStatusPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.PowerStatusPictureBox.Cursor = System.Windows.Forms.Cursors.Hand
        Me.PowerStatusPictureBox.Image = CType(resources.GetObject("PowerStatusPictureBox.Image"), System.Drawing.Image)
        Me.PowerStatusPictureBox.Location = New System.Drawing.Point(12, 21)
        Me.PowerStatusPictureBox.Name = "PowerStatusPictureBox"
        Me.PowerStatusPictureBox.Size = New System.Drawing.Size(28, 28)
        Me.PowerStatusPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.PowerStatusPictureBox.TabIndex = 0
        Me.PowerStatusPictureBox.TabStop = False
        '
        'NetworkStatusPictureBox
        '
        Me.NetworkStatusPictureBox.Anchor = System.Windows.Forms.AnchorStyles.None
        Me.NetworkStatusPictureBox.BackColor = System.Drawing.Color.Transparent
        Me.NetworkStatusPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.NetworkStatusPictureBox.Cursor = System.Windows.Forms.Cursors.Hand
        Me.NetworkStatusPictureBox.Location = New System.Drawing.Point(12, 320)
        Me.NetworkStatusPictureBox.Name = "NetworkStatusPictureBox"
        Me.NetworkStatusPictureBox.Size = New System.Drawing.Size(28, 28)
        Me.NetworkStatusPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.NetworkStatusPictureBox.TabIndex = 1
        Me.NetworkStatusPictureBox.TabStop = False
        '
        'pwrStatusNotifyIcon
        '
        Me.pwrStatusNotifyIcon.Icon = CType(resources.GetObject("pwrStatusNotifyIcon.Icon"), System.Drawing.Icon)
        Me.pwrStatusNotifyIcon.Text = "Power Status Unknown"
        '
        'pwrIconsImageList
        '
        Me.pwrIconsImageList.ImageStream = CType(resources.GetObject("pwrIconsImageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.pwrIconsImageList.TransparentColor = System.Drawing.Color.Transparent
        Me.pwrIconsImageList.Images.SetKeyName(0, "BatteryUnknown.ico")
        Me.pwrIconsImageList.Images.SetKeyName(1, "ACPower.ico")
        Me.pwrIconsImageList.Images.SetKeyName(2, "BatteryCharging.ico")
        Me.pwrIconsImageList.Images.SetKeyName(3, "BatteryHigh.ico")
        Me.pwrIconsImageList.Images.SetKeyName(4, "BatteryLow.ico")
        Me.pwrIconsImageList.Images.SetKeyName(5, "BatteryCritical.ico")
        Me.pwrIconsImageList.Images.SetKeyName(6, "NoSystemBattery.ico")
        Me.pwrIconsImageList.Images.SetKeyName(7, "PowerStatusUnknown.ico")
        '
        'MobileToolTip
        '
        Me.MobileToolTip.AutoPopDelay = 5000
        Me.MobileToolTip.InitialDelay = 100
        Me.MobileToolTip.ReshowDelay = 100
        Me.MobileToolTip.Tag = ""
        '
        'netwrkIconsImageList
        '
        Me.netwrkIconsImageList.ImageStream = CType(resources.GetObject("netwrkIconsImageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.netwrkIconsImageList.TransparentColor = System.Drawing.Color.Transparent
        Me.netwrkIconsImageList.Images.SetKeyName(0, "NetworkNone.ico")
        Me.netwrkIconsImageList.Images.SetKeyName(1, "NetworkLow.ico")
        Me.netwrkIconsImageList.Images.SetKeyName(2, "NetworkGood.ico")
        Me.netwrkIconsImageList.Images.SetKeyName(3, "WirelessNone.ico")
        Me.netwrkIconsImageList.Images.SetKeyName(4, "WirelessLow.ico")
        Me.netwrkIconsImageList.Images.SetKeyName(5, "WirelessGood.ico")
        '
        'MobilePCAwareForm
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(792, 446)
        Me.Controls.Add(Me.NetworkStatusPictureBox)
        Me.Controls.Add(Me.PowerStatusPictureBox)
        Me.MinimumSize = New System.Drawing.Size(800, 480)
        Me.Name = "MobilePCAwareForm"
        Me.Text = "Mobile Aware Form"
        CType(Me.PowerStatusPictureBox, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.NetworkStatusPictureBox, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents PowerStatusPictureBox As System.Windows.Forms.PictureBox
    Friend WithEvents NetworkStatusPictureBox As System.Windows.Forms.PictureBox
    Friend WithEvents pwrStatusNotifyIcon As System.Windows.Forms.NotifyIcon
    Friend WithEvents pwrIconsImageList As System.Windows.Forms.ImageList
    Friend WithEvents MobileToolTip As System.Windows.Forms.ToolTip
    Friend WithEvents netwrkIconsImageList As System.Windows.Forms.ImageList
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions