elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Ayuda en una función
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda en una función  (Leído 1,225 veces)
karmany
Colaborador
***
Desconectado Desconectado

Mensajes: 1.614


Sueñas que sueñas


Ver Perfil WWW
Ayuda en una función
« en: 6 Febrero 2006, 00:14 am »

He encontrado una forma de interceptar el menú que sale cuando pulsamos con el botón derecho por ej. en un textbox.
El problema es que hay una función que no entiendo lo que hace, ¿me podéis ayudar?

Hay un formulario con un Textbox, un Command y un módulo.
El código es el siguiente:
En el formulario:
Código:
Option Explicit
Private mbCapturado As Boolean
Private Sub Command1_Click()
   If Not mbCapturado Then
        gHW = Text1.hWnd
        Activa
        mbCapturado = True
   Else
        mbCapturado = False
        Desactiva
        gHW = 0
   End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If mbCapturado Then Desactiva
End Sub

En el módulo esto:
Código:
Option Explicit

Public Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Public 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

Public Const GWL_WNDPROC = (-4)

Public Const WM_CONTEXTMENU = &H7B

Global lpPrevWndProc As Long
Global gHW As Long

Public Sub Activa()
    lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
    AddressOf gWindowProc)
End Sub

Public Sub Desactiva()
  Dim temp As Long
    temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Public Function gWindowProc(ByVal hWnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
    If Msg = WM_CONTEXTMENU Then
        Debug.Print "Interceptado  WM_CONTEXTMENU ( " & Now & ")"
        gWindowProc = True
    Else ' Send all other messages to the default message handler
        gWindowProc = CallWindowProc(lpPrevWndProc, hWnd, Msg, wParam, _
                    lParam)
    End If
End Function

La función que no entiendo es Function gWindowProc. No sé lo que hace. ¿Es de windows? ¿Es predefinida?
En la primera sentencia if, hace: gWindowProc = True. Viendo esto yo he puesto directamente (dentro de Activa): lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, True), pero se "cuelga" el VB.

Alguien q tenga conocimientos me lo puede explicar un poco??
Muchas gracias.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ayuda con una funcion en c
Programación C/C++
swagger14 7 3,055 Último mensaje 22 Octubre 2011, 15:51 pm
por rir3760
Ayuda con una funcion, por favor
Programación C/C++
jet1994 2 1,562 Último mensaje 24 Septiembre 2012, 02:36 am
por Don Pollo
Ayuda con funcion MprAdminPortDisconnect??
Programación Visual Basic
TrashAmbishion 2 2,003 Último mensaje 29 Octubre 2012, 14:52 pm
por TrashAmbishion
AYUDA CON FUNCION C++
Programación C/C++
DVD116 2 1,405 Último mensaje 25 Octubre 2018, 23:20 pm
por DVD116
Ayuda con función setw()
Programación C/C++
Pedro122h 3 3,433 Último mensaje 3 Diciembre 2021, 22:01 pm
por Pedro122h
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines