×
Namespaces

Variants
Actions

Implementing Password Edwin on Symbian Phones

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: bharatuppal (18 Jul 2007)
Last edited: hamishwillee (25 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

Headers

#include <eikseced.h>
class CEikSecretEditor;
CEikSecretEditor* iSecretEdwin ;
const TInt KEdwinBorder = 20;
_LIT(KDefaultPassword,"mypassword");
const TInt KPasswordLength = 45;

Resource

RESOURCE SECRETED r_password_editor

   {
      num_letters = 45;
   }


Source File

  • ConstructL
/*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);
  • OfferKeyEventL
response = iSecretEdwin ->OfferKeyEventL(aKeyEvent,aType);
  • Setting the default password
iSecretEdwin ->SetText(KDefaultPassword);
  • Retrieving the Entered Password
/*retrieve the text from Secret edwin*/ 
TBuf<KPasswordLength>secretWord;
iSecretEdwin->GetText(secretWord);
  • Destructor
if(iSecretEdwin )
{
delete iSecretEdwin ;
iSecretEdwin = NULL;
}
This page was last modified on 25 July 2012, at 22:59.
32 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×