Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: FrankLizardo en Febrero 28, 2011, 01:08:23 pm
-
cono poner al ucDateTime el evento KeyPress, cuando presione enter deje el foco y backcolor cambie a otro color
-
Hola descargalo de nuevo le puse la propiedad TextBackColor, los cambios son visibles solo en tiempo de ejecución
creo que lo que vos queres es que cambien el color cuando toma y pierde el foco no?
Saludos.
-
excelente leandro solo una cosa mas quiero poner el evento keypress en el objeto cosa que si presiono enter u otra tecla pase el foco a otro objeto
-
Para los eventos KeyPress, KeyDown y KeyUp se tienen que hookear los mensajes WM_CHAR, WM_KEYDOWN y WM_KEYUP respectivamente del handle del control (mhwnd).
Yo cambie la ultima parte del subclassing por esto
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public Event KeyPress(KeyAscii As Integer)
Public Event KeyUp(KeyCode As Integer, Shift As Integer)
'...........................
' siendo que el hwnd hokeado = mhwnd
Select Case uMsg
Case WM_ERASEBKGND
Dim Rec As RECT
Call GetClientRect(hwnd, Rec)
Call FillRect(wParam, Rec, hBrush)
bHandled = True
Case WM_KEYDOWN
RaiseEvent KeyDown(wParam And &H7FFF&, pvShiftState())
Case WM_CHAR
RaiseEvent KeyPress(wParam And &H7FFF&)
Case WM_KEYUP
RaiseEvent KeyUp(wParam And &H7FFF&, pvShiftState())
End Select
' .....................
' Codigo del ucListView de Carles P.V.
Private Function pvShiftState() As Integer
Dim lS As Integer
If (GetAsyncKeyState(vbKeyShift) < 0) Then lS = lS Or vbShiftMask
If (GetAsyncKeyState(vbKeyMenu) < 0) Then lS = lS Or vbAltMask
If (GetAsyncKeyState(vbKeyControl) < 0) Then lS = lS Or vbCtrlMask
pvShiftState = lS
End Function
Y listo :P No subo el uc porque tambien quise tocar cosas con el back color y al final lo termine arruinando ::)
Por cierto, el backcolor no funciona en Windows 7
segun el MSDN: "When visual styles are enabled, DTM_SETMCCOLOR has no effect except when iColor is MCSC_BACKGROUND."...
Ademas, yo agregaria esto :
Private Const DTM_GETIDEALSIZE As Long = (DTM_FIRST + 15)
Public Property Get GetIdealHeight() As Long
If mhwnd Then
Dim pt As POINTAPI
Call SendMessage(mhwnd, DTM_GETIDEALSIZE, 0, pt)
GetIdealHeight = ScaleY(pt.Y, vbPixels, ScaleMode)
End If
End Property
Public Property Get GetIdealWith() As Long
If mhwnd Then
Dim pt As POINTAPI
Call SendMessage(mhwnd, DTM_GETIDEALSIZE, 0, pt)
GetIdealWith = ScaleX(pt.X, vbPixels, ScaleMode)
End If
End Property
Saludos!
Haber si lo haces leandro, porque yo tengo que editar un par de cosas mas :P 8)
-
Gracias Raul por el tips luego lo agrego. Saludos.
-
leandro que sera de los cambios del backcolor y KeyPress en el control por fa
-
Hola, le agregue el keypress que paso Raul, descargalo y probalo haber si te sirve.
Saludos.