#include <eikseced.h>
class CEikSecretEditor;
CEikSecretEditor* iSecretEdwin ;
const TInt KEdwinBorder = 20;
_LIT(KDefaultPassword,"mypassword");
const TInt KPasswordLength = 45;
RESOURCE SECRETED r_password_editor
{
num_letters = 45;
}
/*Read from resource */
TResourceReader resourceReader;
iCoeEnv->CreateResourceReaderLC( resourceReader,R_PASSWORD_EDITOR );
/*password edwin creation */
iSecretEdwin = new(ELeave) CEikSecretEditor;
iSecretEdwin->SetContainerWindowL(*this);
iSecretEdwin->ConstructFromResourceL( resourceReader );
iSecretEdwin->SetMaxLength(KPasswordLength);
CleanupStack::PopAndDestroy(); //destroy the resourceReader
const CFont* editorFont = const_cast<CFont*>(AknLayoutUtils::FontFromId(
EAknLogicalFontSecondaryFont));
iSecretEdwin->AknSetFont(*editorFont);
TRect controlRect = Rect for the password edwin
iSecretEdwin->SetRect(controlRect);
* '''Draw Function'''
<code cpp>
/* draw function*/
TRect edwinRect = iSecretEdwin ->Rect();
TInt borderSize = KEdwinBorder* iSecretEdwin->Size().iHeight/100;
if(borderSize<4)
borderSizee =4;
edwinRect.Grow((borderSize >> 2), (borderSize >> 2));
if(iSecretEdwin ->IsFocused())
gc.SetPenColor(KRgbWhite);
else
gc.SetPenColor(KRgbBlack);
gc.DrawRect(edwinRect);
response = iSecretEdwin ->OfferKeyEventL(aKeyEvent,aType);
iSecretEdwin ->SetText(KDefaultPassword);
/*retrieve the text from Secret edwin*/
TBuf<KPasswordLength>secretWord;
iSecretEdwin->GetText(secretWord);
if(iSecretEdwin )
{
delete iSecretEdwin ;
iSecretEdwin = NULL;
}
No related wiki articles found