O fonte do controle "vazio":
Código: Selecionar todos
#include "hbclass.ch"
#include "inkey.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvtwin.ch"
#include "wvgparts.ch"
CREATE CLASS Wvgcontrol INHERIT WvgWindow
VAR autosize INIT .F.
VAR Border INIT .T.
VAR cancel INIT .F.
VAR caption
VAR default INIT .F.
VAR drawMode INIT WVG_DRAW_NORMAL
VAR preSelect INIT .F.
VAR pointerFocus INIT .F.
VAR Style INIT 0
METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
METHOD destroy()
METHOD handleEvent( nMessage, aNM )
METHOD activate( xParam ) SETGET
METHOD setCaption( cCaption )
METHOD draw( xParam ) SETGET
ENDCLASS
METHOD Wvgcontrol:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
RETURN Self
METHOD Wvgcontrol:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::oParent:AddChild( Self )
::createControl()
//hOldFont := ::SendMessage( WIN_WM_GETFONT )
::SendMessage( WIN_WM_SETFONT, wvt_CreateFont( "Arial", 20, 10 ), 0 )
// wapi_DestroyObject( hOldFont )
IF ::visible
::show()
ENDIF
::setPosAndSize()
IF HB_ISCHAR( ::Caption )
::SetCaption()
ENDIF
RETURN Self
METHOD Wvgcontrol:handleEvent( nMessage, aNM )
DO CASE
CASE nMessage == HB_GTE_RESIZED
IF ::isParentCrt()
::rePosition()
ENDIF
::sendMessage( WIN_WM_SIZE, 0, 0 )
IF HB_ISEVALITEM( ::sl_resize )
Eval( ::sl_resize, , , Self )
ENDIF
CASE nMessage == HB_GTE_COMMAND
IF aNM[ 1 ] == BN_CLICKED
IF HB_ISEVALITEM( ::sl_lbClick )
IF ::isParentCrt()
::oParent:setFocus()
ENDIF
Eval( ::sl_lbClick, , , Self )
IF ::pointerFocus
::setFocus()
ENDIF
ENDIF
RETURN EVENT_HANDLED
ENDIF
CASE nMessage == HB_GTE_NOTIFY
CASE nMessage == HB_GTE_CTLCOLOR
ENDCASE
RETURN EVENT_UNHANDLED
METHOD PROCEDURE Wvgcontrol:destroy()
// LOCAL hOldFont
::wvgWindow:destroy()
// hOldFont := ::SendMessage( WIN_WM_GETFONT )
// wapi_DestroyObject( hOldFont )
RETURN
METHOD Wvgcontrol:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
RETURN Self
METHOD Wvgcontrol:setCaption( cCaption )
IF HB_ISCHAR( cCaption )
::Caption := cCaption
ENDIF
IF HB_ISCHAR( ::Caption )
::SendMessage( WIN_WM_SETTEXT, 0, ::Caption )
ENDIF
RETURN NIL
E o fonte que usei pro teste, baseado no _dyndlgs.prg da WVG:
Código: Selecionar todos
PROCEDURE Main
LOCAL oControl, oGroupbox
SetMode( 21, 60 )
SetColor("N/W")
CLS
// multiline edit
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + ES_AUTOVSCROLL + ES_MULTILINE + ;
ES_WANTRETURN + WIN_WS_BORDER + WIN_WS_VSCROLL
oControl:ClassName := "EDIT"
oControl:Caption := GetEditText()
oControl:Create( , , { -1, -2 }, { -15, -35 } )
// vertical line
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_ETCHEDVERT
oControl:ClassName := "STATIC"
oControl:Create( , , { -1, -39 }, { -16, -1 } )
// horizontal line
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_ETCHEDHORZ
oControl:ClassName := "STATIC"
oControl:Create( , , { -17, -2 }, { -1, -56 } )
// icon
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_ICON
oControl:ClassName := "STATIC"
oControl:Create( , , { -18, -2 }, { -2, -6 } )
// bitmap
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_BITMAP + SS_REALSIZEIMAGE
oControl:ClassName := "STATIC"
oControl:Create( , , { -18, -41 }, { -2, -8 } )
// button
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + BS_AUTOCHECKBOX
oControl:ClassName := "BUTTON"
oControl:Caption := "Satisfied?"
oControl:Create( , , { -18, -15 }, { -1, -10 } )
// edit
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + ES_RIGHT + ES_READONLY
oControl:ClassName := "STATIC"
oControl:Create( , , { -18, -30 }, { -1, -7 } )
// listbox
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + LBS_NOTIFY + WIN_WS_VSCROLL + WIN_WS_BORDER
oControl:ClassName := "LISTBOX"
oControl:Create( , , { -1, 41 }, { -4, -17 } )
// parte do combobox
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_LEFT
oControl:ClassName := "STATIC"
oControl:Create( , , { -4, -41 }, { -1, -17 } )
// combobox
oControl := WvgControl():New()
oControl:Style := WIN_WS_VISIBLE + WIN_WS_TABSTOP + CBS_DROPDOWNLIST + WIN_WS_BORDER + WIN_WS_VSCROLL
oControl:ClassName := "COMBOBOX"
oControl:Create( , , { -5, -41 }, { -6, -17 } )
// groupbox
oGroupbox := wvgControl():new()
oGroupbox:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + BS_GROUPBOX + WIN_WS_EX_TRANSPARENT
oGroupbox:ClassName := "BUTTON"
oGroupbox:Caption := "Compiler"
oGroupbox:Create( , , { -7, -41 }, { -4, -17 } )
//oGroupbox:ToBack()
// radiobutton
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_TABSTOP + BS_AUTORADIOBUTTON
oControl:Caption := "Harbour"
oControl:ClassName := "BUTTON"
oControl:Create( , , { -8, -43 }, { -1, -14 } )
// radiobutton
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_TABSTOP + BS_AUTORADIOBUTTON
oControl:Caption := "Clipper"
oControl:ClassName := "BUTTON"
oControl:Create( , , { -9, -43 }, { -1, -14 } )
// radiobutton
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_TABSTOP + BS_AUTORADIOBUTTON
oControl:Caption := "Xbase++"
oControl:ClassName := "BUTTON"
oControl:Create( , , { -10, -43 }, { -1, -14 } )
// text
oControl := wvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_LEFT
oControl:ClassName := "STATIC"
oControl:Caption := "Scrollable Text"
oControl:Create( , , { -12, -41 }, { -1, -18 } )
// text
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + ES_AUTOHSCROLL + WIN_WS_BORDER
oControl:Caption := "This is Text Field"
oControl:ClassName := "EDIT"
oControl:Create( , , { -13, -41 }, { -1, -18 } )
// text
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + SS_LEFT
oControl:ClassName := "STATIC"
oControl:Caption := "Right Justified Numerics"
oControl:Create( , , { -14, -41 }, { -1, -18 } )
// edit
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + ES_AUTOHSCROLL + ES_NUMBER + ES_RIGHT + WIN_WS_BORDER
oControl:Caption := "1234567"
oControl:ClassName := "EDIT"
oControl:Create( , , { -15, -41 }, { -1, -18 } )
// button
oControl := WvgControl():New()
oControl:Style := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_TABSTOP + BS_PUSHBUTTON
oControl:ClassName := "BUTTON"
oControl:Caption := "OK"
oControl:Create( , , { -18, -50 }, { -1, -8 } )
Inkey(0)
RETURN
STATIC FUNCTION GetEditText()
RETURN ;
"Welcome in the Wonderful World of Harbour!" + ;
hb_eol() + hb_eol() + ;
"When Peter Rees first published GTWVT, a Windows " + ;
"Terminal Driver, on 22 Dec 2003, everybody took it " + ;
"lightly, except for me, as I was aware that what " + ;
"wonderful contribution to Harbour he has made, " + ;
"what immense possibilities he has opened for Harbour " + ;
"developers, what limitations he has cleared for Cl*pper " + ;
"savvy user base." + ;
hb_eol() + hb_eol() + ;
"With a little effort I could extend GTWVT " + ;
"to give it a GUI look. I also tried to give it " + ;
"an event driven functionality, and up came Wvt*Classes." + ;
hb_eol() + hb_eol() + ;
"And yet another feather is added in the cap of GTWVT " + ;
"as it is now capable of firing modeless dialogs like the one " + ;
"you are viewing. These dialogs can be constructed dynamically ( Courtesy hbwhat ) " + ;
"at run time or can be one of resources. At present 20 such dialogs " + ;
"can be active at any given time. Also note that dialogs created " + ;
"dynamically respect Top, Left, Rows, Cols coordinates, which is an " + ;
"undisputed productivity boost!" + ;
hb_eol() + hb_eol() + ;
"Enjoy!" + hb_eol() + ;
"Pritpal Bedi, INDIA"
Nota:
Os "gets" funcionam, mas tudo é componente GUI, e usado encima de uma tela padrão da GTWVG.
O fonte de teste mistura o que deveria ser parte da classe/controle, é só pra teste mesmo.