You can use a few APIs for this.

In a Module, (No Forms in this Project)..
Code:
Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Sub Main()
    Dim lHwnd As Long
    Dim sBuff As String * 255
    Dim tPOINT As POINTAPI
    Dim tRECT As RECT
    Do
        'Wait for a Right Click Anywhere in the O/S
        While GetAsyncKeyState(vbRightButton) = 0
            DoEvents
        Wend
        'Get the Cursor,(Mouse), Position
        Call GetCursorPos(tPOINT)
        'Get the Window Handle the Mouse is Over
        lHwnd = WindowFromPoint(tPOINT.x, tPOINT.y)
        'Get the Windows Dimensions
        Call GetWindowRect(lHwnd, tRECT)
        If tPOINT.y < tRECT.Top + 27 Then
            'See if the Right Click Occurred in the Caption Area, (1st 27 Pixels)
            Debug.Print "Right Click in Caption of " & Left(sBuff, GetWindowText(lHwnd, ByVal sBuff, 255))
        End If
        'Wait for Right Button to be released
        While GetAsyncKeyState(vbRightButton)
        Wend
    Loop
End Sub

------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]