Problema VK_RETURN

Problema VK_RETURN

Postby manuramos » Fri Jul 28, 2006 8:11 pm

Tengo una clase llamada TFondo que es la clase TPanel con algunas modificaciones que me hacían falta para mi aplicación.

Es una clase que deriva directamente de TControl, pero no me deja controlar VK_RETURN ni desde ::KeyDown ni desde ::KeyChar. Algo estoy haciendo mal y no me doy cuenta :shock: , pues tengo otras clases derivadas de TControl que si me dejan analizar esa tecla.

¿Alguna idea?

Como el código es cortito, lo incluyo a continuación:

#include "FiveWin.ch"

#ifdef __XPP__
#define Super ::TControl
#define New _New
#endif

//----------------------------------------------------------------------------//

CLASS TFondo FROM TControl

CLASSDATA lRegistered AS LOGICAL

METHOD New( nTop, nLeft, nBottom, nRight, oWnd, nClrLetr, nClrFond, oCursor, lBorder, lTabStop ) CONSTRUCTOR

METHOD Paint()
METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint()
METHOD LButtonDown( nRow, nCol, nKeyFlags )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nTop, nLeft, nBottom, nRight, oWnd, nClrLetr, nClrFond, oCursor,lBorder, lTabStop ) CLASS TPanel

DEFAULT nTop := 0, nLeft := 0, nBottom := 100, nRight := 100,;
oWnd := GetWndDefault(), nClrLetr := 0, nClrFond := GetSysColor(COLOR_WINDOW ), lBorder := .F., lTabStop := .F. // Añadido

::nTop = nTop
::nLeft = nLeft
::nBottom = nBottom
::nRight = nRight
::oWnd = oWnd
::nStyle = nOr( WS_CHILD, WS_VISIBLE,IF(lBorder,WS_BORDER,0),IF(lTabStop,WS_TABSTOP,0) ) // esto ha variado respeto de TPanel
::lDrag = .f.

#ifdef __XPP__
DEFAULT ::lRegistered := .f.
#endif
*
::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
::SetColor(nClrLetr, nClrFond ) // AÑADIDO
*
IF ! Empty( ::oWnd:hWnd )
::Create("TFondo")
::lVisible = .T.
::oWnd:AddControl( Self )
ELSE
::lVisible = .F.
::oWnd:DefControl( Self )
ENDIF

IF oCursor # NIL // tambien añadido[
::oCursor := oCursor
SetCursor( ::oCursor:hCursor )
ENDIF

::lActive := .T.
::lDrag := .F.
::lCaptured := .F.
::lFocused := .F.

RETURN Self
*
METHOD Paint() CLASS TPanel
LOCAL nTop, nLeft, nHeight, nWidth, nBevel
*
IF ::oClient != NIL .AND. (nBevel := ::oClient:nClientBevel) > 0 // TODO ESTO EN ADELANTE ES DE TPanel
nBevel -= 1
nTop := nBevel
nLeft := nBevel
nHeight := ::nHeight - nBevel - 1
nWidth := ::nWidth - nBevel - 1
IF ::oTop != NIL
nTop += ::oTop:nHeight
ENDIF
IF ::oBottom != NIL
nHeight -= ::oBottom:nHeight
ENDIF
IF ::oLeft != NIL
nLeft += ::oLeft:nWidth
ENDIF
IF ::oRight != NIL
nWidth -= ::oRight:nWidth
ENDIF
WndBoxIn(::hDC, nTop, nLeft, nHeight, nWidth)
ENDIF
*
IF ::bPainted # NIL // ESTO ESTA AÑADIDO
Eval( ::bPainted, ::hDC )
ENDIF

RETURN NIL
*
METHOD LButtonDown( nRow, nCol, nKeyFlags ) CLASS TPanel // ESTO TAMBIEN ES NUEVO
IF ::bGotFocus # NIL
::SetFocus()
ENDIF
IF ::bLClicked != nil
RETURN Eval( ::bLClicked, nRow, nCol, nKeyFlags )
ENDIF
RETURN NIL
*

Gracias por adelantado
Nos Gusta Programar
manuramos
 
Posts: 219
Joined: Mon Dec 26, 2005 7:25 pm
Location: Jerez de la Frontera (Spain)

Postby manuramos » Sat Jul 29, 2006 11:20 am

Creo que encontré la solución. Añadiendo:

METHOD GetDlgCode(nLastKey) CLASS TFondo
IF .NOT. ::oWnd:lValidating
IF nLastKey == VK_RETURN // .OR. nLastKey == VK_TAB
::oWnd:nLastKey = nLastKey
ELSE
::oWnd:nLastKey = 0
ENDIF
ENDIF
RETURN IF( IsWindowEnabled( ::hWnd ), DLGC_WANTALLKEYS, 0 )

Me da acceso a controlar las pulsaciones de las teclas con KeyDown.

Pero alguien me prodría explicar para que sirve concretamente el método GetDlgCode(nLastKey). Pues es curiosos, pero VK_TAB me funciona igual con o sin ese método, sin em,bargo VK_DOWN no ¿? los ponga o no en GetDlgCode() ¿? Alguna explicación sería muy de agradecer.

Saludos a todos.
Nos Gusta Programar
manuramos
 
Posts: 219
Joined: Mon Dec 26, 2005 7:25 pm
Location: Jerez de la Frontera (Spain)

Postby Antonio Linares » Mon Jul 31, 2006 6:52 am

Manu,

Tal como lo explica el API de Windows:

The WM_GETDLGCODE message is sent to the dialog box procedure associated with a control. Normally, Windows handles all arrow-key and TAB-key input to the control. By responding to the WM_GETDLGCODE message, an application can take control of a particular type of input and process the input itself.

WM_GETDLGCODE


Parameters

This message has no parameters.

Return Values

The return value is one or more of the following values, indicating which type of input the application processes.

Value Meaning
DLGC_BUTTON Button.
DLGC_DEFPUSHBUTTON Default push button.
DLGC_HASSETSEL EM_SETSEL messages.
DLGC_RADIOBUTTON Radio button.
DLGC_STATIC Static control.
DLGC_UNDEFPUSHBUTTON Nondefault push button.
DLGC_WANTALLKEYS All keyboard input.
DLGC_WANTARROWS Direction keys.
DLGC_WANTCHARS WM_CHAR messages.
DLGC_WANTMESSAGE All keyboard input (the application passes this message on to a control).
DLGC_WANTTAB TAB key.


Default Action

The DefWindowProc function returns zero.

Remarks

Although the DefWindowProc function always returns zero in response to the WM_GETDLGCODE message, the window procedure for the predefined control classes return a code appropriate for each class.
The WM_GETDLGCODE message and the returned values are useful only with user-defined dialog box controls or standard controls modified by subclassing.

See Also

DefWindowProc, EM_SETSEL, WM_CHAR
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41325
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby manuramos » Mon Jul 31, 2006 10:51 am

Ok Antonio, más o menos ya me he enterado

Saludos
Nos Gusta Programar
manuramos
 
Posts: 219
Joined: Mon Dec 26, 2005 7:25 pm
Location: Jerez de la Frontera (Spain)


Return to FiveWin para CA-Clipper

Who is online

Users browsing this forum: No registered users and 2 guests