直接调用RWsSession绘屏
来源:互联网 发布:大学生网络购物2016 编辑:程序博客网 时间:2024/06/04 19:16
.h文件
-------------------------------------------------
/*
* WindowDrawer.h
*
* Created on: 2010-1-29
* Author: Administrator
*/
#ifndef WINDOWDRAWER_H_
#define WINDOWDRAWER_H_
#include <gdi.h> // CFont
#include <w32std.h> //RWindowGroup, CWsScreenDevice, CWindowGc
#include <e32base.h>
_LIT(KtxHelloThere ,"Hi there !");
_LIT(KFontArial ,"Arial");
class CWindowDrawer : public CActive
{
public:
static CWindowDrawer* NewL(void);
~CWindowDrawer();
protected:
void DoCancel();
void RunL();
private:
CWindowDrawer();
void ConstructL(void);
void Draw(void);
private:
RWsSession iWsSession;
CWindowGc* iWindowGc;
CWsScreenDevice* iScreenDevice;
RWindowGroup iWindowGroup;
RWindow iWindow;
CFont* iMyFont;
};
#endif /* WINDOWDRAWER_H_ */
================================================================
.cpp文件
-------------------------------------------------------------------------
/*
* WindowDrawer.cpp
*
* Created on: 2010-1-29
* Author: Administrator
*/
#include <apgwgnam.h> //CApaWindowGroupName
#include "WindowDrawer.h"
#include <coedef.h> //for ECoeWinPriorityAlwaysAtFront
CWindowDrawer* CWindowDrawer::NewL(void)
{
CWindowDrawer* self = new (ELeave) CWindowDrawer();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
CWindowDrawer::~CWindowDrawer()
{
Cancel();
if (iMyFont)
{
iScreenDevice->ReleaseFont(iMyFont);
iMyFont = NULL;
}
delete iWindowGc;
iWindowGc = NULL;
delete iScreenDevice;
iScreenDevice = NULL;
iWindow.Close();
iWindowGroup.Close();
iWsSession.Close();
}
CWindowDrawer::CWindowDrawer() :
CActive(EPriorityLow)
{
}
void CWindowDrawer::ConstructL(void)
{
CActiveScheduler::Add(this);
User::LeaveIfError(iWsSession.Connect());
iScreenDevice = new (ELeave) CWsScreenDevice(iWsSession);
User::LeaveIfError(iScreenDevice->Construct());
User::LeaveIfError(iScreenDevice->CreateContext(iWindowGc));
TFontSpec MyeFontSpec(KFontArial, 12 * 15);
MyeFontSpec.iTypeface.SetIsProportional(ETrue);
User::LeaveIfError(iScreenDevice->GetNearestFontInTwips(iMyFont,
MyeFontSpec));
iWindowGroup = RWindowGroup(iWsSession);
User::LeaveIfError(iWindowGroup.Construct((TUint32) &iWindowGroup, EFalse));
//iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityNormal);
iWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iWindowGroup.EnableReceiptOfFocus(EFalse);
CApaWindowGroupName* winGroupName = CApaWindowGroupName::NewLC(iWsSession);
winGroupName->SetHidden(ETrue);
winGroupName->SetWindowGroupName(iWindowGroup);
CleanupStack::PopAndDestroy();
iWindow = RWindow(iWsSession);
User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32) &iWindow));
TPixelsTwipsAndRotation SizeAndRotation;
iScreenDevice->GetDefaultScreenSizeAndRotation(SizeAndRotation);
iWindow.Activate();
iWindow.SetExtent(TPoint(0, 0), SizeAndRotation.iPixelSize);
iWindow.SetBackgroundColor(KRgbBlue);
iWindow.SetOrdinalPosition(0,ECoeWinPriorityNormal);
//iWindow.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iWindow.SetNonFading(ETrue);
iWindow.SetVisible(ETrue);
Draw();
iWsSession.RedrawReady(&iStatus);
SetActive();
}
void CWindowDrawer::RunL()
{
if (iStatus != KErrCancel)
{
TWsRedrawEvent e;
iWsSession.GetRedraw(e);
// if Windows Server does not want a redraw the window handle is 0
if (e.Handle() != 0)
{
// draw our only window
Draw();
}
iWsSession.RedrawReady(&iStatus);
SetActive();
}
}
void CWindowDrawer::Draw(void)
{
iWindowGc->Activate(iWindow);
TRect DrwRect(TPoint(0, 0), iWindow.Size());
iWindow.Invalidate(DrwRect);
iWindow.BeginRedraw();
iWindowGc->Clear(DrwRect);
if (iMyFont)
{
iWindowGc->UseFont(iMyFont);
TInt StartY((DrwRect.Height() - iMyFont->HeightInPixels()) / 2);
iWindowGc->DrawText(KtxHelloThere, TRect(0, StartY, DrwRect.Width(),
(StartY + iMyFont->HeightInPixels())),
iMyFont->AscentInPixels(), CGraphicsContext::ECenter, 0);
}
iWindow.EndRedraw();
iWindowGc->Deactivate();
iWsSession.Flush();
}
void CWindowDrawer::DoCancel()
{
iWsSession.RedrawReadyCancel();
}
- 直接调用RWsSession绘屏
- performSelector调用和直接调用
- 客户端直接调用WebServices
- 直接使用系统调用
- QT直接调用dll
- iOS 应用直接调用
- Java直接调用Python
- cxf直接调用
- Ajax直接调用WebService
- Java直接调用Python
- input直接调用数字键盘
- Java直接调用Python
- sublime 命令行直接调用
- 避免直接调用某些文件
- 如何直接调用Excel数据?
- CVI直接调用WinDriver驱动
- jsp 直接调用 spring bean
- oracle直接调用web services
- PB编译错误整理
- 小小便利签
- appverifier用法
- 深入浅出Wince的存储机制
- ocx与dll的区别
- 直接调用RWsSession绘屏
- Eclipse3.5(Galileo)插件安装问题解决
- 数据库只有mdf文件而没有ldf文件,如何恢复数据库
- Wince下扩展串口
- 5分钟破解诺基亚Symbian9.2 S60V3三版手机方法总结
- wince tips
- Linux 脚本编写基础(四)
- ActionScript 学习
- open jtag跟jlink