In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Class Tutorial

Foro público de Xailer en español
Responder
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

Class Tutorial

Mensaje por Cassiano de Oliveira »

Hello guys i want know if have some tutorial to use class, because i don´t
understand very well, for example, when i use:
PUBLISHED EXPORTED PROTECT, etc
What´s difference between PROPERTY and DATA
When i use READ ONLY in DATA, is possible use READ ONLY in PROPERTY?
This and more asks that i want know to create a controls in Xailer too.
I studied the Metacontrols, Controls Sample and bought the Jose Alfonso
Moreno book "Aprendiendo a Pensar en Objetos", but understand more or less,
if have a tutorial or something i will apreciate.
Regards,
Cassiano
joselalinf
Mensajes: 291
Registrado: Jue Ene 31, 2013 1:10 pm

Class Tutorial

Mensaje por joselalinf »

Cassiano,
the better place to learn are the sources.
> Hello guys i want know if have some tutorial to use class, because i don´t
> understand very well, for example, when i use:
>
> PUBLISHED EXPORTED PROTECT, etc
PUBLISHED: are the properties visible outside the class and they
appear in the object inspector.
PUBLIC: are properties visible outside the class but doesn't appear in the
object inspector.
PROTECTED/PRIVATE: properties/datas/methods are visible only inside the class.
> What´s difference between PROPERTY and DATA
PROPERTY allows to customize the behaviour of the property with custom
editors (by example: PE_Color) whilst DATA no.
> This and more asks that i want know to create a controls in Xailer too.
Did you seen these two little tutorials:
http://xailer.info/esp/?p=132
http://xailer.info/esp/?p=165
> I studied the Metacontrols, Controls Sample and bought the Jose Alfonso
The metacontrols is a special kind of control: it is not a real control but
a way to customize them without the needing to modify its sources.
Lets think about a standar TButton, every time you drop one in a form you
have to change its text, ie., to "Aceitar", set lDefault to true,
nModalResul to mrOKm, etc. to sweet your needs. You can write a metacontrol
to do this steps automatically.
Here is a complete sample:
//---------------------------------------------------------- --------------------
INIT PROC RegisterAceitarButton()
RegisterComponent( "Cassiano", "TButton", "TAceitarButton", {||
TAceitarButton():Create() } )
RETURN
//---------------------------------------------------------- --------------------
CLASS TAceitarButton FROM TIDEMetaControl
METHOD Create()
ENDCLASS
//---------------------------------------------------------- --------------------
METHOD Create() CLASS TAceitarButton
LOCAL oBtn
LOCAL aPos := GetCursorPos()
IF ::oActiveForm == Nil
RETURN Nil
ENDIF
aPos := ScreenToClient( ::oActiveForm:Handle, aPos )
WITH OBJECT oBtn := ::AddComponent( TButton(), ::oActiveForm )
:nLeft := aPos[1]
:nTop := aPos[2]
:lDefault := .T.
:cText := "&Aceitar"
:nModalResult := mrOK
//:nWidth := ...
END
::SetControl( oBtn )
RETURN Nil
//---------------------------------------------------------- --------------------
If you compile this code as a DLL and load it with Components->Component
manager->Add you will have a custom TButton in the "Cassiano" tab.
Regards,
José Lalí­n
Cassiano de Oliveira
Mensajes: 475
Registrado: Mar Jul 24, 2012 10:21 pm

Class Tutorial

Mensaje por Cassiano de Oliveira »

Gracias José.
Att.
Cassiano.
"José Lalí­n" wrote in message news:525d534a$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
Cassiano,
the better place to learn are the sources.
> Hello guys i want know if have some tutorial to use class, because i don´t
> understand very well, for example, when i use:
>
> PUBLISHED EXPORTED PROTECT, etc
PUBLISHED: are the properties visible outside the class and they
appear in the object inspector.
PUBLIC: are properties visible outside the class but doesn't appear in the
object inspector.
PROTECTED/PRIVATE: properties/datas/methods are visible only inside the
class.
> What´s difference between PROPERTY and DATA
PROPERTY allows to customize the behaviour of the property with custom
editors (by example: PE_Color) whilst DATA no.
> This and more asks that i want know to create a controls in Xailer too.
Did you seen these two little tutorials:
http://xailer.info/esp/?p=132
http://xailer.info/esp/?p=165
> I studied the Metacontrols, Controls Sample and bought the Jose Alfonso
The metacontrols is a special kind of control: it is not a real control but
a way to customize them without the needing to modify its sources.
Lets think about a standar TButton, every time you drop one in a form you
have to change its text, ie., to "Aceitar", set lDefault to true,
nModalResul to mrOKm, etc. to sweet your needs. You can write a metacontrol
to do this steps automatically.
Here is a complete sample:
//---------------------------------------------------------- --------------------
INIT PROC RegisterAceitarButton()
RegisterComponent( "Cassiano", "TButton", "TAceitarButton", {||
TAceitarButton():Create() } )
RETURN
//---------------------------------------------------------- --------------------
CLASS TAceitarButton FROM TIDEMetaControl
METHOD Create()
ENDCLASS
//---------------------------------------------------------- --------------------
METHOD Create() CLASS TAceitarButton
LOCAL oBtn
LOCAL aPos := GetCursorPos()
IF ::oActiveForm == Nil
RETURN Nil
ENDIF
aPos := ScreenToClient( ::oActiveForm:Handle, aPos )
WITH OBJECT oBtn := ::AddComponent( TButton(), ::oActiveForm )
:nLeft := aPos[1]
:nTop := aPos[2]
:lDefault := .T.
:cText := "&Aceitar"
:nModalResult := mrOK
//:nWidth := ...
END
::SetControl( oBtn )
RETURN Nil
//---------------------------------------------------------- --------------------
If you compile this code as a DLL and load it with Components->Component
manager->Add you will have a custom TButton in the "Cassiano" tab.
Regards,
José Lalí­n
Responder