Underc0de - La Casa de los Informáticos

Programación General => Visual Basic => Códigos Fuentes => Mensaje iniciado por: ANTRAX en Julio 26, 2010, 03:52:43 PM

Título: Cambiar texto a botones de MsgBox
Publicado por: ANTRAX en Julio 26, 2010, 03:52:43 PM
Modulo:

Código (vb) [Seleccionar]
Public hHook As Long
Public Const WH_CALLWNDPROCRET = 12
Public Const GWL_HINSTANCE = (-6)
Private Type tagCWPRETSTRUCT
    lResult As Long
    lParam As Long
    wParam As Long
    message As Long
    hWnd As Long
End Type
Private Const WM_INITDIALOG = &H110
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Public 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
Private Declare Function UnhookWindowsHookEx Lib "user32" _
    (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" _
    (ByVal hHook As Long, ByVal nCode As Long, _
    ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (Destination As Any, Source As Any, ByVal Length As Long)
Private Const IDOK = 1
Private Const IDCANCEL = 2
Private Const IDABORT = 3
Private Const IDRETRY = 4
Private Const IDIGNORE = 5
Private Const IDYES = 6
Private Const IDNO = 7
Private Declare Function SetDlgItemText Lib "user32" Alias "SetDlgItemTextA" _
    (ByVal hDlg As Long, ByVal nIDDlgItem As Long, _
    ByVal lpString As String) As Long
Public Function CallWndRetProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim lr As Long
    Dim s As tagCWPRETSTRUCT
    lr = CallNextHookEx(hHook, nCode, wParam, lParam)
    If (nCode < 0) Then
        CallWndRetProc = lr
        Exit Function
    End If
    Call CopyMemory(s, ByVal lParam, Len(s))
    If (s.message = WM_INITDIALOG) Then
        Call SetDlgItemText(s.hWnd, IDYES, "Aprobar")
        Call SetDlgItemText(s.hWnd, IDNO, "Rechazar")
        UnhookWindowsHookEx hHook
        lr = 0&
    End If
    CallWndRetProc = lr
End Function


FORM:

Código (vb) [Seleccionar]
Dim hInst As Long
    Dim Thread As Long
    Dim i As Long
    hInst = GetWindowLong(Me.hWnd, GWL_HINSTANCE)
    Thread = GetCurrentThreadId()
    hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, AddressOf CallWndRetProc, hInst, Thread)
    i = MsgBox("Presiona en Aprobar o Rechazar.", vbYesNo)
    If i = vbYes Then
        Label1 = "Has presionado en Aprobar"
    ElseIf i = vbNo Then
        Label1 = "Has presionado en Rechazar"
    End If
Título: Re:Cambiar texto a botones de MsgBox
Publicado por: JOSE.HABANERO en Agosto 20, 2013, 07:34:21 PM
Hola, gracias por tu aporte.
Me da un error de compilacion en la linea hHook =    hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, AddressOf CallWndRetProc, hInst, Thread)
en concreto AddressOf CallWndRetProc (Error de compilacion, no coinciden los tipos)
Estoy con acces 2010 y windows 7 64 bits
Soy nuevo y estoy aprendiendo.
Gracias anticipadas.
Título: Re:Cambiar texto a botones de MsgBox
Publicado por: Danyfirex en Agosto 20, 2013, 10:52:45 PM
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Hola, gracias por tu aporte.
Me da un error de compilacion en la linea hHook =    hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, AddressOf CallWndRetProc, hInst, Thread)
en concreto AddressOf CallWndRetProc (Error de compilacion, no coinciden los tipos)
Estoy con acces 2010 y windows 7 64 bits
Soy nuevo y estoy aprendiendo.
Gracias anticipadas.
y acces que tendría que ver.

probado en windows Xp Visual Basic 6.0 y funciona perfecto.

saludos
Título: Re:Cambiar texto a botones de MsgBox
Publicado por: [L]ord [R]NA en Agosto 23, 2013, 01:23:19 PM
Erase una vez que hace unos años se escribio un post y el publico grito:  "Dejen de revivir Posts!!!"