打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Symbian学习笔记(14)——使用BrowserControlAPI - 中华考试网(...

Symbian学习笔记(14)——使用BrowserControlAPI

中华IT学院 加入收藏  【 】  [ 2011-2-25 ]
-
再把这个Browser Control API也总结一下吧,只是做个引导,其实要掌握它的用法最好的方法是打开 9.1\S60_3rd\S60Ex\BrCtlSampleApp 这个例子来阅读,它几乎涵盖了这个API的所有使用方法。

而我在UniNews中只使用了它最基本的用法,下面给出代码:

首先,在H文件中声明一个控件成员:

#include <coecntrl.h>
#include <brctlinterface.h> 
#include <brctldefs.h>
#include <brctllayoutobserver.h> 
#include <brctllinkresolver.h>

class CUniNewsWebContainer : public CCoeControl, MCoeControlObserver,MBrCtlLoadEventObserver ...{
public:
    // Constructors and destructor        
    ~CUniNewsWebContainer();
    static CUniNewsWebContainer* NewL(const TRect& aRect);
    static CUniNewsWebContainer* NewLC(const TRect& aRect);

private:
    // New functions
    void ConstructL(const TRect& aRect);
    CUniNewsWebContainer();

public:
    // Functions from base classes
    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
    void HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,TUint aSize,TUint16 aTransactionId);
    void LoadContentL(TInt id);
    
private:
    // Functions from base classes
    void SizeChanged();
    TInt CountComponentControls() const;
    CCoeControl* ComponentControl(TInt aIndex) const;
    void Draw(const TRect& aRect) const;
    void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);

    HBufC8* ReadFileLC(const TDesC& aFileName);
private:
//data
    CBrCtlInterface*    iBrowser;
    TUint                iCapabilities;
    TInt                 iCommandBase;
};

 

主要声明了三个成员,其中CBrCtlInterface是主要的browser控件,其它两个是构造时的所需要的参数。而这个类派生于接口MBrCtlLoadEventObserver,所以实现它的方法void HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,TUint aSize,TUint16 aTransactionId);

在实现文件CPP中,我们需要构造它:

void CUniNewsWebContainer::ConstructL(const TRect& aRect) ...{
    // Create a window for this application view
    CreateWindowL();
    SetRect(aRect);
    
    //add your code here ...
    iBrowser=CreateBrowserControlL(this
            ,aRect
            ,iCapabilities
            ,iCommandBase
            ,NULL     //softkey observer
            ,NULL    //link resolver
            ,NULL    //special load observer
            ,NULL    //layout observer
            ,NULL    //dialog provider
            );
首页 1 2 尾页
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
自定义控件
最新修改版树形表格(TreeViewGrid)控件代码
Symbian OS:活动对象与活动调度器
关于RMsgQueue类的使用
ini文件的创建读写(含源码)
C5
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服