Jump to content

The invisibility of the control on the second monitor


 Share

Recommended Posts

The message is displayed using the ToolTip property is displayed only on the first monitor when using dual monitor or network projector (it also can not see message ). It is necessary to ensure that such properties can be assigned to Edit control or window.

It would be grateful if someone tell me how to do it!

Edited by AndreyS
Link to comment
Share on other sites

What mechanism are you using to display the tooltip?

The Tooltip func can specify x,y co-ordinates. You could use WinGetPos to associate the tooltip to the same screen as the application window.

Link to comment
Share on other sites

The simplest mechanism! I call this function as follows:

ToolTip ("MyMessage", Default, Default, "TitleMessage", 0, 5)

As a result, the first screen is displayed tooltip, and on the second monitor/projector is not displayed.

I need to do so that I could hide as any control or window on the second monitor/projector.

How do I do?

Thank you for your attention!

Edited by AndreyS
Link to comment
Share on other sites

I forgot dealing with dual monitors can be a little tricky, so I had to seek outside help. I borrowed from and genned up this simple script to find the center of a screen. Feed it an X & Y and it will return the center of the screen. This example takes the current mouse location and then moves the mouse to the center the of the screen. You should be able to modify it to suit your needs.

edit: It's far from perfect, like if you have you screens aligned non-linear (ie. diagonal or some weird layout) it's unreliable but works fine for simple (non-complex) layouts.

$mousepos = MouseGetPos()
$pos = _CenterScreen($mousepos[0],$mousepos[1])
MouseMove($pos[0],$pos[1])

Func _CenterScreen($xTest=0, $yTest=0)
    Local $center[2]
    $displays = _DisplayKeySettings(_NumberAndNameMonitors())
    $int = $displays[0][0]
    Do
        If $displays[$int][4] Then
            If $xTest >= $displays[$int][2] And Not $center[0] Then $center[0] = $int
        EndIf
        $int -= 1
    Until $int<0
    $int = $displays[0][0]
    Do
        If $displays[$int][4] Then
            if $yTest >= $displays[$int][3] And Not $center[1] Then $center[1] = $int
        EndIf
        $int -= 1
    Until $int<0
    $center[0] = Round($displays[$center[0]][2]+$displays[$center[0]][4]/2)
    $center[1] = Round($displays[$center[1]][3]+$displays[$center[1]][5]/2)
    Return $center
EndFunc

;============================================================================================== _NumberAndNameMonitors
; Function Name:       _NumberAndNameMonitors ()
; Description:       Provides the first key elements of a multimonitor system, included the Regedit Keys
; Parameter(s):      None
; Return Value(s):    $NumberAndName [][]
;~                                   [0][0] total number of video devices
;;                                  [x][1] name of the device
;;                                  [x][2] name of the adapter
;;                                  [x][3] monitor flags (value is returned in Hex str -convert in DEC before use with Bitand)
;;                                  [x][4] registry key of the device
; Remarks:          the flag value [x][3] can be one of the following
;;                                  DISPLAY_DEVICE_ATTACHED_TO_DESKTOP   0x00000001
;;                                     DISPLAY_DEVICE_MULTI_DRIVER          0x00000002
;;                                 DISPLAY_DEVICE_PRIMARY_DEVICE          0x00000004
;;                                 DISPLAY_DEVICE_VGA                    0x00000010
;;                                   DISPLAY_MIRROR_DEVICE               0X00000008
;;                                   DISPLAY_REMOVABLE                  0X00000020
;
; Author(s):        Hermano
;===========================================================================================================================
Func _NumberAndNameMonitors()
    Local $dev = -1, $id = 0, $msg_ = "", $EnumDisplays, $StateFlag
    Dim $NumberAndName[2][6]
    Local $DISPLAY_DEVICE = DllStructCreate("int;char[32];char[128];int;char[128];char[128]")
    DllStructSetData($DISPLAY_DEVICE, 1, DllStructGetSize($DISPLAY_DEVICE))
    Dim $dll = "user32.dll"
    Do
        $dev += 1
        $EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", "ptr", 0, "int", $dev, "ptr", DllStructGetPtr($DISPLAY_DEVICE), "int", 1)
        If $EnumDisplays[0] <> 0 Then
            ReDim $NumberAndName[$dev + 2][6]
            $NumberAndName[$dev + 1][1] = DllStructGetData($DISPLAY_DEVICE, 2)   ;device Name
            $NumberAndName[$dev + 1][2] = DllStructGetData($DISPLAY_DEVICE, 3)   ;device or display description
            $NumberAndName[$dev + 1][3] = Hex(DllStructGetData($DISPLAY_DEVICE, 4))  ;all flags (value in HEX)
            $NumberAndName[$dev + 1][4] = DllStructGetData($DISPLAY_DEVICE, 6)   ;registry key of the device
            $NumberAndName[$dev + 1][5] = DllStructGetData($DISPLAY_DEVICE, 5)   ;hardware interface name
        EndIf
    Until $EnumDisplays[0] = 0
    $NumberAndName[0][0] += $dev
    Return $NumberAndName
EndFunc   ;==>_NumberAndNameMonitors
;============================================================================================== _DisplayKeySettings
; Function Name:       _DisplayKeySettings($MonName,$Opt = -1)
; Description:       all key information about each adapter needed to properly change the display setting
; Parameter(s):      $MonName    =    return array from _NumberAndNameMonitors
;;                   $Opt       = -1  $ENUM_CURRENT_SETTINGS [default]
;;                              = -2  $ENUM_REGISTRY_SETTINGS
; Return Value(s):    $KeySettings[][]
;;                                      $KeySettings[0][0] =     Number of non virtual devices
;;                                      $KeySettings[x][0] =     Flags
;;                                      $KeySettings[x][1] =     Monitor Name
;;                                      $KeySettings[x][2] =    up left desktop position X
;;                                      $KeySettings[x][3] =    up left desktop position Y
;;                                      $KeySettings[x][4] =    Width (resolution)
;;                                      $KeySettings[x][5] =    Heigth (resolution)
;;                                      $KeySettings[x][6] =    Bpp color (resolution)
;;                                      $KeySettings[x][7] =    Screen Refresh(resolution)
;;                                      $KeySettings[x][8] =    Display Orientation
;;                                      $KeySettings[x][9] =    Display Fixed Output
; Remarks:
;
; Author(s):        Hermano
;===========================================================================================================================
Func _DisplayKeySettings($MonName, $Opt = -1)
    Local Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008
    Dim $KeySettings[1][10], $i, $Dn = 0, $res

    If Not IsArray($MonName) Then $MonName = _NumberAndNameMonitors()
    Local $DEVMODE = DllStructCreate("char[32];short[4];int[5];short[5];byte[32];short;int[6]")
    DllStructSetData($DEVMODE, 2, DllStructGetSize($DEVMODE), 3)

    For $i = 1 To $MonName[0][0]
        If ($MonName[$i][3] <> $DISPLAY_DEVICE_MIRRORING_DRIVER) Then
            $Dn += 1
            $res = DllCall("user32.dll", "int", "EnumDisplaySettings", "str", $MonName[$i][1], "int", $Opt, "ptr", DllStructGetPtr($DEVMODE))
            If $res[0] = 0 Then _
                    $res = DllCall("user32.dll", "int", "EnumDisplaySettings", "str", $MonName[$i][1], "int", Mod($Opt, 2) - 1, "ptr", DllStructGetPtr($DEVMODE))

            ReDim $KeySettings[1 + $Dn][10]
            $KeySettings[$Dn][0] = $MonName[$i][3]   ;flags
            $KeySettings[$Dn][1] = $MonName[$i][1]   ;name
            $KeySettings[$Dn][2] = DllStructGetData($DEVMODE, 3, 2)  ;up left desktop position coord X
            $KeySettings[$Dn][3] = DllStructGetData($DEVMODE, 3, 3)  ;up left desktop position coord Y
            $KeySettings[$Dn][4] = DllStructGetData($DEVMODE, 7, 2)  ;Width (resolution)
            $KeySettings[$Dn][5] = DllStructGetData($DEVMODE, 7, 3)  ;Heigth (resolution)
            $KeySettings[$Dn][6] = DllStructGetData($DEVMODE, 7, 1)  ;Bpp color (resolution)
            $KeySettings[$Dn][7] = DllStructGetData($DEVMODE, 7, 5)  ;Screen Refresh(resolution)
            $KeySettings[$Dn][8] = DllStructGetData($DEVMODE, 3, 4)  ;Display Orientation
            $KeySettings[$Dn][9] = DllStructGetData($DEVMODE, 3, 5)  ;fixed output
        EndIf
    Next
    $KeySettings[0][0] = $Dn
    Return $KeySettings
EndFunc
Edited by spudw2k
Link to comment
Share on other sites

Or I put it right or you did not understand me. :oops:

I need to make sure that the program window, or some control was seen only on the first monitor, but on the second monitor was not visible!

Do you understand now?

Element ToolTip default has these properties!

How do I set these properties window or any control?

Link to comment
Share on other sites

no, I guess I don't understand you.

I need to make sure that the program window, or some control was seen only on the first monitor, but on the second monitor was not visible!

This sentence seems contradictory.

Do you want the tooltip displayed on the primary or secondary monitor?

I am also confused to what you are referring to as properties.

A property (typically) is named variable that stores a value, sometimes static, sometimes dynamic.

A method or function is a named command that performs an action.

Edited by spudw2k
Link to comment
Share on other sites

Sorry for my english please! :oops:

I want a window or any separate control of this window to appear only on the primary monitor (second monitor/projector mode when the image is duplicated on the primary monitor).

Just as a tooltip displays the called function ToolTip.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...