Symbian
Symbian OS Library

FAQ-0578 How do I include 'Add to Desk' functionality in my 9200 Series application?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Applications
Created: 04/27/2001 Modified: 04/08/2002
Number: FAQ-0578
Platform: Symbian OS v6.0

Question:
How do I include 'Add to Desk' functionality in my 9200 Series application?

Answer:
The following basic steps are what is needed to add this functionality to your own application:

1) Include the following headers in your application project:

#include
#include
#include
#include

2) Somewhere convenient (e.g. the end of your AppUi::ConstructL() method) add the following line:
    LinkUtils::AddLinkHotKeyL(*iEikonEnv->AppUiFactory()->MenuBar()->HotKeyTable(),EYourAppCmdAddToDesk);
    3) In the normal switch() block for that method add an extra check along the lines of:
      case EYourappCmdAddToDesk:
        AddToDeskL();
        break;
        4) At the start of your AppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) method, add the following check:
          if (aResourceId==R_YOUR_APP_FILE_MENU)
            {
            LinkUtils::AddLinkMenuItemL(*aMenuPane,EYourAppCmdAddToDesk);
            5) Add a new method to your AppUi class along the following lines:
              void CMyAppUi::AddToDeskL()
                {
                TPtrC documentName=iEikonEnv->Process()->MainDocFileName();
                if (currentDocument.Length()==0) // No current document so add Application link
                  {
                  CLinkApplication* linkApp=CLinkApplication::NewL();
                  CleanupStack::PushL(linkApp);
                  linkApp->SetApplicationUidL(iEikonEnv->Process()->MainDocument()->Application()->AppDllUid());
                  LinkUtils::CreateLinkDocumentL(*linkApp);
                  }else // Add a link to the current document
                    {
                    CLinkDocument* linkDoc=CLinkDocument::NewL();
                    CleanupStack::PushL(linkDoc);
                    linkDoc->SetDocumentL(documentName);
                    LinkUtils::CreateLinkDocumentL(*linkDoc);
                    }CleanupStack::PopAndDestroy(); // linkApp/linkDoc
                    }