diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-CDBBD44F-C5F6-4D51-B4BA-23DA9BB58D69.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-CDBBD44F-C5F6-4D51-B4BA-23DA9BB58D69.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,66 @@ + + + + + +Creating +generic button +

Create the CAknButton object +either dynamically from program code or from a resource structure. The constructed +button can then be used as a component control of a compound control.

+

Use the resource structures AVKON_BUTTON, AVKON_BUTTON_STATE, +and AVKON_BUTTON_STATE_EXTENSION for the button object (defined +in the file eikon.rh). The following example shows how to +construct a button with the help of a button resource. The button is placed +in a compound control (container) and it occupies the whole rectangle of the +container. The container is set as the observer of the button.

+

Example: Button resource

+RESOURCE AVKON_BUTTON r_myapp_button + { + flags = KAknButtonTextLeft; + states = + { + AVKON_BUTTON_STATE + { + txt = “Text”; + helptxt = “Help text”; + } + }; + } + +

Example: Constructing button from resource

+void CMyButtonContainer::CreateButtonL() + { + CAknButton* iAknButton = CAknButton::NewL(); + iAknButton->ConstructFromResourceL(R_MYAPP_BUTTON); + iAknButton->SetContainerWindowL(*this); + iAknButton->SetRect(Rect()); + iAknButton->SetObserver(this); + iAknButton->MakeVisible(ETrue); + iAknButton->ActivateL(); + } + +

Example: Constructing button from program code

+void CMyButtonContainer::CreateButtonL() + { + HBufC* buttonText = StringLoader::LoadLC( R_MYAPP_TEXT ); + HBufC* helpText = + StringLoader::LoadLC( R_MYAPP_HELPTEXT ); + CAknButton* iAknButton = CAknButton::NewL( + 0, 0, 0, 0, + *buttonText, *helpText, KAknButtonTextLeft, 0); + CleanupStack::PopAndDestroy( 2 ); // helpText, buttonText + iAknButton->SetContainerWindowL(*this); + iAknButton->SetRect(Rect()); + iAknButton->SetObserver(this); + iAknButton->MakeVisible(ETrue); + iAknButton->ActivateL(); + } + +
\ No newline at end of file