Accessing a control from AppUi
| Thu, 2005-11-17 03:15 | |
|
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! ![]() |
|







Forum posts: 110
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
Forum posts: 34
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:
{
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);
}
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!