Dialog Box Centering

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ckrows
    New Member
    • Jan 2008
    • 17

    Dialog Box Centering

    I am running a validation function and i call a msgbox at the end to let the user know their information was valid.
    The problem is that the words are left justified, besides adding spaces to the front of the msg box is there a better way to center the text?



    Code:
    Public Function ValidatePW(password As String, Username As String, DomainName As String) As Boolean
    ' Start by retrieving the user's name
    Dim lpBuffer As String, nSize As Long
    Dim rv As Long, usrName As String
    Dim hToken As Long
    
    ' Initialise an empty buffer, 10 characters long (long enough for most user names)
    lpBuffer = String(10, Chr(0))
    Do
        nSize = Len(lpBuffer)
        rv = Getusername(lpBuffer, nSize)
        If rv = 0 Then
            ' The function probably failed due to the buffer being too small
            ' nSize holds the required size
            lpBuffer = String(nSize, Chr(0)) ' Resize buffer to accomodate big name
        End If
    Loop Until rv <> 0
    ' Extract user name from buffer
    usrName = Left(lpBuffer, nSize - 1)
    
    If usrName <> Username Then
    
        MsgBox "Unable to login your user name is incorrect"
        
        Exit Function
    
    End If
    
    If Domain() <> DomainName Then
    
    
        MsgBox "Unable to login your user Domain name is incorrect"
        
        Exit Function
    
    End If
    
    ' Now validate the password
    rv = LogonUser(usrName, vbNullString, password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, hToken)
    If rv <> 0 Then
        ' Password validated successfully
        MsgBox "Your Password is valid"
        DoCmd.Close acForm, "frmLogin", acSaveNo
        DoCmd.OpenForm "frmRiskSwitch", acNormal
    Else
        ' Username and password failed validation
        MsgBox "Your Password is Invalid"
    End If
    End Function
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Not using a message box as such, no. You cannot customise the justification of a messagebox.

    If you need centred text your best bet is to design a custom pop-up message form in which your message is written to an Access textbox.

    Text displayed in textboxes can be set to left, centre or right aligned directly, removing the need to add spaces to the text.

    -Stewart

    Comment

    • ckrows
      New Member
      • Jan 2008
      • 17

      #3
      Thanks for the info!

      Comment

      Working...