home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
SOURCE
/
CLASSES
/
MGET.PRG
< prev
next >
Wrap
Text File
|
1994-06-10
|
5KB
|
162 lines
#include "FiveWin.ch"
#include "Constant.ch"
#define ES_WANTRETURN 4096 // 0x1000
#define EM_GETSEL (WM_USER+0)
#define EM_SETSEL (WM_USER+1)
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
//----------------------------------------------------------------------------//
CLASS TMultiGet FROM TControl
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, oFont,;
lHScroll, nClrFore, nClrBack, oCursor, lPixel, cMsg,;
lUpdate ) CONSTRUCTOR
METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, nClrFore, nClrBack, oFont,;
oCursor, cMsg, lUpdate ) CONSTRUCTOR
METHOD cToChar() INLINE Super:cToChar( "EDIT" )
METHOD GotFocus() INLINE Super:GotFocus(),;
SetWindowText( ::hWnd, Eval( ::bSetGet ) )
METHOD Init( hDlg )
METHOD LostFocus() INLINE Super:LostFocus(),;
Eval( ::bSetGet, GetWindowText( ::hWnd ) )
METHOD MouseMove( nRow, nCol, nKeyFlags )
METHOD cText( cText ) SETGET
METHOD Refresh() INLINE ;
SetWindowText( ::hWnd, cValToChar( Eval( ::bSetGet ) ) )
METHOD Save() INLINE Eval( ::bSetGet, GetWindowText( ::hWnd ) )
METHOD VScroll( nWParam, nLParam ) VIRTUAL
METHOD GetSel()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, oFont, lHScroll,;
nClrFore, nClrBack, oCursor, lPixel, cMsg, lUpdate ) CLASS TMultiGet
DEFAULT lHScroll := .f.,;
nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW ),;
lPixel := .f., lUpdate := .f.
::cCaption = cValToChar( Eval( bSetGet ) )
::nTop = nRow * If( lPixel, 1, MGET_CHARPIX_H ) //13
::nLeft = nCol * If( lPixel, 1, MGET_CHARPIX_W ) // 8
::nBottom = If( nHeight == nil, ::nTop + 11, ::nTop + nHeight )
::nRight = If( nWidth == nil, ::nLeft + Len( ::cCaption ) * 3.5, ;
::nLeft + nWidth )
::bSetGet = bSetGet
::oWnd = oWnd
::nStyle = nOR( WS_CHILD, WS_VISIBLE, WS_BORDER, WS_TABSTOP, ES_LEFT,;
ES_WANTRETURN, ES_MULTILINE, WS_VSCROLL,;
If( lHScroll, WS_HSCROLL, 0 ) )
::nId = ::GetNewId()
::cCaption = RTrim( ::cCaption )
::lDrag = .f.
::lCaptured = .f.
::oCursor = oCursor
::oFont = oFont
::cMsg = cMsg
::lUpdate = lUpdate
::SetColor( nClrFore, nClrBack )
if oWnd:lVisible
::Create( "EDIT" )
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
return nil
//----------------------------------------------------------------------------//
METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, nClrFore, nClrBack, oFont,;
oCursor, cMsg, lUpdate ) CLASS TMultiGet
DEFAULT nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
nClrBack := GetSysColor( COLOR_WINDOW ),;
lUpdate := .f.
::nId = nId
::bSetGet = bSetGet
::oWnd = oWnd
::nHelpId = nHelpId
::lDrag = .f.
::lCaptured = .f.
::oFont = oFont
::oCursor = oCursor
::cMsg = cMsg
::lUpdate = .f.
::SetColor( nClrFore, nClrBack )
oWnd:DefControl( Self )
return nil
//----------------------------------------------------------------------------//
METHOD Init( hDlg ) CLASS TMultiGet
Super:Init( hDlg )
SetWindowText( ::hWnd, cValToChar( Eval( ::bSetGet ) ) )
return nil
//----------------------------------------------------------------------------//
METHOD cText( cText ) CLASS TMultiGet
if PCount() == 1
SetWindowText( ::hWnd, cText )
endif
return GetWindowText( ::hWnd )
//----------------------------------------------------------------------------//
METHOD GetSel() CLASS TMultiGet
local n := ::SendMsg( EM_GETSEL )
local nStart := nLoWord( n )
local nEnd := nHiWord( n )
return If( nStart != nEnd, SubStr( ::cText, nStart + 1, nEnd - nStart + 1 ), "" )
//----------------------------------------------------------------------------//
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TMultiGet
if ::lDrag
return Super:MouseMove( nRow, nCol, nKeyFlags )
else
if ::oCursor != nil
SetCursor( ::oCursor:hCursor )
else
CursorIBeam()
endif
endif
return nil // We want standard MultiLine Get behavior !!!
//---------------------------------------------------------------------------//