Bueno ando con un rollo en el vb6 y es que ando creando un UC ( ya tiene mucho que llevo con esto pero no he tenido mucho tiempo para terminarlo ), mi problema es que en el UC resivo los mensajes con GetMessage y los dejo fluir con DispatchMessage pero he aqui el problema en DispatchMessage cundo termino el form donde tengo el UC se queda todo el programa en dicha linea y por esta linea no se puede cerrar el programa o form en cuestion.
En pocas palabras una alternativa a estas apis cual seria?, las he usado por que estas no me traban de forma innesesaria el programa, en cambio PeekMessage tengo que hacer un Bucle pero este a diferencia de las otras dos apis se le escapan mensajes, por ende no me sirve ademas que tengo que ponerle doevents y cosillas dentro del bucle para que no se coma el procesador.
Este es el codigo, lo programe para que dejara de procesar mensajes si le llegan los mensajes WM_CLOSE o WM_DESTROY, pero esto no me gusta mucho que digamos.
Código
' // // // // // // // // // // // // // // // // // // // // ' // El Objetivo de este proceso es que el Control de Usuario sea Maleable, ' // de igual forma por que lo pienso pasar a C++ y esto me ayudara despues, ' // se que aqui no se tratan los mensajes si no mas bien en el Callback ' // WindProc() pero bueno, es solo una obtativa para vb6 de forma cutre ' // // // // // // // // // // // // // // // // // // // // ' // ---------------------------------------------------------------------- // ' // // // // // // // // // // // // // // // // // // // // ' // No es la manera mas Ortodoxa pero asi me evito usar TODO el Procesador... ' // // // // // // // // // // // // // // // // // // // // Private Sub ProcessMessages() Dim vMsg As Msg Dim bool_MsgCancel As Boolean Dim Button As Integer Dim tPoint As POINTAPI Dim Shift As Integer bool_MsgCancel = False Do While GetMessage(vMsg, 0, 0, 0) And bool_MsgCancel = False If vMsg.hwnd = UserControl.hwnd Or _ vMsg.hwnd = VS.hwnd Or _ vMsg.hwnd = HS.hwnd Then Select Case vMsg.message ' // Mensajes del Mouse Case WM.WM_MOUSEWHEEL, WM.WM_MOUSEMOVE, _ WM.WM_LBUTTONDBLCLK, WM.WM_LBUTTONDOWN, WM.WM_LBUTTONUP, _ WM.WM_RBUTTONDBLCLK, WM.WM_RBUTTONDOWN, WM.WM_RBUTTONUP, _ WM.WM_MBUTTONDBLCLK, WM.WM_MBUTTONDOWN, WM.WM_MBUTTONUP tPoint = GetCursorRegion If vMsg.wParam = MK.MK_CONTROL Then Shift = 2 ElseIf vMsg.wParam = MK.MK_SHIFT Then Shift = 1 Else Shift = 0 End If Select Case vMsg.message Case WM.WM_MOUSEWHEEL Debug.Print "WM_MOUSEWHEEL" If vMsg.wParam < 0 Then If (DatosScrollGhost(1).Visible Or VS.Visible) Then Scroll_V = Priv_SV + int_hRow End If Else If (DatosScrollGhost(0).Visible Or VS.Visible) Then Scroll_V = Priv_SV - int_hRow End If End If Case WM.WM_LBUTTONDBLCLK Debug.Print "WM_LBUTTONDBLCLK" Call lvDblClick Case WM.WM_RBUTTONDBLCLK Debug.Print "WM_RBUTTONDBLCLK" Call lvDblClick Case WM.WM_MBUTTONDBLCLK Debug.Print "WM_MBUTTONDBLCLK" Call lvDblClick Case WM.WM_LBUTTONDOWN Debug.Print "WM_LBUTTONDOWN" Button = 1 Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y) Case WM.WM_RBUTTONDOWN Debug.Print "WM_RBUTTONDOWN" Button = 2 Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y) Case WM.WM_MBUTTONDOWN Debug.Print "WM_MBUTTONDOWN" Button = 4 Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y) Case WM.WM_LBUTTONUP, WM.WM_RBUTTONUP, WM.WM_MBUTTONUP Debug.Print "WM_LBUTTONUP" Call lvMouseUp(Button, Shift, tPoint.X, tPoint.Y) Call lvClick Button = 0 Case WM.WM_MOUSEMOVE Debug.Print "WM_MOUSEMOVE" Call lvMouseMove(Button, Shift, tPoint.X, tPoint.Y) End Select ' // Teclas Pulsadas... Case WM.WM_KEYDOWN Debug.Print "WM_KEYDOWN", vMsg.wParam Select Case vMsg.wParam Case VK.VK_UP If DatosScrollGhost(0).Visible Or VS.Visible Then Scroll_V = Priv_SV - int_hRow 'Priv_SV - int_hRow End If Case VK.VK_Down If DatosScrollGhost(1).Visible Or VS.Visible Then Scroll_V = Priv_SV + int_hRow 'Priv_SV + int_hRow End If Case VK.VK_Left If DatosScrollGhost(3).Visible Or HS.Visible Then Scroll_H = Priv_SH - 20 'Priv_SH - 20 End If Case VK.VK_RIGHT If DatosScrollGhost(3).Visible Or HS.Visible Then Scroll_H = Priv_SH + 20 'Priv_SH + 20 End If Case VK.VK_HOME Scroll_V = 0 Case VK.VK_END If RowVisibleCount < CantRows Then Scroll_V = (CantRows * int_hRow) - (RectLista.Bottom - RectLista.Top) End If Case VK.VK_SHIFT cAoDSS = True Shift = 1 Case VK.VK_CONTROL cAoDSC = True Shift = 2 Case VK.VK_PRIOR Scroll_V = Priv_SV - RowVisibleCount * int_hRow Case VK.VK_NEXT Scroll_V = Priv_SV + RowVisibleCount * int_hRow End Select RaiseEvent KeyDown(Int(vMsg.wParam), Shift) Case WM.WM_KEYUP Debug.Print "WM_KEYUP", vMsg.wParam Select Case vMsg.wParam Case VK.VK_SHIFT cAoDSS = False Shift = 0 Case VK.VK_CONTROL cAoDSC = False Shift = 0 End Select RaiseEvent KeyUp(Int(vMsg.wParam), Shift) RaiseEvent KeyPress(Int(vMsg.wParam)) ' // Mesajes de la Ventana Case WM.WM_ACTIVATE Debug.Print "WM_ACTIVATE" Case WM.WM_CLOSE, WM.WM_DESTROY Debug.Print "WM_CLOSE", "WM_DESTROY" bool_MsgCancel = True Exit Sub Case WM.WM_PAINT If vMsg.wParam = 0 Then Call Refresh Else Call RefreshCols(vMsg.lparam) End If Case WM.WM_ENABLE 'wParam ' Indicates whether the window has been enabled or disabled. This parameter is TRUE if the window has been enabled or FALSE if the window has been disabled. 'lparam ' This parameter is not used. Debug.Print "WM_ENABLE" Case Else End Select End If Call DispatchMessage(vMsg) 'Call WaitMessage Loop End Sub
P.D.: Que no sea por subclasificación... aun que si no tengo otra opcion...
Temibles Lunas!¡.