|
|
Classification: |
C++ |
Category: |
EIKON |
Created: |
05/24/2002 |
Modified: |
06/21/2002 |
Number: |
FAQ-0795 |
Platform: |
Symbian OS v6.0, Symbian OS v6.1 |
|
Question: How do I change the colours of the highlighted item in a text list box and make it appear in my dialog?
Answer: You can use the CCoecontrol::OverrideColorL(...) method to change the default colour list which the control picks up, then force the control to update to use the new colour
list with a call to HandleResourceChange(KEikColorResourceChange). The best place to do this is in PreLayoutDynInitL():
// MyApp.cpp
void CModifiedListBoxDialog::PreLayoutDynInitL() { CEikTextListBox* listbox=(CEikTextListBox*)Control(EModifiedTextListBox); listbox->OverrideColorL(EColorControlHighlightBackground, TRgb(200, 100, 0)); listbox->OverrideColorL(EColorControlHighlightText, TRgb(0, 100, 200)); listbox->HandleResourceChange(KEikColorResourceChange); CDesCArray* listboxArray=((CDesCArray*)listbox->Model()->ItemTextArray()); ... }
You can then include the control in your dialog by adding it to your .hrh and .rss files as follows:
// MyApp.hrh
enum { EModifiedTextListBox };
// MyAppUi.rss
RESOURCE DIALOG r_modified_listbox_dialog { ... items = { DLG_LINE { type = EEikCtListBox; id = EModifiedTextListBox; control = LISTBOX { flags = EEikListBoxIncrementalMatching; }; } }; }
The logical color options which can be passed as the first argument to OverrideColorL() are defined in gulcolor.h.
|
|
|