I 'm trying to create a new fwh class
I want create a list of Check box and insert it on alistbox as Items
I create it but there something not run also
Can you help me please
- Code: Select all Expand view
#include "fivewin.ch"
#define LB_SETITEMHEIGHT 0x01A0
#define LB_SETCOLUMNWIDTH 0x0195
#define LBS_MULTICOLUMN 0x0200
#define LBS_OWNERDRAWVARIABLE 0x0020
#define SRCCOPY 13369376
#define ODT_MENU 1
#define ODT_LISTBOX 2
#define ODT_COMBOBOX 3
#define ODT_BUTTON 4
#define ODA_DRAWENTIRE 0x0001
#define ODA_SELECT 0x0002
#define ODA_FOCUS 0x0004
#define ODS_SELECTED 0x0001
#define ODS_GRAYED 0x0002
#define ODS_DISABLED 0x0004
#define ODS_CHECKED 0x0008
#define ODS_FOCUS 0x0010
#define ODS_DEFAULT 0x0020
#define ODS_COMBOBOXEDIT 0x1000
#define LISTBOX_BASE 383
#define LB_ADDSTRING ( LISTBOX_BASE + 1 )
#define LB_INSERTSTRING ( LISTBOX_BASE + 2 )
#define LB_DELETESTRING ( LISTBOX_BASE + 3 )
#define LB_RESETCONTENT ( LISTBOX_BASE + 5 )
#define LB_SETSEL ( LISTBOX_BASE + 6 )
#define LB_SETCURSEL ( LISTBOX_BASE + 7 )
#define LB_GETSEL ( LISTBOX_BASE + 8 )
#define LB_GETCURSEL ( LISTBOX_BASE + 9 )
#define LB_GETCOUNT ( LISTBOX_BASE + 12 )
#define LB_DIR ( LISTBOX_BASE + 14 )
#define LB_GETSELCOUNT ( LISTBOX_BASE + 17 )
#define LB_GETSELITEMS ( LISTBOX_BASE + 18 )
#define LB_ERR -1
#define COLOR_WINDOW 5
#define COLOR_WINDOWTEXT 8
Static oWnd
FUNCTION Main()
Local oList
DEFINE WINDOW oWnd
aItems := { "Silvio Falconi","Enrico Maria Giordano", "Antonio Linares", "James Bott", ;
"Big Luciano", "Bill Gates", "Bin laden", "Obama", "Bush", "Clinton", "Micky Mouse" }
oList:= TListCheck():new( oWnd, 10, 10, 200, 200 )
oList:add(aItems )
oList:GoTop()
ACTIVATE WINDOW oWnd
RETURN
//------------------------------------------------------------------------------//
//Beta version
CLASS TListCheck FROM TListBox
DATA aCheckBox AS ARRAY INIT {}
DATA nHeightItem // nheight for items
METHOD New( oWnd,nTop, nLeft, nWidth, nHeight, nHeightItem,nClrFore, nClrBack, lPixel, lDesign) CONSTRUCTOR
METHOD Initiate( hDlg ) INLINE Super:Initiate( hDlg ), ::Default()
METHOD Default()
METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
METHOD Paint()
METHOD DrawCheck()
METHOD AddItem ( cItem, lValue ) INLINE ::Add( cItem,lValue )
METHOD SetCheck( nItem, lValue ) INLINE ::aCheckBoxs[ nItem ] := lValue, if( ::hWnd != nil, ::Refresh(),)
METHOD lselected( nItem ) INLINE ::aCheckBox[ nItem ]
METHOD SetHeightItem( nHItem ) INLINE ::nHeightItem := nHeightItem, ::SendMsg( LB_SETITEMHEIGHT, 0, ::nHeighItem )
ENDCLASS
METHOD New( oWnd,nTop, nLeft, nWidth, nHeight, nHeightItem,nClrFore, nClrBack, lPixel, lDesign) CLASS TListCheck
if nClrFore == nil
nClrBack := GetSysColor( COLOR_WINDOW )
endif
DEFAULT nTop := 0, nLeft := 0,;
aItems := {}, nWidth := 40, nHeight := 40,;
nClrFore := GetSysColor( COLOR_WINDOWTEXT ),;
lPixel := .f., lDesign := .f.,;
oWnd := GetWndDefault()
::bSetGet := { || nil } // from listbox class
::aItems := {}
::cCaption := ""
::nTop := nTop
::nLeft := nLeft
::nBottom := ::nTop + nHeight - 1
::nRight := ::nLeft + nWidth - 1
::oWnd = oWnd
::oFont = TFont():New( GetSysFont(), 0, -9,, .t. )
::lOwnerDraw = .T.
::nStyle = nOR( LBS_NOTIFY , LBS_OWNERDRAWFIXED , WS_CHILD , WS_VISIBLE ,;
WS_BORDER , WS_VSCROLL, WS_HSCROLL, WS_TABSTOP )
if nHeightItem == nil
nHeightItem := 21
endif
::SetColor( nClrFore, nClrBack )
if ! Empty( oWnd:hWnd )
::Create( "LISTBOX" )
::Default()
if oFont != nil
::SetFont( oFont )
endif
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
endif
if lDesign
::CheckDots()
endif
return Self
METHOD Paint() CLASS TListCheck
local aInfo := ::DispBegin()
if ::oBrush != nil
FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
else
CallWindowProc( ::nOldProc, ::hWnd, WM_ERASEBKGND, ::hDC, 0 )
endif
CallWindowProc( ::nOldProc, ::hWnd, WM_PAINT, ::hDC, 0 )
::DrawCheck()
::DispEnd( aInfo )
return 1
METHOD Default() CLASS TListCheck
local nAt
local cStart := Eval( ::bSetGet )
local aFiles
DEFAULT cStart := ""
::SetHeightItem( ::nHeightItem ) // to set the Height for each Items
if ! Empty( ::cFileSpec )
aFiles = Directory( ::cFileSpec )
for nAt = 1 to Len( aFiles )
AAdd( ::aItems, Lower( aFiles[ nAt ][ 1 ] ) )
next
ASort( ::aItems )
endif
AEval( ::aItems,;
{ | cItem, nAt | If( cItem == nil, ::aItems[ nAt ] := "",),;
::SendMsg( LB_ADDSTRING, 0,;
If( cItem == nil, "", cItem ) ) } )
if ValType( cStart ) != "N"
nAt = AScan( ::aItems, { | cItem | Upper( AllTrim( cItem ) ) == ;
Upper( AllTrim( cStart ) ) } )
else
nAt = cStart
endif
if nAt != 0
::SendMsg( LB_SETCURSEL, nAt - 1 )
else
::SendMsg( LB_SETCURSEL, 0 )
endif
::SetHeightItem( ::nHeightItem ) // to set the Height for each Items
return nil
METHOD DrawCheck() CLASS TListCheck
LOCAL i, obj, nFila
nFila := 1
FOR i := 1 TO Len( ::aItems )
oChk := TCheckBox():New( nFila, ::nLeft, aItems[ i ], , oWnd)
Aadd( ::aCheckBox, oChk )
nFila += 21
NEXT
return nil