by areang » Fri Aug 18, 2006 6:14 am
Antonio
I Created the Class, still can't put the caption on the frames
and please also ERROR HANDLER ERROR().
Please Help me !
Here is the sample
#include "Fivewin.ch"
FUNCTION Main()
LOCAL oWnd, oFrames
DEFINE Window oWnd
oWnd:setText( "Use JcFrames from CoolControls.ocx" )
oFrames := Framesx():New( oWnd )
/*
To : Antonio
This is Work fine, I want to put caption on this frames
How to create class and use Caption properties
Here are methods on CoolControls.jcFrame, I got from oleview :
[
uuid(4C252B42-CA3D-477E-8A0E-CD2E4AB70B12),
version(1.0),
hidden,
dual,
nonextensible
]
dispinterface _jcFrames {
properties:
methods:
[id(0x68030015), propput]
void FrameColor([in, out] OLE_COLOR* rhs);
[id(0x68030015), propget]
OLE_COLOR FrameColor();
[id(0x68030014), propput, helpstring("Returns/Sets the Fill color for TextBox and Windows style")]
void FillColor([in, out] OLE_COLOR* rhs);
[id(0x68030014), propget, helpstring("Returns/Sets the Fill color for TextBox and Windows style")]
OLE_COLOR FillColor();
[id(0x68030013), propput]
void RoundedCornerTxtBox([in, out] VARIANT_BOOL* rhs);
[id(0x68030013), propget]
VARIANT_BOOL RoundedCornerTxtBox();
[id(0x68030012), propput]
void Enabled([in, out] VARIANT_BOOL* rhs);
[id(0x68030012), propget]
VARIANT_BOOL Enabled();
[id(0x68030011), propput]
void TxtBoxShadow([in, out] jcShadowConst* rhs);
[id(0x68030011), propget]
jcShadowConst TxtBoxShadow();
[id(0x68030010), propput]
void RoundedCorner([in, out] VARIANT_BOOL* rhs);
[id(0x68030010), propget]
VARIANT_BOOL RoundedCorner();
[id(0x6803000f), propput]
void Caption([in, out] BSTR* rhs);
[id(0x6803000f), propget]
BSTR Caption();
[id(0x6803000e), propput]
void Alignment([in, out] AlignmentConstants* rhs);
[id(0x6803000e), propget]
AlignmentConstants Alignment();
[id(0x6803000d), propput]
void Style([in, out] jcStyleConst* rhs);
[id(0x6803000d), propget]
jcStyleConst Style();
[id(0x6803000c), propput]
void TextBoxHeight([in, out] long* rhs);
[id(0x6803000c), propget]
long TextBoxHeight();
[id(0x6803000b), propput]
void TextColor([in, out] OLE_COLOR* rhs);
[id(0x6803000b), propget]
OLE_COLOR TextColor();
[id(0x6803000a), propput]
void TextBoxColor([in, out] OLE_COLOR* rhs);
[id(0x6803000a), propget]
OLE_COLOR TextBoxColor();
[id(0x68030009), propput]
void BackColor([in, out] OLE_COLOR* rhs);
[id(0x68030009), propget]
OLE_COLOR BackColor();
[id(0x68030008), propputref]
void Font([in, out] Font** rhs);
[id(0x68030008), propput]
void Font([in, out] Font** rhs);
[id(0x68030008), propget]
Font* Font();
[id(0x68030007), propget]
Picture* Picture();
[id(0x68030007), propputref]
void Picture([in] Picture* rhs);
[id(0x68030006), propget]
short IconSize();
[id(0x68030006), propput]
void IconSize([in] short rhs);
[id(0x68030005), propput]
void IconAlignment([in, out] IconAlignConst* rhs);
[id(0x68030005), propget]
IconAlignConst IconAlignment();
[id(0x68030004), propget]
jcThemeConst ThemeColor();
[id(0x68030004), propput]
void ThemeColor([in] jcThemeConst rhs);
[id(0x68030003), propget, helpstring("Returns/Sets the Start color for gradient")]
OLE_COLOR ColorFrom();
[id(0x68030003), propput, helpstring("Returns/Sets the Start color for gradient")]
void ColorFrom([in, out] OLE_COLOR* rhs);
[id(0x68030002), propget, helpstring("Returns/Sets the End color for gradient")]
OLE_COLOR ColorTo();
[id(0x68030002), propput, helpstring("Returns/Sets the End color for gradient")]
void ColorTo([in, out] OLE_COLOR* rhs);
[id(0x68030001), propput]
void HeaderStyle([in, out] jcHeaderConst* rhs);
[id(0x68030001), propget]
jcHeaderConst HeaderStyle();
[id(0x68030000), propput]
void GradientHeaderStyle([in, out] jcGradConst* rhs);
[id(0x68030000), propget]
jcGradConst GradientHeaderStyle();
};
*/
oWnd:oClient := oFrames:oControl
Activate Window oWnd
Return NIL
CLASS FRAMESX
DATA oControl
DATA oButton
CLASSDATA lOk Init .F.
ERROR HANDLER ERROR()
METHOD New()
METHOD Activate()
METHOD Install()
METHOD CheckOCX()
ENDCLASS
METHOD New( oWnd,nId ) CLASS FRAMESX
::CheckOCX()
IF !::lOk
MsgInfo( "Error to Install OCX Control" )
RETURN SELF
ENDIF
IF nId != NIL
::oControl := TActiveX():Redefine( nId, oWnd, "COOLCONTROLS.jcFrames" )
ELSE
::oControl := TActiveX():New( oWnd, "COOLCONTROLS.jcFrames" )
ENDIF
IF !Empty( oWnd:hWnd )
::Activate()
ENDIF
RETURN SELF
METHOD Activate()
::oButton := TOleAuto():New( ActXPdisp( ::oControl:hActiveX ) )
RETURN NIL
/*-----------------------------------------------------------------------------------------------*/
METHOD CheckOCX( lAutoInstall )
DEFAULT lAutoInstall := .F.
IF !::lOk
IF IsActiveX( "CoolControls.jcFrames" )
::lOk := .T.
ELSE
IF lAutoInstall .OR. MsgAlert( "Install OCX COntrol Now ?", { "Yes", "No" } ) == 1
MsgRun( "Installing OCX Control", NIL, { || ::Install() } )
ENDIF
ENDIF
ENDIF
RETURN ::lOk
/*-----------------------------------------------------------------------------------------------*/
METHOD Install()
LOCAL cOriginal, cDestination
cOriginal := "CoolControls.ocx"
cDestination := GetSysDir() + "\CoolControls.ocx"
IF !File( cOriginal )
MsgAlert(cOriginal+" file not found")
RETURN NIL
ENDIF
if !File((cDestination))
Copy File &cOriginal TO &cDestination
endif
if File((cDestination))
WinExec( "REGSVR32 " + cDestino + " /s" )
endif
::lOk := IsActiveX( "CoolControls.jcFrames" )
IF !::lOk
MsgInfo( "Error to Register "+cOriginal+" File" )
ENDIF
RETURN NIL
METHOD ERROR( uParam1 )
LOCAL cMsg, nParam, uRet
nParam := PCount()
cMsg := __GetMessage()
IF SubStr( cMsg, 1, 1 ) == "_"
cMsg := SubStr( cMsg, 2 )
ENDIF
/*
How to handle error code start from here
*/
DO CASE
CASE nParam == 0
uRet := "I don't know"
CASE nParam == 1
uRet := "What is this"
ENDCASE
RETURN uRet