函数参考


_WinAPI_MonitorFromPoint

Retrieves a handle to the display monitor that contains a specified point.

#Include <WinAPIEx.au3>
_WinAPI_MonitorFromPoint ( $tPOINT [, $iFlag] )

参数

$tPOINT $tagPOINT structure that specifies the point of interest in virtual-screen coordinates.
$iFlag [可选参数] The flag that specifies the function's return value if the point is not contained within any display
monitor. This parameter can be one of the following values.

$MONITOR_DEFAULTTONEAREST
$MONITOR_DEFAULTTONULL
$MONITOR_DEFAULTTOPRIMARY

返回值

Success A handle to the display monitor that contains a specified point, or the value depends on the
$MONITOR_* constant.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

None

相关

详情参考

在MSDN中搜索


示例/演示


#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $hMonitor, $Data

$hMonitor = _WinAPI_MonitorFromPoint(_WinAPI_GetMousePos())
If @error Then
    Exit
EndIf

$Data = _WinAPI_GetMonitorInfo($hMonitor)
If IsArray($Data) Then
    ConsoleWrite('Handle:      ' & $hMonitor & @CR)
    ConsoleWrite('Rectangle:   ' & DllStructGetData($Data[0], 1) & ', ' & DllStructGetData($Data[0], 2) & ', ' & DllStructGetData($Data[0], 3) & ', ' & DllStructGetData($Data[0], 4) & @CR)
    ConsoleWrite('Work area:   ' & DllStructGetData($Data[1], 1) & ', ' & DllStructGetData($Data[1], 2) & ', ' & DllStructGetData($Data[1], 3) & ', ' & DllStructGetData($Data[1], 4) & @CR)
    ConsoleWrite('Primary:     ' & $Data[2] & @CR)
    ConsoleWrite('Device name: ' & $Data[3] & @CR)
EndIf