请各位一定要帮忙,否则刚就业就要失业了.

yeahchenghu 2007-09-18 02:01:12
我参照例子grid,做了一个menu grid 不知为什么就是加不了图片.请各位指点一二,最好有代码.
下面是我的部分代码:

void CIconContainer::GridMenuL()
{
iGrid = new ( ELeave ) CAknGrid;

CAknPopupList* popupList = CAknPopupList::NewL( iGrid,
R_AVKON_SOFTKEYS_SELECT_BACK );
CleanupStack::PushL( popupList );
popupList->SetTitleL( _L("Emoticons") );
iGrid->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTIONGRID);
iGrid->ConstructFromResourceL(reader);
iGrid->ActivateL();
TInt popupOk = popupList->ExecuteLD();
CleanupStack::Pop();
// TRect rect = Rect();

GridCellL();
AddIcons();
}
void CIconContainer::GridCellL()
{ AknListBoxLayouts::SetupStandardGrid( *iGrid );

AknListBoxLayouts::SetupFormGfxCell(

*iGrid, // Reference to grid control

iGrid->ItemDrawer(),// Pointer to the item drawer

0,

0,
0,
0,

0,

50,

32,

TPoint(0,0),

TPoint(32, 32));

}

void CIconContainer::AddIcons()
{ CArrayPtr< CGulIcon >* icons = new(ELeave) CAknIconArray(3);
CleanupStack::PushL( icons );
_LIT(KMbmPath, "\\resource\\apps\\Icon.mbm");

CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL( KMbmPath,

0);

CleanupStack::PushL( bitmap );

Load the mask for mail icon

CFbsBitmap* mask = iEikonEnv->CreateBitmapL( KMbmPath,

1);

CleanupStack::PushL( mask );
// Append the mail icon to icon array
// icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
// CleanupStack::Pop(2); // bitmap, mask
// Attach icon array to grid’s item drawer
iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons);
CleanupStack::Pop();
delete iGrid;
iGrid=NULL;
}
...全文
322 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
yeahchenghu 2007-09-26
  • 打赏
  • 举报
回复
谢谢你们,问题已解决.我是动态定义布局.在资源文件里定义不行.困惑....
isarc 2007-09-24
  • 打赏
  • 举报
回复
想让别人帮忙有不肯贴上代码。。。。。
yeahchenghu 2007-09-24
  • 打赏
  • 举报
回复
未解决.....................
dyw 2007-09-21
  • 打赏
  • 举报
回复
贴添加Items的代码
yeahchenghu 2007-09-21
  • 打赏
  • 举报
回复
上面的方法也试了.我上面的代码是可以编译的,没有出错,但就是加不了图片.不知是不是少了关键性的代码....
dyw 2007-09-20
  • 打赏
  • 举报
回复
设置断点,单步执行。发现出错行。
yeahchenghu 2007-09-20
  • 打赏
  • 举报
回复
谢谢两位,我用你们的方法都试了.不行...
我怀疑是 AddIcons()中代码有错,于是我用carbide ,我拖了一个listboxItem进主窗格,会自动生成一些加图标的代码.我尝试用这些代码,可还是不行.自动生成的代码如下:
CArrayPtr< CGulIcon >* icons = NULL;
icons = new (ELeave) CAknIconArray( 1 );
CleanupStack::PushL( icons );
// for EListBoxIconList_iconIndex
icons->AppendL( LoadAndScaleIconL(
KIconFile, EMbmIconList_icon, EMbmIconList_icon_mask,
NULL, EAspectRatioPreserved ) );
CleanupStack::Pop( icons );

//Attach icon array to grid’s item drawer
iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons);
iGrid->HandleItemAdditionL();
神啊,救救我吧!!!!!!
isarc 2007-09-20
  • 打赏
  • 举报
回复
昨天,没来上班。你用断点跟踪啊,看是哪里错了。
yeahchenghu 2007-09-19
  • 打赏
  • 举报
回复
没有人回答我吗?
dyw 2007-09-19
  • 打赏
  • 举报
回复
void CIconContainer::AddIcons() 
{
...
// 最后两行
delete iGrid; // 为什么删除iGrid?
iGrid=NULL;
}
anel 2007-09-19
  • 打赏
  • 举报
回复
1.确定你图是否正常(能显示)
2,在你加入图完毕,
iGrid->HandleItemAdditionL();
yeahchenghu 2007-09-19
  • 打赏
  • 举报
回复
谢谢你的回复,我已经参考了Series60Ex\grid的例子,可还是不知道错在哪..............
anel 2007-09-19
  • 打赏
  • 举报
回复
可参考
Series60Ex\grid
yeahchenghu 2007-09-18
  • 打赏
  • 举报
回复
谢谢.我按楼上的方法试了.不行......
isarc 2007-09-18
  • 打赏
  • 举报
回复
呵呵,是我在线等你。
不等了。
isarc 2007-09-18
  • 打赏
  • 举报
回复
CleanupStack::Pop(2); // bitmap, mask
不要delete bitmap
CGulIcon* vGulIcon = CGulIcon::NewL(vBitmap);要new实例而且它把new的内存拿去负责了,
iListIcon->AppendL(vGulIcon);ilisticon是我的程序里面的listbox不过也差不多
isarc 2007-09-18
  • 打赏
  • 举报
回复
CArrayPtr < CGulIcon >* icons = new(ELeave) CAknIconArray(3);
这个东西建立在类成员中,不要popanddestroy,only pop, 在析构函数里面icons->resetanddestroy
isarc 2007-09-18
  • 打赏
  • 举报
回复
报什么错误?
yeahchenghu 2007-09-18
  • 打赏
  • 举报
回复
我是新手.我在线等...........

3,119

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧