Dialog positionieren

SetWindowPos, FindWindow
Declare Function SetWindowPos Lib "User" (ByVal hwnd%, ByVal _
  hwndAfter%, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal _
  Flags%) As Integer
Declare Function FindWindow Lib "User" (ByVal szClass$, ByVal szTitle$) As Integer
Const SWP_NOSIZE = 1
Const SWP_NOMOVE = 2
Const SWP_NOZORDER = 4
Const SWP_NOREDRAW = 8
Const SWP_NOACTIVATE = &h10
Sub ShowDialogboxByPos(ByVal x%, ByVal y%)
Dim hwndDlg As Integer
hwndDlg = FindWindow("bosa_sdm_XL", ActiveDialog.DialogFrame.Text)
If hwndDlg <> 0 Then
  SetWindowPos hwndDlg, 0, x%, y%, 0, 0, SWP_NOSIZE + SWP_NOACTIVATE + SWP_NOZORDER
End If
End Sub 'ShowDialogboxByPos
Sub CentreDialog32()
On Error Resume Next
'*** DIMENSION VARIABLES ***
Dim V_rect As Rect32
'Variables to retrieve the screen dimensions with GetSystemMetrics API.
Dim V_scrn_w As Long
Dim V_scrn_h As Long
'Variable to store the window handle with FindWindow API.
Dim V_hwnd As Long
'Variables to calculate the new dimensions for the window.
Dim V_width As Long
Dim V_height As Long
Dim V_left As Long
Dim V_top As Long
'Get the handle of the dialog box window - 'bosa_sdm_XL' is the class name
'for an Excel dialog box.
V_hwnd = FindWindow32("bosa_sdm_XL", ActiveDialog.DialogFrame.Text)
'Only continue if a valid handle is returned
If V_hwnd <> 0 Then
'Get the width and height of the screen in pixels
  V_scrn_w = GetSystemMetrics32(0)
  V_scrn_h = GetSystemMetrics32(1)
'Get the dimensions of the dialog box window in pixels
  GetWindowRect32 V_hwnd, V_rect
'Calculate the width and height of the dialog box
  V_width = Abs(V_rect.Right - V_rect.Left)
  V_height = Abs(V_rect.Top - V_rect.Bottom)
'Calculate the new position of the dialog box in pixels
  V_left = (V_scrn_w - V_width) / 2
  V_top = (V_scrn_h - V_height) / 2
'Move the dialog box to the centre of the screen
  Movewindow32 V_hwnd, V_left, V_top, V_width, V_height, True
End If
End Sub
Sub ShowDialog()
  ThisWorkbook.DialogSheets("Dialog1").Show
End Sub

 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info