VB.Net by API/System.Windows.Forms/Application — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:52, 26 мая 2010

Application.AddMessageFilter

  
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class MessageFilter
   public Shared Sub Main
         Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Public Class NoLeftDownMessageFilter
        Implements IMessageFilter
        Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements IMessageFilter.PreFilterMessage
            Const WM_LBUTTONDOWN As Long = &H201
            Return (m.Msg = WM_LBUTTONDOWN)
        End Function
    End Class
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim no_left_down_message_filter As New NoLeftDownMessageFilter
        Application.AddMessageFilter(no_left_down_message_filter)
    End Sub
    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        Application.UseWaitCursor = Not Application.UseWaitCursor
    End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Public Class Form1
    Inherits System.Windows.Forms.Form
    "Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ruponentModel.IContainer
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.SuspendLayout()
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Text = "UseMessageFilter"
        Me.ResumeLayout(False)
    End Sub
End Class


Application.ApplicationExit

  

Imports System.Windows.Forms
Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents button4 As System.Windows.Forms.Button
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button1 As System.Windows.Forms.Button
    Public Sub New()
        MyBase.New()
        Me.button4 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        Me.button4.Location = New System.Drawing.Point(24, 127)
        Me.button4.Name = "button4"
        Me.button4.Size = New System.Drawing.Size(144, 23)
        Me.button4.TabIndex = 7
        Me.button4.Text = "Show MessageBox"
        "
        Me.button3.Location = New System.Drawing.Point(24, 90)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(144, 23)
        Me.button3.TabIndex = 6
        Me.button3.Text = "Throw Exception"
        "
        Me.button2.Location = New System.Drawing.Point(24, 53)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(144, 23)
        Me.button2.TabIndex = 5
        Me.button2.Text = "Application.ExitThread"
        "
        Me.button1.Location = New System.Drawing.Point(24, 16)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(144, 23)
        Me.button1.TabIndex = 4
        Me.button1.Text = "Application.Exit"
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(192, 166)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button4, Me.button3, Me.button2, Me.button1})
        Me.ResumeLayout(False)
    End Sub
    Shared Sub App_Exit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Exit")
    End Sub
    Shared Sub App_Idle(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Idle")
    End Sub
    Shared Sub App_ThreadingException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadException")
        Dim msg As String = "A problem has occurred in this application." & vbCrLf & vbCrLf & _
            vbTab & e.Exception.Message & vbCrLf & vbCrLf & _
            "Would you like to continue the application so that " & vbCrLf & _
            "you can save your work?"
        Dim res As DialogResult = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo)
        If res = System.Windows.Forms.DialogResult.Yes Then Exit Sub
        Application.Exit()
    End Sub
    Shared Sub DumpThreadID(ByVal name As String)
        System.Diagnostics.Debug.WriteLine(name & " thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Shared Sub DummyThreadStart()
        DumpThreadID("Dummy Thread")
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
    End Sub
    Shared Sub Main()
        AddHandler Application.ThreadException, New System.Threading.ThreadExceptionEventHandler(AddressOf App_ThreadingException)
        AddHandler Application.Idle, New EventHandler(AddressOf App_Idle)
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
        AddHandler Application.ApplicationExit, New EventHandler(AddressOf App_Exit)
        DumpThreadID("UI Thread")
        Dim dummythread As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf DummyThreadStart))
        dummythread.Start()
        Application.Run(New Form1())
    End Sub
    Shared Sub App_ThreadExit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadExit on thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Application.Exit()
    End Sub
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Application.ExitThread()
    End Sub
    Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
        Throw New System.IO.FileLoadException()
    End Sub
End Class


Application.CompanyName

  
Imports System.Windows.Forms
public class Test
   public Shared Sub Main
        Console.WriteLine(Application.rupanyName)
        Console.WriteLine(Application.ProductName)
        Console.WriteLine(Application.ProductVersion)
   End Sub
End class


Application.DoEvents()

  

Option Strict On
imports System
imports System.Drawing
imports System.Windows.Forms
public class ProgressBars : inherits Form
  dim pb as ProgressBar
  dim lbl as Label
  public sub New()
    Size = new Size(300,200)
    dim btn as new Button()
    btn.Parent = me
    btn.Text = "&Start"
    btn.Location = new Point(0,0)
    AddHandler btn.Click, AddressOf btn_OnClick
    lbl = new Label()
    lbl.Parent = me
    lbl.Size = new Size(100,23)
    lbl.Location = new Point(0,25)
    lbl.BorderStyle = BorderStyle.FixedSingle
    lbl.TextAlign = ContentAlignment.MiddleCenter
    lbl.Text = ""
    pb = new ProgressBar()
    pb.Parent = me
    pb.Location = new Point(0, 70)
    pb.Size = new Size(400, 20) 
    pb.Minimum = 0      "  the default value
    pb.Maximum = 100    "  the default value
  end sub  "  close for constructor
  private sub btn_OnClick(ByVal sender as object,ByVal e as EventArgs)
    dim cntr as integer = 0
    pb.Value = 0
    pb.Step = 1
    for i as integer = 0 to 100000
      cntr  = cntr + 1
      if cntr mod 100 = 0 then
        lbl.Text = cntr.ToString()
        pb.PerformStep()
        Application.DoEvents()
        System.Threading.Thread.Sleep(40)
      end if
    next
  end sub
  public shared sub Main() 
    Application.Run(new ProgressBars())
  end sub
end class


Application.ExecutablePath

  
Imports System.Windows.Forms
Public Class Tester
    Public Shared Sub Main
    
        Console.WriteLine(Application.ExecutablePath)
        Console.WriteLine(Application.StartupPath)
    End Sub
End Class


Application.Idle

  

Imports System.Windows.Forms
Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents button4 As System.Windows.Forms.Button
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button1 As System.Windows.Forms.Button
    Public Sub New()
        MyBase.New()
        Me.button4 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        Me.button4.Location = New System.Drawing.Point(24, 127)
        Me.button4.Name = "button4"
        Me.button4.Size = New System.Drawing.Size(144, 23)
        Me.button4.TabIndex = 7
        Me.button4.Text = "Show MessageBox"
        "
        Me.button3.Location = New System.Drawing.Point(24, 90)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(144, 23)
        Me.button3.TabIndex = 6
        Me.button3.Text = "Throw Exception"
        "
        Me.button2.Location = New System.Drawing.Point(24, 53)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(144, 23)
        Me.button2.TabIndex = 5
        Me.button2.Text = "Application.ExitThread"
        "
        Me.button1.Location = New System.Drawing.Point(24, 16)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(144, 23)
        Me.button1.TabIndex = 4
        Me.button1.Text = "Application.Exit"
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(192, 166)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button4, Me.button3, Me.button2, Me.button1})
        Me.ResumeLayout(False)
    End Sub
    Shared Sub App_Exit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Exit")
    End Sub
    Shared Sub App_Idle(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Idle")
    End Sub
    Shared Sub App_ThreadingException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadException")
        Dim msg As String = "A problem has occurred in this application." & vbCrLf & vbCrLf & _
            vbTab & e.Exception.Message & vbCrLf & vbCrLf & _
            "Would you like to continue the application so that " & vbCrLf & _
            "you can save your work?"
        Dim res As DialogResult = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo)
        If res = System.Windows.Forms.DialogResult.Yes Then Exit Sub
        Application.Exit()
    End Sub
    Shared Sub DumpThreadID(ByVal name As String)
        System.Diagnostics.Debug.WriteLine(name & " thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Shared Sub DummyThreadStart()
        DumpThreadID("Dummy Thread")
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
    End Sub
    Shared Sub Main()
        AddHandler Application.ThreadException, New System.Threading.ThreadExceptionEventHandler(AddressOf App_ThreadingException)
        AddHandler Application.Idle, New EventHandler(AddressOf App_Idle)
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
        AddHandler Application.ApplicationExit, New EventHandler(AddressOf App_Exit)
        DumpThreadID("UI Thread")
        Dim dummythread As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf DummyThreadStart))
        dummythread.Start()
        Application.Run(New Form1())
    End Sub
    Shared Sub App_ThreadExit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadExit on thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Application.Exit()
    End Sub
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Application.ExitThread()
    End Sub
    Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
        Throw New System.IO.FileLoadException()
    End Sub
End Class


Application.ProductName

  
Imports System.Windows.Forms
public class Test
   public Shared Sub Main
        Console.WriteLine(Application.rupanyName)
        Console.WriteLine(Application.ProductName)
        Console.WriteLine(Application.ProductVersion)
   End Sub
End class


Application.ProductVersion

  
Imports System.Windows.Forms
public class Test
   public Shared Sub Main
        Console.WriteLine(Application.rupanyName)
        Console.WriteLine(Application.ProductName)
        Console.WriteLine(Application.ProductVersion)
   End Sub
End class


Application.Run

  

Imports System.Drawing.Drawing2D
Imports System
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Math
Public Class MainClass
   Shared Sub Main()
       Dim form1 As Form = New Form1()
       Application.Run(form1)
   End Sub 
End Class
 
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ResizeRedraw = True
    End Sub
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim txt As String
        Dim the_font As New Font("Times New Roman", 30, FontStyle.Bold, GraphicsUnit.Pixel)
        Dim layout_rect As RectangleF
        e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit
        layout_rect = New RectangleF(100, 0, 180, 70)
        txt = "Today is Monday. Tomorrow is Friday"
        Dim string_format As New StringFormat
        string_format.Trimming = StringTrimming.EllipsisWord
        e.Graphics.DrawString(txt, the_font, Brushes.Black, layout_rect, string_format)
        e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(layout_rect))
    End Sub
End Class


Application.StartupPath

  
Imports System.Windows.Forms
Public Class Tester
    Public Shared Sub Main
    
        Console.WriteLine(Application.ExecutablePath)
        Console.WriteLine(Application.StartupPath)
    End Sub
End Class


Application.ThreadException

  

Imports System.Windows.Forms
Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents button4 As System.Windows.Forms.Button
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button1 As System.Windows.Forms.Button
    Public Sub New()
        MyBase.New()
        Me.button4 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        Me.button4.Location = New System.Drawing.Point(24, 127)
        Me.button4.Name = "button4"
        Me.button4.Size = New System.Drawing.Size(144, 23)
        Me.button4.TabIndex = 7
        Me.button4.Text = "Show MessageBox"
        "
        Me.button3.Location = New System.Drawing.Point(24, 90)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(144, 23)
        Me.button3.TabIndex = 6
        Me.button3.Text = "Throw Exception"
        "
        Me.button2.Location = New System.Drawing.Point(24, 53)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(144, 23)
        Me.button2.TabIndex = 5
        Me.button2.Text = "Application.ExitThread"
        "
        Me.button1.Location = New System.Drawing.Point(24, 16)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(144, 23)
        Me.button1.TabIndex = 4
        Me.button1.Text = "Application.Exit"
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(192, 166)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button4, Me.button3, Me.button2, Me.button1})
        Me.ResumeLayout(False)
    End Sub
    Shared Sub App_Exit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Exit")
    End Sub
    Shared Sub App_Idle(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Idle")
    End Sub
    Shared Sub App_ThreadingException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadException")
        Dim msg As String = "A problem has occurred in this application." & vbCrLf & vbCrLf & _
            vbTab & e.Exception.Message & vbCrLf & vbCrLf & _
            "Would you like to continue the application so that " & vbCrLf & _
            "you can save your work?"
        Dim res As DialogResult = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo)
        If res = System.Windows.Forms.DialogResult.Yes Then Exit Sub
        Application.Exit()
    End Sub
    Shared Sub DumpThreadID(ByVal name As String)
        System.Diagnostics.Debug.WriteLine(name & " thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Shared Sub DummyThreadStart()
        DumpThreadID("Dummy Thread")
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
    End Sub
    Shared Sub Main()
        AddHandler Application.ThreadException, New System.Threading.ThreadExceptionEventHandler(AddressOf App_ThreadingException)
        AddHandler Application.Idle, New EventHandler(AddressOf App_Idle)
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
        AddHandler Application.ApplicationExit, New EventHandler(AddressOf App_Exit)
        DumpThreadID("UI Thread")
        Dim dummythread As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf DummyThreadStart))
        dummythread.Start()
        Application.Run(New Form1())
    End Sub
    Shared Sub App_ThreadExit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadExit on thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Application.Exit()
    End Sub
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Application.ExitThread()
    End Sub
    Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
        Throw New System.IO.FileLoadException()
    End Sub
End Class


Application.ThreadExit

  

Imports System.Windows.Forms
Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents button4 As System.Windows.Forms.Button
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button1 As System.Windows.Forms.Button
    Public Sub New()
        MyBase.New()
        Me.button4 = New System.Windows.Forms.Button()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        "
        Me.button4.Location = New System.Drawing.Point(24, 127)
        Me.button4.Name = "button4"
        Me.button4.Size = New System.Drawing.Size(144, 23)
        Me.button4.TabIndex = 7
        Me.button4.Text = "Show MessageBox"
        "
        Me.button3.Location = New System.Drawing.Point(24, 90)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(144, 23)
        Me.button3.TabIndex = 6
        Me.button3.Text = "Throw Exception"
        "
        Me.button2.Location = New System.Drawing.Point(24, 53)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(144, 23)
        Me.button2.TabIndex = 5
        Me.button2.Text = "Application.ExitThread"
        "
        Me.button1.Location = New System.Drawing.Point(24, 16)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(144, 23)
        Me.button1.TabIndex = 4
        Me.button1.Text = "Application.Exit"
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(192, 166)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button4, Me.button3, Me.button2, Me.button1})
        Me.ResumeLayout(False)
    End Sub
    Shared Sub App_Exit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Exit")
    End Sub
    Shared Sub App_Idle(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_Idle")
    End Sub
    Shared Sub App_ThreadingException(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadException")
        Dim msg As String = "A problem has occurred in this application." & vbCrLf & vbCrLf & _
            vbTab & e.Exception.Message & vbCrLf & vbCrLf & _
            "Would you like to continue the application so that " & vbCrLf & _
            "you can save your work?"
        Dim res As DialogResult = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo)
        If res = System.Windows.Forms.DialogResult.Yes Then Exit Sub
        Application.Exit()
    End Sub
    Shared Sub DumpThreadID(ByVal name As String)
        System.Diagnostics.Debug.WriteLine(name & " thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Shared Sub DummyThreadStart()
        DumpThreadID("Dummy Thread")
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
    End Sub
    Shared Sub Main()
        AddHandler Application.ThreadException, New System.Threading.ThreadExceptionEventHandler(AddressOf App_ThreadingException)
        AddHandler Application.Idle, New EventHandler(AddressOf App_Idle)
        AddHandler Application.ThreadExit, New EventHandler(AddressOf App_ThreadExit)
        AddHandler Application.ApplicationExit, New EventHandler(AddressOf App_Exit)
        DumpThreadID("UI Thread")
        Dim dummythread As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf DummyThreadStart))
        dummythread.Start()
        Application.Run(New Form1())
    End Sub
    Shared Sub App_ThreadExit(ByVal sender As Object, ByVal e As EventArgs)
        System.Diagnostics.Debug.WriteLine("App_ThreadExit on thread id= " & System.AppDomain.GetCurrentThreadId().ToString())
    End Sub
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Application.Exit()
    End Sub
    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Application.ExitThread()
    End Sub
    Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
        Throw New System.IO.FileLoadException()
    End Sub
End Class


Application.UseWaitCursor

  
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class MessageFilter
   public Shared Sub Main
         Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Public Class NoLeftDownMessageFilter
        Implements IMessageFilter
        Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements IMessageFilter.PreFilterMessage
            Const WM_LBUTTONDOWN As Long = &H201
            Return (m.Msg = WM_LBUTTONDOWN)
        End Function
    End Class
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim no_left_down_message_filter As New NoLeftDownMessageFilter
        Application.AddMessageFilter(no_left_down_message_filter)
    End Sub
    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        Application.UseWaitCursor = Not Application.UseWaitCursor
    End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Public Class Form1
    Inherits System.Windows.Forms.Form
    "Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ruponentModel.IContainer
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.SuspendLayout()
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Text = "UseMessageFilter"
        Me.ResumeLayout(False)
    End Sub
End Class