×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2005
    Location
    Bologna - Italy
    Posts
    14

    Text Color in Form

    I've been trying to change text color on a Form since some days.

    Looking around in the forum, I wrore this code:

    void CPersonForm::PreLayoutDynInitL()
    {
    CAknForm::PreLayoutDynInitL();
    LoadFormValuesFromDataL();
    }

    void CPersonForm::LoadFormValuesFromDataL()
    {

    .........

    InitializeEditor(EMtPersonFormId, iId);
    ....
    InitializeEditor(EMtPersonFormNrId, iNrId);

    }

    void CPersonForm::InitializeEditor(const TInt aControlId, const TDesC& aText)
    {
    CCharFormatLayer* aFormatLayer = CEikonEnv::NewDefaultCharFormatLayerL ();
    TCharFormat charFormat;
    TCharFormatMask charFormatMask;
    aFormatLayer->Sense (charFormat, charFormatMask);
    charFormat.iFontPresentation.iTextColor=KRgbGreen;
    charFormatMask.SetAttrib (EAttColor);
    aFormatLayer->SetL (charFormat, charFormatMask);

    CEikEdwin* textEd = (CEikEdwin*)ControlOrNull( aControlId );

    if (textEd)
    {
    textEd->SetCursorPosL(0, EFalse);
    textEd->SetFocus(EFalse);
    textEd->SetCharFormatLayer(aFormatLayer);
    textEd->SetTextL( &aText );
    }
    }

    This is the resource file content:

    RESOURCE DIALOG r_person_form_dialog
    {
    flags = EEikDialogFlagNoDrag |
    EEikDialogFlagFillAppClientRect |
    EEikDialogFlagNoTitleBar |
    EEikDialogFlagWait |
    EEikDialogFlagCbaButtons |
    EEikDialogFlagNoBorder;
    buttons = r_options_back_cba;
    form = r_person_form;
    }

    RESOURCE FORM r_person_form
    {
    items =
    {
    DLG_LINE
    {
    type=EEikCtEdwin;
    prompt="Code";
    id=EMtPersonFormId;
    control=EDWIN
    {
    width=1;
    flags = EEikEdwinDisplayOnly;
    maxlength=KMaxReadOnlyLength;
    };
    },

    ........
    }


    The result is always the same: black text.

    Can someone explain me what's wrong in my code?

    Thank you in advance,
    Stefano

  2. #2
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    92

    Re: Text Color in Form

    I am also having this problem, where the font color in a form is always black. On FP1/FP2 devices it seems to correctly use the skin text color, but not on 3.0 devices like E61.

    I tried setting the color in PreLayoutDynInitL and PostLayoutDynInitL, but no luck. There must be a way since the built in forms like calendar use the skin color.

    Code:
       MAknsSkinInstance* skin = AknsUtils::SkinInstance();
         TRgb skinTextcol;
         AknsUtils::GetCachedColor(skin, skinTextcol, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
    
         CCharFormatLayer* FormatLayer=CEikonEnv::NewDefaultCharFormatLayerL();
    
         const CFont* edwinFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
         TFontSpec fontspec = edwinFont->FontSpecInTwips();
         TCharFormat charFormat(fontspec.iTypeface.iName, fontspec.iHeight);
         TCharFormatMask charFormatMask;
         FormatLayer->Sense(charFormat, charFormatMask);
    
         charFormat.iFontPresentation.iTextColor = skinTextcol;
         charFormatMask.SetAttrib(EAttColor);
    
         FormatLayer->SetL(charFormat, charFormatMask);
    
         iSubject->SetCharFormatLayer(FormatLayer);
    }

Similar Threads

  1. Exit form from edit mode
    By tqchcm in forum Symbian User Interface
    Replies: 13
    Last Post: 2007-10-31, 06:06
  2. Display Text Message on a Form (CAknForm)
    By saadmansur in forum Symbian User Interface
    Replies: 5
    Last Post: 2007-04-25, 11:45
  3. Form text is black in non editable mode
    By arachidyl in forum Symbian
    Replies: 0
    Last Post: 2007-03-20, 11:05
  4. text color in EDWIN in FORM
    By donDonald in forum Symbian User Interface
    Replies: 1
    Last Post: 2006-11-13, 07:25
  5. Replies: 0
    Last Post: 2004-11-24, 18:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •