2009-10-01 OpenFileDialog 時檢視縮圖 8565 0 VB.Net / C#.Net / 摘要:OpenFileDialog 時檢視縮圖 OpenFileDialog 時檢視縮圖 Call API Public Class Form1 ' 宣告 API Private Declare Function GetActiveWindow Lib "user32" () As Int32 Private Declare Function FindWindowExA Lib "user32" _ (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, _ ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32 Private Declare Function SendMessageA Lib "user32" _ (ByVal hwnd As Int32, ByVal wMsg As Int32, _ ByVal wParam As Int32, ByVal lParam As Int32) As Int32 Private WithEvents tmr As Timer ' 宣告 Timer Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Using ofd As New OpenFileDialog ofd.InitialDirectory = "D:\Photo\Gif" tmr = New Timer With {.Interval = 99} ' 建購物件並初始化 If chkThumbnail.Checked Then tmr.Start() ' 勾選檢視縮圖則啟動 Timer ofd.ShowDialog() End Using End Sub ' Timer 事件 Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick ' 取得 Dialog 視窗 handle Dim hwnd As Int32 = FindWindowExA(GetActiveWindow, 0, "SHELLDLL_DefView", vbNullString) If hwnd > 0 Then SendMessageA(hwnd, &H111, 28717, 0) ' 傳訊息 VIEW_THUMBNAIL tmr.Stop() ' 停止 Timer End If End Sub End Class OpenFileDialog檢視縮圖ThumbnailView 回首頁