Read-only archive of the All About Symbian forum (2001–2013) · About this archive

SetObserver Compile Error Problem

0 replies · 2,739 views · Started 20 February 2006

😡 I'm trying to create a list box from (rss) file , My IDE is (VS.Net 2003) When I build the project it gives the following compiling error:

Generating AIF file.
File C:\Symbian\7.0s\Series60_v20\Series60Ex\Sym9\aif\Sym9aif.mbm up-to-date, not converted.
File C:\Symbian\7.0s\Series60_v20\Epoc32\release\wins\UDEB\z\system\apps\sym9\Sym9.aif up-to-date, not compiled.
Compiling...
Sym9.cpp
src\Sym9.cpp(209) : error C2664: 'CEikListBox::SetListBoxObserver' : cannot convert parameter 1 from 'CSym9Container *const ' to 'MEikListBoxObserver *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

The Line of the error is inside (ConstrL) Method on the line:
iListBox->SetObserver(this);

Here is the complete code of the (ConstrL) Method:
#include "Sym9.h"
#include <barsread.h>
#include <Sym9.rsg>
#include "Sym9.hrh"
#include <coecntrl.h>
#include <coeccntx.h>
#include <txtglobl.h>

// CONSTANTS
const TUid KUidSym9App = { 0x03bc1fdb }; // Application UID

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

//iLabel = new (ELeave) CEikLabel;
//iLabel->SetContainerWindowL( *this );
//iLabel->SetTextL( _L("Example View"😉 );

//iToDoLabel = new (ELeave) CEikLabel;
//iToDoLabel->SetContainerWindowL( *this );
//iToDoLabel->SetTextL( _L("Add Your controls\n here"😉 );
iListBox = new (ELeave) CAknSingleStyleListBox();
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this, EAknListBoxSelectionList);
HBufC* helloText;

array = new (ELeave) CDesCArrayFlat(26);
// now reads the text from resource file to helloText
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_1); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_2); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_3); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_4); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_5); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_6); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_7); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_8); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_9); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_10); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_11); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_12); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_13); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_14); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_15); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_16); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_17); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_18); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_19); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_20); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_21); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_22); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_23); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_24); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_25); array->AppendL(*helloText);
helloText = iEikonEnv->AllocReadResourceL(TXT_SERVE_26); array->AppendL(*helloText);
iListBox->Model()->SetItemTextArray(array);
delete helloText;
//iListBox->ActivateL ();
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
iListBox->SetListBoxObserver(this);
iListBox->SetObserver(this);
SetRect(aRect);
ActivateL();
MakeVisible(ETrue);
}
------
Here Is the (Sym9.Rss) file:
/*
============================================================================
Name : Sym9.rss
Author :
Version :
Copyright : Your copyright notice
Description : Application resource file
============================================================================
*/

// Resource Identifier

NAME MHWA // 4 letter ID

// Include Files
#include <eikon.rh> // Global command ids
#include <avkon.rsg> // Avkon resource ids
#include <avkon.rh> // Avkon resource structure definitions
#include <avkon.mbg> // Avkon bitmap ids
#include "Sym9.hrh" // Application command ids
#include "Sym9.loc" // Localized strings
// Resource File Sigunature
CHARACTER_SET UTF8
RESOURCE RSS_SIGNATURE {}

// Default Document Name
RESOURCE TBUF { buf=""; }

// Application Information
RESOURCE EIK_APP_INFO {
menubar = r_sym9_menubar;
cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
}

//---------------------------------------------------------------------------
// R_SYM9_MENUBAR - Menu bar and menu pane
//---------------------------------------------------------------------------

RESOURCE MENU_BAR r_sym9_menubar {
titles = {
MENU_TITLE { txt = "File"; menu_pane = r_sym9_file_menu; }
};
}

RESOURCE MENU_PANE r_sym9_file_menu {
items = {
MENU_ITEM { txt = "Test"; command = EEikCmdFileOpen; },
MENU_ITEM { txt = qtn_List; command = ESym9CmdAppList; },
MENU_ITEM { txt = "Exit"; command = EAknCmdExit; }
};
}

RESOURCE LISTBOX r_list_listbox {
array_id = r_list_items;
flags = EAknListBoxSelectionList;
}

RESOURCE ARRAY r_list_items {
items =
{
LBUF { txt = "\tFirst"; },
LBUF { txt = "x\tSecond"; },
LBUF { txt = "\tThird"; }
};
}
RESOURCE TBUF TXT_SERVE_1 { buf = txt_Serve_1; }
RESOURCE TBUF TXT_SERVE_2 { buf = txt_Serve_2; }
RESOURCE TBUF TXT_SERVE_3 { buf = txt_Serve_3; }
RESOURCE TBUF TXT_SERVE_4 { buf = txt_Serve_4; }
RESOURCE TBUF TXT_SERVE_5 { buf = txt_Serve_5; }
RESOURCE TBUF TXT_SERVE_6 { buf = txt_Serve_6; }
RESOURCE TBUF TXT_SERVE_7 { buf = txt_Serve_7; }
RESOURCE TBUF TXT_SERVE_8 { buf = txt_Serve_8; }
RESOURCE TBUF TXT_SERVE_9 { buf = txt_Serve_9; }
RESOURCE TBUF TXT_SERVE_10 { buf = txt_Serve_10; }
RESOURCE TBUF TXT_SERVE_11 { buf = txt_Serve_11; }
RESOURCE TBUF TXT_SERVE_12 { buf = txt_Serve_12; }
RESOURCE TBUF TXT_SERVE_13 { buf = txt_Serve_13; }
RESOURCE TBUF TXT_SERVE_14 { buf = txt_Serve_14; }
RESOURCE TBUF TXT_SERVE_15 { buf = txt_Serve_15; }
RESOURCE TBUF TXT_SERVE_16 { buf = txt_Serve_16; }
RESOURCE TBUF TXT_SERVE_17 { buf = txt_Serve_17; }
RESOURCE TBUF TXT_SERVE_18 { buf = txt_Serve_18; }
RESOURCE TBUF TXT_SERVE_19 { buf = txt_Serve_19; }
RESOURCE TBUF TXT_SERVE_20 { buf = txt_Serve_20; }
RESOURCE TBUF TXT_SERVE_21 { buf = txt_Serve_21; }
RESOURCE TBUF TXT_SERVE_22 { buf = txt_Serve_22; }
RESOURCE TBUF TXT_SERVE_23 { buf = txt_Serve_23; }
RESOURCE TBUF TXT_SERVE_24 { buf = txt_Serve_24; }
RESOURCE TBUF TXT_SERVE_25 { buf = txt_Serve_25; }
RESOURCE TBUF TXT_SERVE_26 { buf = txt_Serve_26; }

-----
Here Is the Localization fiel (Arabic Text):

#define qtn_app_caption "Mobile Services"
#define qtn_app_short_caption "&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;"
#define qtn_Sym9_menu_title "&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;"
#define qtn_List "&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;"
#define qtn_exit "&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;"

#define txt_Serve_1 "\t&#1575;&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;"
#define txt_Serve_2 "\t&#1575;&#1604;&#1605;&#1576;&#1575;&#1575;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;&#1604;"
///....etc
// End of File
Here Is the (CSym9Container) syntax:

class CSym9Container : public CCoeControl, MCoeControlObserver
{
public: // Constructors and destructor
void ConstructL(const TRect& aRect);
~CSym9Container();

public: // New functions

public: // From CCoeControl
void SizeChanged();
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;
void Draw(const TRect& aRect) const;

public: // From MCoeControlObserver
void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
CEikTextListBox* iListBox;

private: // Data
//CEikLabel* iLabel; // example label
//CEikLabel* iToDoLabel; // example label
CDesCArray* array ;
HBufC* iSubject;
};

Because I'm new in symbian shall I do modification on the class?
Any Body Have An Idea on resolving this problem?