這檔案是 用伊莉論壇做範例,用VB 2008 版做的
是一個很簡易把標題 做一個篩檢而已
有用到 WebBrowser , ListView
原始碼在此,如想研究用請自取
這檔案是 用伊莉論壇做範例,用VB 2008 版做的
是一個很簡易把標題 做一個篩檢而已
有用到 WebBrowser , ListView
原始碼在此,如想研究用請自取
dim date2 as date = date.now
'轉換時間
date2 = (Date.Now - date1).ToString
Label1.Text = date2.ToString("yyyy/MM/dd HH:mm:ss.fffffff")
Dim bmCur As New Bitmap(60, 60)
Dim g As Graphics = Graphics.FromImage(bmCur)
'開始畫雙圓形
g.FillRectangle(Brushes.Transparent, 0, 0, 60, 60)
g.DrawEllipse(Pens.Red, 10, 10, 40, 40)
g.DrawEllipse(Pens.Red, 0, 0, 60, 60)
g.DrawEllipse(Pens.Red, 30, 30, 1, 1)
g.DrawEllipse(Pens.Red, 25, 25, 10, 10)
'取得滑鼠的指標
Dim ptrCur As IntPtr = bmCur.GetHicon
Dim cur As Cursor
cur = New Cursor(ptrCur)
'設定滑鼠
Cursor.Current = cur
這程式碼是用在要取視窗的標題文字用
深藍色字體可有可無
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Text
Namespace VBDotNet_SendMessage_WM_GETTEXT_ObjektbeschreibungErmitteln_1
Public Class MainForm
Inherits System.Windows.Forms.Form
Private button1 As System.Windows.Forms.Button
Public Shared Sub Main
Dim fMainForm As New MainForm
fMainForm.ShowDialog()
End Sub
Public Sub New()
MyBase.New
Me.InitializeComponent
End Sub
#Region " Windows Forms Designer generated code "
Private Sub InitializeComponent()
Me.button1 = New System.Windows.Forms.Button
Me.SuspendLayout
'
'button1
'
Me.button1.Location = New System.Drawing.Point(8, 8)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(280, 40)
Me.button1.TabIndex = 0
Me.button1.Text = "&Test..."
AddHandler Me.button1.Click, AddressOf Me.Button1Click
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 53)
Me.Controls.Add(Me.button1)
Me.Name = "MainForm"
Me.Text = "Testform <SendMessage - WM_GETTEXT - Objektbeschreibung ermitteln>"
Me.ResumeLayout(false)
End Sub
#End Region
Private Sub Button1Click(sender As System.Object, e As System.EventArgs)
Dim Result As String = GetText(button1.Handle)
If (Not Result Is String.Empty) Then
MessageBox.Show(GetText(Me.Handle), "Info")
End If
End Sub
End Class
End Namespace
Public Module Win32Api
Private Declare Function SendMessageByInt Lib "user32.dll" Alias "SendMessageA" _
(ByVal hWnd As IntPtr, _
ByVal uMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32
Private Declare Function SendMessageByString Lib "user32.dll" Alias "SendMessageA" _
(ByVal hWnd As IntPtr, _
ByVal uMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As StringBuilder) As Int32
Private Const WM_GETTEXT As Int32 = &HD
Private Const WM_GETTEXTLENGTH As Int32 = &HE
Public Function GetText(ByVal hwnd As IntPtr) As String
If (Not hwnd.Equals(IntPtr.Zero)) Then
Dim NumberOfCharacters As Int32 = SendMessageByInt(hwnd, WM_GETTEXTLENGTH, 0, 0)
If NumberOfCharacters > 0 Then
Dim ptText As New StringBuilder(NumberOfCharacters)
Dim Result As Int32 = SendMessageByString(hwnd, WM_GETTEXT, NumberOfCharacters + 1, ptText)
If Result <> 0 Then
Return ptText.ToString()
Else
Return String.Empty
End If
End If
Else
MessageBox.Show("Fehler in der Verarbeitung: IntPtr!", "Info")
End If
End Function
End Module