为何创建一个最简单的EDIT都不显示啊,,,,,,,,,

god_sun 2010-02-02 11:16:06

void CtestEditAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();

TResourceReader aRead ;
iCoeEnv->CreateResourceReaderLC(aRead,R_EXAMPLE_EDITOR);
iEdit = new (ELeave) CEikEdwin();
iEdit->SetContainerWindowL(*this);
iEdit->ConstructFromResourceL(aRead);
iEdit->SetBackgroundColorL(KRgbRed);
CleanupStack::PopAndDestroy();
iEdit->SetExtent(TPoint( 10, 25 ), iEdit->MinimumSize());
iEdit->SetFocus(ETrue);

// Set the windows size
SetRect(aRect);

// Activate the window, which makes it ready to be drawn
ActivateL();
}


rss

RESOURCE EDWIN r_example_editor
{

flags = EEikEdwinWidthInPixels; // 以像素为单位

width = 240; // 控件宽度

lines = 2; // 行数

maxlength = 256; // 文本最大长度

}
...全文
212 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯枫 2010-02-24
  • 打赏
  • 举报
回复
Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();

// Gets the control's extent
TRect drawRect(Rect());

gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGreen);

gc.SetBrushStyle(CGraphicsContext::ESolidBrush);

gc.DrawRect(drawRect);

// Clears the screen
//gc.Clear(drawRect);

}
把Draw()改一下,再加
TInt ChhAppView::CountComponentControls() const
{
return 1;

}

CCoeControl* ChhAppView::ComponentControl( TInt aIndex ) const
{
switch (aIndex)
{
case 0:
return itime;
default:
return NULL;
}
}
chenziteng 2010-02-09
  • 打赏
  • 举报
回复
Hi,

"请问S60下CEikEdwin如何显示边框"
http://topic.csdn.net/t/20060315/18/4616827.html

Regards

Ziteng Chen
tian_xuezhi 2010-02-08
  • 打赏
  • 举报
回复
孩子,你要加边框

没边框,是看不见的
god_sun 2010-02-08
  • 打赏
  • 举报
回复
引用 25 楼 tian_xuezhi 的回复:
孩子,你要加边框

没边框,是看不见的

大哥,如何加边框啊
symart 2010-02-07
  • 打赏
  • 举报
回复
不好意思啊 ,粘错了,不过好像和你的问题很相似。自己检查吧
symart 2010-02-06
  • 打赏
  • 举报
回复
我刚在模拟器上测试了可以显示,不能编辑,还需处理按键事件OfferKeyEventL
/*
============================================================================
Name : hhAppView.cpp
Author :
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/

// INCLUDE FILES
#include <coemain.h>
#include "hhAppView.h"
#include "Ctime.h"
#include <hh_0xE0F3A282.rsg>
// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// ChhAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
ChhAppView* ChhAppView::NewL(const TRect& aRect)
{
ChhAppView* self = ChhAppView::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
ChhAppView* ChhAppView::NewLC(const TRect& aRect)
{
ChhAppView* self = new (ELeave) ChhAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void ChhAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
TBuf16 <64> buf;
TInt ibeginHour=5;
TInt ibeginMin=7;
TInt ibeginMinute=6;
TInt iendHour=4;
TInt iendMin=4;
TInt iendMinute=1;
buf.Format(_L("%02d:%02d:%02d -- %02d:%02d:%02d"), ibeginHour, ibeginMin, ibeginMinute,iendHour,iendMin,iendMinute);
itime=new (ELeave)CCtime(R_TIME,buf);
itime->ConstructL(this,(Rect()));
itime->SetRect(aRect);

// Activate the window, which makes it ready to be drawn
SetRect(aRect);
ActivateL();
}

// -----------------------------------------------------------------------------
// ChhAppView::ChhAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
ChhAppView::ChhAppView()
{
// No implementation required
}

// -----------------------------------------------------------------------------
// ChhAppView::~ChhAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
ChhAppView::~ChhAppView()
{
delete itime;
// No implementation required
}

// -----------------------------------------------------------------------------
// ChhAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void ChhAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();

// Gets the control's extent
TRect drawRect(Rect());

// Clears the screen
gc.Clear(drawRect);

}

// -----------------------------------------------------------------------------
// ChhAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void ChhAppView::SizeChanged()
{
DrawNow();
}

// -----------------------------------------------------------------------------
// ChhAppView::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// Note: although this method is compatible with earlier SDKs,
// it will not be called in SDKs without Touch support.
// -----------------------------------------------------------------------------
//
void ChhAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{

// Call base class HandlePointerEventL()
CCoeControl::HandlePointerEventL(aPointerEvent);
}
TInt ChhAppView::CountComponentControls() const
{
return 1;

}

CCoeControl* ChhAppView::ComponentControl( TInt aIndex ) const
{
switch (aIndex)
{
case 0:
return itime;
default:
return NULL;
}
}
TKeyResponse ChhAppView::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )//软键控制
{
if (itime)
return itime->OfferKeyEventL (aKeyEvent, aType);

else
return EKeyWasNotConsumed;
}
// End of File

/*
============================================================================
Name : hhAppView.h
Author :
Copyright : Your copyright notice
Description : Declares view class for application.
============================================================================
*/

#ifndef __HHAPPVIEW_h__
#define __HHAPPVIEW_h__

// INCLUDES
#include <coecntrl.h>
class CCtime;
// CLASS DECLARATION
class ChhAppView : public CCoeControl
{
public:
// New methods

/**
* NewL.
* Two-phased constructor.
* Create a ChhAppView object, which will draw itself to aRect.
* @param aRect The rectangle this view will be drawn to.
* @return a pointer to the created instance of ChhAppView.
*/
static ChhAppView* NewL(const TRect& aRect);

/**
* NewLC.
* Two-phased constructor.
* Create a ChhAppView object, which will draw itself
* to aRect.
* @param aRect Rectangle this view will be drawn to.
* @return A pointer to the created instance of ChhAppView.
*/
static ChhAppView* NewLC(const TRect& aRect);

/**
* ~ChhAppView
* Virtual Destructor.
*/
virtual ~ChhAppView();

public:
// Functions from base classes

/**
* From CCoeControl, Draw
* Draw this ChhAppView to the screen.
* @param aRect the rectangle of this view that needs updating
*/
void Draw(const TRect& aRect) const;

/**
* From CoeControl, SizeChanged.
* Called by framework when the view size is changed.
*/
virtual void SizeChanged();

/**
* From CoeControl, HandlePointerEventL.
* Called by framework when a pointer touch event occurs.
* Note: although this method is compatible with earlier SDKs,
* it will not be called in SDKs without Touch support.
* @param aPointerEvent the information about this event
*/
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
public:
TInt CountComponentControls() const;

CCoeControl* ComponentControl( TInt aIndex ) const;

TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );

private:
// Constructors

/**
* ConstructL
* 2nd phase constructor.
* Perform the second phase construction of a
* ChhAppView object.
* @param aRect The rectangle this view will be drawn to.
*/
void ConstructL(const TRect& aRect);

/**
* ChhAppView.
* C++ default constructor.
*/
ChhAppView();

private:
CCtime *itime;
};

#endif // __HHAPPVIEW_h__
// End of File

RESOURCE EDWIN r_example_editor
{
flags = EEikEdwinWidthInPixels; // 以像素为单位
width = 240; // 控件宽度
lines = 2; // 行数
maxlength = 256; // 文本最大长度

}
god_sun 2010-02-05
  • 打赏
  • 举报
回复
楼上,朋友,是这样的,我代码已经贴上去了。。
感觉没问题,但是就是什么都不显示
shuaigea12 2010-02-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 god_sun 的回复:]
引用 1 楼 a14776584 的回复:
ComponentControl()
CountComponentControls()
这两个方法处理了吗

我用的carbide c++ 新建的 UI工程。。里面没有container类,所以我在view类的construt里创建的,你说的这2个方法我没看到有啊
[/Quote]

从你的描述看,你说的View就是一个UI自己建的Container类,你看看这个View是不是继承自CCoeControl,是的话就对了,那么接下来你只要在这个类中增加ComponentControl()、CountComponentControls()两个方法,具体:
TInt CtestEditAppView::CountComponentControls() const
{
return 1;
}


CCoeControl* CtestEditAppView::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iEdit;
default:
return NULL;
}

}
god_sun 2010-02-05
  • 打赏
  • 举报
回复
rss:

RESOURCE EDWIN r_example_editor
{
flags = EEikEdwinWidthInPixels; // 以像素为单位
width = 240; // 控件宽度
lines = 2; // 行数
maxlength = 256; // 文本最大长度
}
god_sun 2010-02-05
  • 打赏
  • 举报
回复
view.cpp

/*
============================================================================
Name : testEditAppView.cpp
Author : SQS
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/

// INCLUDE FILES
#include <coemain.h>

#include "testEditAppView.h"
#include <testEdit_0xEC890DBC.rsg>
// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CtestEditAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CtestEditAppView* CtestEditAppView::NewL(const TRect& aRect)
{
CtestEditAppView* self = CtestEditAppView::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}

// -----------------------------------------------------------------------------
// CtestEditAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CtestEditAppView* CtestEditAppView::NewLC(const TRect& aRect)
{
CtestEditAppView* self = new (ELeave) CtestEditAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}

// -----------------------------------------------------------------------------
// CtestEditAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CtestEditAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();

TResourceReader aRead ;
iCoeEnv->CreateResourceReaderLC(aRead,R_EXAMPLE_EDITOR);
iEdit = new (ELeave) CEikEdwin();
iEdit->SetContainerWindowL(*this);
iEdit->ConstructFromResourceL(aRead);
iEdit->SetBackgroundColorL(KRgbRed);
CleanupStack::PopAndDestroy();
iEdit->SetExtent(TPoint( 10, 25 ), TSize(100, 30));
iEdit->SetFocus(ETrue);
// Set the windows size
SetRect(aRect);

// Activate the window, which makes it ready to be drawn
ActivateL();
}

// -----------------------------------------------------------------------------
// CtestEditAppView::CtestEditAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CtestEditAppView::CtestEditAppView()
{
// No implementation required
}

// -----------------------------------------------------------------------------
// CtestEditAppView::~CtestEditAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CtestEditAppView::~CtestEditAppView()
{
// No implementation required
delete iEdit;
iEdit = NULL;
}

// -----------------------------------------------------------------------------
// CtestEditAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CtestEditAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();

// Gets the control's extent
TRect drawRect(Rect());

// Clears the screen
gc.Clear(drawRect);

}

// -----------------------------------------------------------------------------
// CtestEditAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CtestEditAppView::SizeChanged()
{
if (iEdit)
{
iEdit->SetExtent(TPoint( 10, 25 ), TSize(100, 30));
}
// DrawNow();
}

// -----------------------------------------------------------------------------
// CtestEditAppView::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// Note: although this method is compatible with earlier SDKs,
// it will not be called in SDKs without Touch support.
// -----------------------------------------------------------------------------
//
void CtestEditAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{

// Call base class HandlePointerEventL()
CCoeControl::HandlePointerEventL(aPointerEvent);
}

//-----------------------------------------------------------------------------
// CFilelistContainer::CountComponentControls()
// Called by the framework in compound controls
// @return The number of controls in this CSimpleGridContainer
// -----------------------------------------------------------------------------
//
TInt CtestEditAppView::CountComponentControls() const
{
return 1;
// if(iEdit)
// return 1;
// else
// return 0;
//return 1; // return number of controls inside this container
}

// -----------------------------------------------------------------------------
// CFilelistContainer::ComponentControl
// Called by the framework in compound controls
// @param The index of the control to return
// @return The control for aIndex
// -----------------------------------------------------------------------------
//
CCoeControl* CtestEditAppView::ComponentControl(TInt aIndex) const
{
// return iEdit;
switch ( aIndex )
{
case 0:
return iEdit;
default:
return NULL;
}

}
// End of File

god_sun 2010-02-05
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 symart 的回复:]
把你写的代码贴在上面我看看
[/Quote]
view.h

/*
============================================================================
Name : testEditAppView.h
Author : SQS
Copyright : Your copyright notice
Description : Declares view class for application.
============================================================================
*/

#ifndef __TESTEDITAPPVIEW_h__
#define __TESTEDITAPPVIEW_h__

// INCLUDES
#include <coecntrl.h>
#include <barsread.h>
#include <eikmfne.h>
#include <eikedwin.h>

class CEikLabel;
class CEikEdwin;

// CLASS DECLARATION
class CtestEditAppView : public CCoeControl
{
public:
// New methods

/**
* NewL.
* Two-phased constructor.
* Create a CtestEditAppView object, which will draw itself to aRect.
* @param aRect The rectangle this view will be drawn to.
* @return a pointer to the created instance of CtestEditAppView.
*/
static CtestEditAppView* NewL(const TRect& aRect);

/**
* NewLC.
* Two-phased constructor.
* Create a CtestEditAppView object, which will draw itself
* to aRect.
* @param aRect Rectangle this view will be drawn to.
* @return A pointer to the created instance of CtestEditAppView.
*/
static CtestEditAppView* NewLC(const TRect& aRect);

/**
* ~CtestEditAppView
* Virtual Destructor.
*/
virtual ~CtestEditAppView();

public:
// Functions from base classes

/**
* From CCoeControl, Draw
* Draw this CtestEditAppView to the screen.
* @param aRect the rectangle of this view that needs updating
*/
void Draw(const TRect& aRect) const;

/**
* From CoeControl, SizeChanged.
* Called by framework when the view size is changed.
*/
virtual void SizeChanged();

/**
* From CoeControl, HandlePointerEventL.
* Called by framework when a pointer touch event occurs.
* Note: although this method is compatible with earlier SDKs,
* it will not be called in SDKs without Touch support.
* @param aPointerEvent the information about this event
*/
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);

private:
// Constructors
CEikEdwin* iEdit;

/**
* ConstructL
* 2nd phase constructor.
* Perform the second phase construction of a
* CtestEditAppView object.
* @param aRect The rectangle this view will be drawn to.
*/
void ConstructL(const TRect& aRect);

/**
* CtestEditAppView.
* C++ default constructor.
*/
CtestEditAppView();

/**
* From CCoeControl,CountComponentControls.
*/
TInt CountComponentControls() const;

/**
* From CCoeControl,ComponentControl.
*/
CCoeControl* ComponentControl( TInt aIndex ) const;

};

#endif // __TESTEDITAPPVIEW_h__
// End of File

god_sun 2010-02-03
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 symart 的回复:]
TInt CtestEditAppView::CountComponentControls() const
    {
     
        return 1;   
        }

// -----------------------------------------------------------------------------
// CFilelistContainer::ComponentControl
// Called by the framework in compound controls   
// @param The index of the control to return
// @return The control for aIndex
// -----------------------------------------------------------------------------
//
CCoeControl* CtestEditAppView::ComponentControl(TInt aIndex) const
    { 
  switch (aIndex)
{
case 0:
return iEdit;
default:
return NULL;

}


[/Quote]
还是一片白色,,唉,我实在搞不懂symbian~
symart 2010-02-03
  • 打赏
  • 举报
回复
TInt CtestEditAppView::CountComponentControls() const
{

return 1;
}

// -----------------------------------------------------------------------------
// CFilelistContainer::ComponentControl
// Called by the framework in compound controls
// @param The index of the control to return
// @return The control for aIndex
// -----------------------------------------------------------------------------
//
CCoeControl* CtestEditAppView::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iEdit;
default:
return NULL;
}
}

god_sun 2010-02-03
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 feiqhk 的回复:]
void CtestEditAppView::SizeChanged()
{
iEdit->SetExtent(TPoint( 10, 25 ), iEdit->MaximumWidth()());
}

用 inputEdit->MaximumWidth() 试试,MinimumSize 可能为0
[/Quote]

void CtestEditAppView::SizeChanged()
{
iEdit->SetExtent(TPoint( 10, 25 ), TSize(100, 30));
DrawNow();
}

还是不行~~
symart 2010-02-03
  • 打赏
  • 举报
回复
把你写的代码贴在上面我看看
jmulxg 2010-02-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 god_sun 的回复:]
引用 1 楼 a14776584 的回复:
ComponentControl()
CountComponentControls()
这两个方法处理了吗

我用的carbide c++ 新建的 UI工程。。里面没有container类,所以我在view类的construt里创建的,你说的这2个方法我没看到有啊
[/Quote]


重写CCoeContorl的虚接口
ComponentControl()
CountComponentControls()
jmulxg 2010-02-02
  • 打赏
  • 举报
回复
参考..\S60Ex目录下Editor例子

god_sun 2010-02-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 a14776584 的回复:]
ComponentControl()
CountComponentControls()
这两个方法处理了吗
[/Quote]
我用的carbide c++ 新建的 UI工程。。里面没有container类,所以我在view类的construt里创建的,你说的这2个方法我没看到有啊
a14776584 2010-02-02
  • 打赏
  • 举报
回复
ComponentControl()
CountComponentControls()
这两个方法处理了吗
feiqhk 2010-02-02
  • 打赏
  • 举报
回复
void CtestEditAppView::SizeChanged()
{
iEdit->SetExtent(TPoint( 10, 25 ), iEdit->MaximumWidth()());
}

用 inputEdit->MaximumWidth() 试试,MinimumSize 可能为0
加载更多回复(8)

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧