Results 1 to 4 of 4

Thread: MsgBox Problem

  1. #1

    Thread Starter
    Addicted Member icemanmt78's Avatar
    Join Date
    May 2000
    Posts
    142

    Unhappy


    I have some q's about Message Boxes

    Can you get a mmsbox appearing any bigger on the screen?
    Can you get the msgBox producing a sound when it appears?

    And can you change the colour of a message box

    Help

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    I don't know about message box but you can design your own form to do all that including the sound and use it like this

    frmmsgbox.show 1
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  3. #3
    Guest
    Try this.

    Code for a Module
    Code:
    Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
    Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LOGBRUSH) As Long
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
    Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
    Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
    Public Const GWL_WNDPROC = (-4)
    Public Const WH_CALLWNDPROC = 4
    Public Const WM_CREATE = &H1
    Public Const WM_CTLCOLORBTN = &H135
    Public Const WM_CTLCOLORDLG = &H136
    Public Const WM_CTLCOLORSTATIC = &H138
    Public Const WM_DESTROY = &H2
    Public lPrevWnd As Long
    Public lHook As Long
    Public MSGBOX_BACKCOLOR As Long
    Public MSGBOX_FORECOLOR As Long
    Type LOGBRUSH
            lbStyle As Long
            lbColor As Long
            lbHatch As Long
    End Type
    Type CWPSTRUCT
            lParam As Long
            wParam As Long
            message As Long
            hwnd As Long
    End Type
    
    Public Function SubMsgBox(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim tLB As LOGBRUSH
        Select Case Msg
        Case WM_CTLCOLORDLG, WM_CTLCOLORSTATIC, WM_CTLCOLORBTN
            Call SetTextColor(wParam, MSGBOX_FORECOLOR)
            Call SetBkColor(wParam, MSGBOX_BACKCOLOR)
            tLB.lbColor = MSGBOX_BACKCOLOR
            SubMsgBox = CreateBrushIndirect(tLB)
            Exit Function
        Case WM_DESTROY
            Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWnd)
        End Select
        SubMsgBox = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, ByVal lParam)
    End Function
    
    Public Function HookWindow(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim tCWP As CWPSTRUCT
        Dim sClass As String
        CopyMemory tCWP, ByVal lParam, Len(tCWP)
        If tCWP.message = WM_CREATE Then
            sClass = Space(255)
            sClass = Left(sClass, GetClassName(tCWP.hwnd, ByVal sClass, 255))
            If sClass = "#32770" Then
                lPrevWnd = SetWindowLong(tCWP.hwnd, GWL_WNDPROC, AddressOf SubMsgBox)
            End If
        End If
        HookWindow = CallNextHookEx(lHook, nCode, wParam, ByVal lParam)
    End Function
    Code for Form with a Commandbutton
    Code:
    Private Sub Command1_Click()
        MsgBox "MessageBox", vbYesNo + vbInformation, "MsgBox"
    End Sub
    Private Sub Form_Load()
        'BackColor for MsgBox
        MSGBOX_BACKCOLOR = vbBlue
        lHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf HookWindow, App.hInstance, App.ThreadID)
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        Call UnhookWindowsHookEx(lHook)
    End Sub

  4. #4
    New Member
    Join Date
    Jul 2000
    Location
    China,Shandong,Jinan
    Posts
    5

    thx for your code

    then i find that cann't change the button in msgbox .
    how to change it to polychrome button?
    faint.... so many api......
    Forgive my poor English;
    Forgive my poor VB knowledge;
    Forgive my lazy;
    Forgive my stupidity;
    I need your help;
    And i need your friendship.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width