WEB开发网
开发学院手机开发Symbian 开发 在Symbian exe 程序中显示图形 阅读

在Symbian exe 程序中显示图形

 2010-05-06 21:39:00 来源:WEB开发网   
核心提示:window.SetBackgroundColor(TRgb(0x90, 0x90, 0x90));window.Activate();window.SetExtent(TPoint(0, 0), TSize(screenWidth, screenHeight));window.SetVisible(ETrue);gc

window.SetBackgroundColor(TRgb(0x90, 0x90, 0x90));

window.Activate();

window.SetExtent(TPoint(0, 0), TSize(screenWidth, screenHeight));

window.SetVisible(ETrue);

gc->Activate(window);

TRect rect = TRect(window.Size());

window.Invalidate(rect);

window.BeginRedraw(rect);

gc->SetBrushStyle(CGraphicsContext::ESolidBrush);

gc->Clear();

TInt64 seed = User::TickCount();

TRgb color[] = { KRgbRed, KRgbGreen, KRgbBlue, KRgbYellow, KRgbCyan };

for (TUint i = 0; i < 10000; ++i)

{

TInt x = Math::Rand(seed) % screenWidth;

TInt y = Math::Rand(seed) % screenHeight;

TInt w = Math::Rand(seed) % 50;

TInt h = Math::Rand(seed) % 25;

TRect rect(TPoint(x, y), TSize(w, h));

gc->SetBrushColor(color[i % sizeof color]);

gc->DrawRect(rect);

}

window.EndRedraw();

gc->Deactivate();

ws.Flush();

CleanupStack::PopAndDestroy(5, &ws); // window, gc, wg, screen, ws

}

Let's see now the entry point of the program. If we tried something like this

现在我们来看入口程序。如果我们这样做:

GLDEF_C TInt E32Main()

{

__UHEAP_MARK;

CTrapCleanup* cleanup = CTrapCleanup::New();

TRAPD(error, ExeMainL());

__ASSERT_ALWAYS(!error, User::Panic(_L("EXEUI"), error));

delete cleanup;

__UHEAP_MARKEND;

return 0;

}

it would work on the device only. On the emulator, you'd get a panic, as

RWsSession::Connect() would fail. The reason for this is that when an exe is executed, the

emulator doesn't launch the window server as part of its initialization, whereas on the

device the server is already loaded.

上一页  1 2 3 4 5  下一页

Tags:Symbian exe 程序

编辑录入:coldstar [复制链接] [打 印]
赞助商链接