使用Symbian dev的CDirectScreenAccess的问题
最近在研究Symbian开发。当我想使用CDirectScreenAccess直接在设备上绘图时,出现了问题。 我的代码如下:
//MySnakeAppView.h
class CMySnakeAppView : public CCoeControl
{
...
private:
void ConstructL(const TRect& aRect);
CDirectScreenAccess* iDSA;
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
void DrawGraphics();
...
}
//MySnakeAppView.cpp
void CMySnakeAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
CEikonEnv* env = CEikonEnv::Static();
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), *this);
iDSA->StartL();
DrawGraphics();
}
void CMySnakeAppView::DrawGraphics()
{
CFbsBitGc *gc = iDSA->Gc();
TRgb colorRed = AKN_LAF_COLOR(35);
gc->SetPenColor(colorRed);
gc->DrawRect(TRect(0,0,100,100));
iDSA->ScreenDevice()->Update();
}
void CMySnakeAppView::Restart(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->StartL();
DrawGraphics();
}
void CMySnakeAppView::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->Cancel();
}
当我构建这个项目时,代码是错误的 iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), *this); 这是一个错误的写法: 'MDirectScreenAccess &' - 非法隐式转换 'CMySnakeAppView' 到 但是当我这样做时: iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), (MDirectScreenAccess &)*this);
构建没有错误,但项目中仍然有错误,我不知道为什么,我需要你的帮助
Recently, I am studying Symbian development. When I want to use CDirectScreenAccess to draw on the device directly, there occurs the question.
My code is below :
//MySnakeAppView.h
class CMySnakeAppView : public CCoeControl
{
...
private:
void ConstructL(const TRect& aRect);
CDirectScreenAccess* iDSA;
void Restart(RDirectScreenAccess::TTerminationReasons aReason);
void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
void DrawGraphics();
...
}
//MySnakeAppView.cpp
void CMySnakeAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
CEikonEnv* env = CEikonEnv::Static();
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), *this);
iDSA->StartL();
DrawGraphics();
}
void CMySnakeAppView::DrawGraphics()
{
CFbsBitGc *gc = iDSA->Gc();
TRgb colorRed = AKN_LAF_COLOR(35);
gc->SetPenColor(colorRed);
gc->DrawRect(TRect(0,0,100,100));
iDSA->ScreenDevice()->Update();
}
void CMySnakeAppView::Restart(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->StartL();
DrawGraphics();
}
void CMySnakeAppView::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
{
iDSA->Cancel();
}
when I build this project, it is wrong with the code
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), *this);
this is a mistake writing that :
'MDirectScreenAccess &'
- illegal implicit conversion from
'CMySnakeAppView' to
but when I do it like this :
iDSA = CDirectScreenAccess::NewL(env->WsSession(), *env->ScreenDevice(), Window(), (MDirectScreenAccess &)*this);
there is no mistake in building,but still have mistake in the project, I don't know why,I need your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
CMySnakeAppView
应该派生自MDirectScreenAccess
- 看起来您已经实现了正确的方法,只是缺少声明:Your
CMySnakeAppView
should derive fromMDirectScreenAccess
- it looks like you're already implementing the right methods, you're just missing the declaration:您不能传递 *this,因为它不是 MDirectScreenAccess 类的实例,也不是从它继承的类的实例。您可以手动投射它,但这是一个错误。您应该构建一个继承自 MDirectScreenAccess 的类,并从那里构建 iDSA。请看这里:
http://www.developer.nokia.com/Community/Wiki /Anti-tearing_with_CDirectScreenBitmap
You can't pass *this, because it is not an istance of a MDirectScreenAccess class nor an istance of a class that inherits from it. You can cast it manually, but that is an error. You should construct a class that inherits from MDirectScreenAccess and from there build the iDSA. Look at here:
http://www.developer.nokia.com/Community/Wiki/Anti-tearing_with_CDirectScreenBitmap