使用Symbian dev的CDirectScreenAccess的问题

发布于 2024-11-27 13:58:58 字数 1697 浏览 3 评论 0原文

最近在研究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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒浓于脸红 2024-12-04 13:58:58

您的 CMySnakeAppView 应该派生自 MDirectScreenAccess - 看起来您已经实现了正确的方法,只是缺少声明:

class CMySnakeAppView : public CCoeControl, public MDirectScreenAccess

Your CMySnakeAppView should derive from MDirectScreenAccess - it looks like you're already implementing the right methods, you're just missing the declaration:

class CMySnakeAppView : public CCoeControl, public MDirectScreenAccess
演出会有结束 2024-12-04 13:58:58

您不能传递 *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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文