Attribute VB_Name = "modDialog" '============================================================================== ' ' File : Dialog.bas ' Date : 11.02.1999 ' Version: 1.00 ' Author : Andreas Schmidt, lindner&partner ' '============================================================================== ' ' *shared* ' ' Funktionen zur Arbeit mit Dialogen ' '============================================================================== ' ' History: ' ' Date : 11.02.1999 ' Version: 1.00 ' Author : Andreas Schmidt, lindner&partner ' ' Erste Version. ' '============================================================================== Option Explicit ' Standard dialog button IDs ' -------------------------- Global Const IDOK = 1 Global Const IDCANCEL = 2 Global Const IDABORT = 3 Global Const IDRETRY = 4 Global Const IDIGNORE = 5 Global Const IDYES = 6 Global Const IDNO = 7 ' Dialog modal zur Anzeige bringen. ' ' @param frm anzuzeigender Dialog ' ' @return IDOK = Dialog wurde mit OK beendet, ' IDCANCEL = Dialog wurde mit CANCEL beendet, ' IDABORT = Fehler bei der Initialisierung des Dialogs ' Public Function doModal(frm As Form, Optional bCenterForm) As Integer If IsMissing(bCenterForm) Then bCenterForm = False If bCenterForm Then Call centerFormInScreen(frm) On Error GoTo doModalErr frm.Show vbModal doModalErr: doModal = frm.getExitCode() End Function Public Function doNonModal(frm As Form, Optional bCenterForm As Boolean) If IsMissing(bCenterForm) Then bCenterForm = False If bCenterForm Then Call centerFormInScreen(frm) frm.Show frm.Visible = True If Left(frm.Caption, Len("Pruef2000")) <> "Pruef2000" Then frm.Caption = "Pruef2000 (" & frm.Name & ") " & App.EXEName & " Version " & App.Major & "." & App.Minor & "." & App.Revision End If doNonModalErr: End Function Public Sub centerFormInScreen(frm As Form) If frm.WindowState = 0 Then frm.Top = (Screen.Height - frm.Height) \ 2 frm.Left = (Screen.Width - frm.Width) \ 2 End If End Sub Public Sub centerFormInWindow(frm As Form, frmParent As Form) frm.Top = frmParent.Top + (frmParent.Height - frm.Height) \ 2 frm.Left = frmParent.Left + (frmParent.Width - frm.Width) \ 2 End Sub ' Control in Parent-Container zentrieren ' Public Sub centerControlInParent(child As Control, parent As Control) child.Top = (parent.Height - child.Height) \ 2 child.Left = (parent.Width - child.Width) \ 2 End Sub Public Function TwipsPerPixelX(nPixel) As Integer TwipsPerPixelX = nPixel * Screen.TwipsPerPixelX End Function Public Function TwipsPerPixelY(nPixel) As Integer TwipsPerPixelY = nPixel * Screen.TwipsPerPixelY End Function Public Function PixelPerTwipsX(nTwips) As Integer PixelPerTwipsX = nTwips / Screen.TwipsPerPixelX End Function Public Function PixelPerTwipsY(nTwips) As Integer PixelPerTwipsY = nTwips / Screen.TwipsPerPixelY End Function