Autor Tema: ucDateTime KeyPress y backcolor  (Leído 3252 veces)

0 Usuarios y 1 Visitante están viendo este tema.

FrankLizardo

  • Kilobyte
  • **
  • Mensajes: 65
  • Reputación: +7/-1
    • Ver Perfil
ucDateTime KeyPress y backcolor
« 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

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:ucDateTime KeyPress y backcolor
« Respuesta #1 en: Febrero 28, 2011, 04:51:51 pm »
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.

FrankLizardo

  • Kilobyte
  • **
  • Mensajes: 65
  • Reputación: +7/-1
    • Ver Perfil
Re:ucDateTime KeyPress y backcolor
« Respuesta #2 en: Marzo 02, 2011, 12:02:18 pm »
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

raul338

  • Terabyte
  • *****
  • Mensajes: 894
  • Reputación: +62/-8
  • xD fan!!!!! xD
    • Ver Perfil
    • Raul's Weblog
Re:ucDateTime KeyPress y backcolor
« Respuesta #3 en: Marzo 02, 2011, 02:02:40 pm »
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
Código: (vb) [Seleccionar]
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 :

Código: (vb) [Seleccionar]
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)

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:ucDateTime KeyPress y backcolor
« Respuesta #4 en: Marzo 02, 2011, 03:37:53 pm »
Gracias Raul por el tips luego lo agrego. Saludos.

FrankLizardo

  • Kilobyte
  • **
  • Mensajes: 65
  • Reputación: +7/-1
    • Ver Perfil
Re:ucDateTime KeyPress y backcolor
« Respuesta #5 en: Marzo 08, 2011, 12:28:40 pm »
leandro que sera de los cambios del backcolor y KeyPress en el control por fa

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:ucDateTime KeyPress y backcolor
« Respuesta #6 en: Marzo 08, 2011, 02:03:29 pm »
Hola, le agregue el keypress que paso Raul, descargalo y probalo haber si te sirve.

Saludos.