Public Class Form1
:
Declare Function GetForegroundWindow Lib "user32" () As IntPtr
Declare Function SetForegroundWindow Lib "user32" (hWnd As IntPtr) As Boolean
Private Const WM_NCLBUTTONDOWN As Integer = &HA1
Private Const WM_NCLBUTTONUP As Integer = &HA0
Private m_hForegroundWnd As IntPtr = IntPtr.Zero
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCLBUTTONDOWN
If m_hForegroundWnd = IntPtr.Zero Then
m_hForegroundWnd = GetForegroundWindow
SetForegroundWindow(Me.Handle)
End If
Case WM_NCLBUTTONUP
If m_hForegroundWnd <> IntPtr.Zero Then
SetForegroundWindow(m_hForegroundWnd)
m_hForegroundWnd = IntPtr.Zero
End If
End Select
MyBase.WndProc(m)
End Sub
けどこれだと、前面にいたウィンドウが再フォーカスされることになるからどうかなぁ。例えばIE9のURL部分は一度フォーカス外して再フォーカスすると全選択になるし。
0 件のコメント:
コメントを投稿