Accessing a control from AppUi

Login to reply to this topic.
Thu, 2005-11-17 03:15
Joined: 2005-11-16
Forum posts: 34
I am a total newbie in Symbian development and I am still trying to grasp the idea of everything while working on an actual project (a very dangerous approach).

My problem is that I have a ListBox control defined in HTMLContainer.cpp

Code:
void CHTMLContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

//List box instance
iList = new (ELeave) CAknSingleStyleListBox;

//set container window
iList->SetContainerWindowL(*this);

//set listbox observer
iList->SetListBoxObserver(this);

//create scroll bars
iList->CreateScrollBarFrameL(ETrue);
iList->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);

////////////////////////////////////////////////////////
//set item array - design time
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_LIST_MAIN);
iList->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();

// update listbox
iList->HandleItemAdditionL();

//end list box

// TITLE
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
tp->SetTextL(_L("HTML/XML Viewer"));
DrawNow();
// END: TITLE

    SetListData();
SetRect(aRect);
    ActivateL();
    }

I am trying (really trying) to call iList from HTMLAppUi:

Code:
void CHTMLAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EEikCmdExit:
            {
            Exit();
            break;
            }

        case EHTMLCmdView:
            {
TUint a;
TText tItem;

TInt index = iList->CurrentItemIndex();

// Connect to the file server
RFs fileSession;
CDir* dirList;
TBuf<30> fileName;
TInt stat;

_LIT(KDirName, "C:\\Nokia\\MyTindahan\\web");
_LIT(KFileSpec,"C:\\Nokia\\MyTindahan\\web\\*.html");

stat = fileSession.Connect();

User::LeaveIfError( fileSession.GetDir(KFileSpec,
KEntryAttMaskSupported,
ESortByName,
dirList));

fileSession.Close();

itemList->Reset();
iList->HandleItemAdditionL();

fileName = (*dirList)[index].iName;

delete dirList;

iEikonEnv->InfoMsg(_L("Loading file..."));
LoadHTMLFile(fileName);
break;
            }

        default:
            break;     
     }
}

I get the error:
Code:
src\HTMLAppUi.cpp(95) : error C2065: 'iList' : undeclared identifier

Obviously, iList is not available to HTMLAppUi. How can I access iList from there?

Thanks, guys!  Grin

Thu, 2005-11-17 06:51
Joined: 2004-07-09
Forum posts: 110
Re: Accessing a control from AppUi
Hi Jhourlad,

   You can not access iList Directly to App Ui.


   Write a function to container class like

   
   CAknSingleStyleListBox Listbox()
  {
    if(iList)
      return iList;
  }

  Make sure it should be Public to container class.


All the best

DipakBaviskar

Thu, 2005-11-17 06:56
Joined: 2005-11-16
Forum posts: 34
Re: Accessing a control from AppUi
Thanks for the reply.

I managed o solve the problem by transfering the code to HTMLView.cpp and everything is working now. For the benefit of the curious this is how I did it:

Code:
void CHTMLView::activateModule(TInt module)
{
TText tItem;

// Connect to the file server
RFs fileSession;
CDir* dirList;
TBuf<100> fileName;
TInt stat;

_LIT(KDirName, "C:/Nokia/MyTindahan/web/");
_LIT(KFileSpec,"C:\\Nokia\\MyTindahan\\web\\*.html");

stat = fileSession.Connect();

User::LeaveIfError( fileSession.GetDir(KFileSpec,
KEntryAttMaskSupported,
ESortByName,
dirList));

fileSession.Close();

fileName.Append(_L("file://"));
fileName.Append(KDirName);
fileName.Append((*dirList)[module].iName);

delete dirList;

//iEikonEnv->InfoMsg(fileName);
LoadHTMLFile(fileName);

}

Code:
void CHTMLView::LoadHTMLFile(const TDesC& aUrl) {
HBufC* param = HBufC::NewLC( 256 );
param->Des().Format( _L( "4 %S" ),&aUrl );

// Wap Browser's constants UId
const TInt KWmlBrowserUid = 0x10008D39;
TUid id( TUid::Uid( KWmlBrowserUid ) );

TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );

if ( task.Exists() )
{
HBufC8* param8 = HBufC8::NewLC( param->Length() );
param8->Des().Append( *param );
task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
CleanupStack::PopAndDestroy(); // param8

} else {
RApaLsSession appArcSession;
User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server
TThreadId id;
appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid ), id );
appArcSession.Close();
}

CleanupStack::PopAndDestroy(); // param
}

Thanks guys!
  • Login to reply to this topic.