Berechnet eine angemessene Pop-Up Fensterposition
#include <GuiMenu.au3>
_GUICtrlMenu_CalculatePopupWindowPosition ( $iX, $iY, $iWidth, $iHeight [, $iFlags = 0 [, $tExclude = 0]] )
$iX | Die X-Koordinate, in logischen Einheiten, des spezifizierten Ankerpunktes. |
$iY | Die Y-Koordinate, in logischen Einheiten, des spezifizierten Ankerpunktes. |
$iWidth | Die Breite, in logischen Einheiten, des spezifizierten Fensters. |
$iHeight | Die Höhe, in logischen Einheiten, des spezifizierten Fensters. |
$iFlags | [optional] Die Flags welche angeben wie die Funktion das Pop-Up-Fenster horizontal oder vertikal positioniert. $TPM_CENTERALIGN $TPM_LEFTALIGN (Standard) $TPM_RIGHTALIGN $TPM_BOTTOMALIGN $TPM_TOPALIGN (Standard) $TPM_VCENTERALIGN $TPM_HORIZONTAL (Standard) $TPM_VERTICAL $TPM_WORKAREA |
$tExclude | [optional] Die $tagRECT Struktur welche das Ausschließen-Rechteck beinhaltet. |
Erfolg: | Eine $tagRECT Struktur welche die Pop-Up Fensterposition beinhaltet. |
Fehler: | Setzt das @error Flag auf ungleich null. Es ist _WinAPI_GetLastError() aufzurufen um erweiterte Fehlerinformationen zu erhalten. |
Diese Funktion benötigt Windows 7 oder höher.
Suche nach CalculatePopupWindowPosition in der MSDN Bibliothek.
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIConv.au3>
#include <WinAPISysWin.au3>
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 500, 400)
Local $idButton = GUICtrlCreateButton('Neues Fenster', 145, 366, 110, 23)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton
_PopupDlg($hForm)
EndSwitch
WEnd
Func _PopupDlg($hParent)
GUISetState(@SW_DISABLE, $hParent)
Local $tPOINT = DllStructCreate($tagPOINT)
For $i = 1 To 2
DllStructSetData($tPOINT, $i, 0)
Next
_WinAPI_ClientToScreen($hParent, $tPOINT)
Local $hDlg = GUICreate('Neues Fenster', 400, 400)
Local $idButton = GUICtrlCreateButton('Schließen', 165, 366, 70, 23)
Local $tRECT = _GUICtrlMenu_CalculatePopupWindowPosition(DllStructGetData($tPOINT, 1), DllStructGetData($tPOINT, 2), _WinAPI_GetWindowWidth($hDlg), _WinAPI_GetWindowHeight($hDlg))
If @error Then
MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Fehler', 'Benötigt Windows 7 oder neuer.')
Exit
EndIf
WinMove($hDlg, '', DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2))
GUISetState(@SW_SHOW, $hDlg)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $idButton
ExitLoop
EndSwitch
WEnd
GUISetState(@SW_ENABLE, $hParent)
GUIDelete($hDlg)
EndFunc ;==>_PopupDlg