Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User uponline's Avatar
    Join Date
    Nov 2004
    Posts
    23
    Hi there !
    When I write these code in my project ,but it never paint a bitmap , I don't know what's happend , tell me how to do it , please .

    Code:
    -------------
    IMAppView.h
    -------------
    CFbsBitmap* iBitmap;                                 
    
    
    
    
    ---------------
    IMAppView.cpp
    ---------------
    void CIMAppView::ConstructL(const TRect& aRect)      
    	{                                             
    	CreateWindowL();                              
    	LoadBitmapL();                                
    	SetRect(aRect);                               
    	ActivateL();                                  
    	}                                             
    
    void CIMAppView::LoadBitmapL()                       
    	{                                             
    	iBitmap=new (ELeave)CFbsBitmap();             
    	_LIT(KMBMFILE,"\\system\\apps\\IM\\IM.mbm");  
    	TFileName file(KMBMFILE);                     
    	User::LeaveIfError(CompleteWithAppPath(file));
    	                                              
    	TRAPD(err,iBitmap->Load(file,EMbmImFace);)    
    	User::LeaveIfError(err);                       
    	                                              
    	}                                             
    
    void CIMAppView::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);                           
    	gc.BitBlt(TPoint(20,20), iBitmap);            
    	                                              
    	}
    Last edited by uponline; 2008-12-16 at 08:49.

  2. #2
    Nokia Developer Champion stenlik's Avatar
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    your code looks correct.

    1/So what really happens? Application runs and you see only white screen?

    2/The CIMAppView is derived form the CCoeControl, isn't it?

    3/How do you create CIMAppView - can you show us the code?

    4/ When you debug the code - id the Draw() method called?

    5/ What are aRect values in the ConstructL() method?

    BR
    STeN

  3. #3
    Registered User uponline's Avatar
    Join Date
    Nov 2004
    Posts
    23
    Code:
    /*
     ============================================================================
     Name		: IMAppView.h
     Author	  : 王秉先
     Copyright   : CartoonSMS
     Description : Declares view class for application.
     ============================================================================
     */
    
    #ifndef __IMAPPVIEW_h__
    #define __IMAPPVIEW_h__
    
    // INCLUDES
    #include <coecntrl.h>
    
    // CLASS DECLARATION
    class CFbsBitmap;
    class CIMAppView : public CCoeControl
    	{
    public:
    	// New methods
    
    	/**
    	 * NewL.
    	 * Two-phased constructor.
    	 * Create a CIMAppView 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 CIMAppView.
    	 */
    	static CIMAppView* NewL(const TRect& aRect);
    
    	/**
    	 * NewLC.
    	 * Two-phased constructor.
    	 * Create a CIMAppView object, which will draw itself
    	 * to aRect.
    	 * @param aRect Rectangle this view will be drawn to.
    	 * @return A pointer to the created instance of CIMAppView.
    	 */
    	static CIMAppView* NewLC(const TRect& aRect);
    
    	/**
    	 * ~CIMAppView
    	 * Virtual Destructor.
    	 */
    	virtual ~CIMAppView();
    
    public:
    	// Functions from base classes
    
    	/**
    	 * From CCoeControl, Draw
    	 * Draw this CIMAppView 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);
    	void LoadBitmapL();
    private:
    	// Constructors
    
    	/**
    	 * ConstructL
    	 * 2nd phase constructor.
    	 * Perform the second phase construction of a
    	 * CIMAppView object.
    	 * @param aRect The rectangle this view will be drawn to.
    	 */
    	void ConstructL(const TRect& aRect);
    
    	/**
    	 * CIMAppView.
    	 * C++ default constructor.
    	 */
    	CIMAppView();
    	CFbsBitmap* iBitmap;
    
    	};
    
    #endif // __IMAPPVIEW_h__
    // End of File
    
    
    
    
    /*
     ============================================================================
     Name	     : IMAppView.cpp
     Author	     : 王秉先
     Copyright   : CartoonSMS
     Description : Application view implementation
     ============================================================================
     */
    
    // INCLUDE FILES
    #include <coemain.h>
    #include <aknutils.h>
    #include <IM.mbg>
    #include "IMAppView.h"
    
    // ============================ MEMBER FUNCTIONS ===============================
    
    // -----------------------------------------------------------------------------
    // CIMAppView::NewL()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CIMAppView* CIMAppView::NewL(const TRect& aRect)
    	{
    	CIMAppView* self = CIMAppView::NewLC(aRect);
    	CleanupStack::Pop(self);
    	return self;
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::NewLC()
    // Two-phased constructor.
    // -----------------------------------------------------------------------------
    //
    CIMAppView* CIMAppView::NewLC(const TRect& aRect)
    	{
    	CIMAppView* self = new (ELeave) CIMAppView;
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::ConstructL()
    // Symbian 2nd phase constructor can leave.
    // -----------------------------------------------------------------------------
    //
    void CIMAppView::ConstructL(const TRect& aRect)
    	{
    	// Create a window for this application view
    	CreateWindowL();
    	LoadBitmapL();
    	// Set the windows size
    	SetRect(aRect);
    
    	// Activate the window, which makes it ready to be drawn
    	ActivateL();
    	}
    
    void CIMAppView::LoadBitmapL()
    	{
    	iBitmap=new (ELeave)CFbsBitmap();
    	 _LIT(KMBMFILE,"\\system\\apps\\IM\\IM.mbm");
    	
    	 TFileName file(KMBMFILE);
    	// TFilename fname = _L("Multi.mbm");
    	 
    	 User::LeaveIfError(CompleteWithAppPath(file));
    	 
    	 TRAPD(err,iBitmap->Load(file,EMbmImFace);)
    	 //User::LeaveIfError(iBitmap->Load(file,EMbmImFace));
    	 
    	 User::LeaveIfError(err);
    	 
    	}
    
    
    // -----------------------------------------------------------------------------
    // CIMAppView::CIMAppView()
    // C++ default constructor can NOT contain any code, that might leave.
    // -----------------------------------------------------------------------------
    //
    CIMAppView::CIMAppView()
    	{
    	// No implementation required
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::~CIMAppView()
    // Destructor.
    // -----------------------------------------------------------------------------
    //
    CIMAppView::~CIMAppView()
    	{
    	// No implementation required
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::Draw()
    // Draws the display.
    // -----------------------------------------------------------------------------
    //
    void CIMAppView::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);
    	gc.BitBlt(TPoint(20,20), iBitmap);
    	
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::SizeChanged()
    // Called by framework when the view size is changed.
    // -----------------------------------------------------------------------------
    //
    void CIMAppView::SizeChanged()
    	{
    	DrawNow();
    	}
    
    // -----------------------------------------------------------------------------
    // CIMAppView::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 CIMAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    	{
    
    	// Call base class HandlePointerEventL()
    	CCoeControl::HandlePointerEventL(aPointerEvent);
    	}
    
    // End of File
    Last edited by uponline; 2008-12-16 at 08:48. Reason: Change Formation

  4. #4
    Registered User uponline's Avatar
    Join Date
    Nov 2004
    Posts
    23
    when I run it , it's white screen, I used wizard of Carbide.C++ and never change kernel code ,

    Quote Originally Posted by stenlik View Post
    Hi,

    your code looks correct.

    1/So what really happens? Application runs and you see only white screen?

    2/The CIMAppView is derived form the CCoeControl, isn't it?

    3/How do you create CIMAppView - can you show us the code?

    4/ When you debug the code - id the Draw() method called?

    5/ What are aRect values in the ConstructL() method?

    BR
    STeN

  5. #5
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,743
    Does the file \system\apps\IM\IM.mbm exist? Your current code expects it to be in epoc32\release\winscw\udeb\z\system\apps\IM\IM.mbm when you execute it in the emulator.
    Note that TRAPD does not do anything with methods which do not leave. And Load is not LoadL, so it does not leave. Instead it returns an error code, so you could rather
    Code:
    TInt err=iBitmap->Load(file,EMbmImFace);
    then you will probably get a -1, which you can decode via checking http://wiki.forum.nokia.com/index.php/Error_codes

  6. #6
    Registered User moshing's Avatar
    Join Date
    Jan 2008
    Posts
    11
    I'm no expert, but I know that phones like .png's

  7. #7
    Regular Contributor niyaz.khan's Avatar
    Join Date
    Sep 2006
    Posts
    61
    hi,

    Did u checked the applcation with giving full source mbm path.
    Also try with removing DrawNow() from SizeChanged() function.
    Niyaz

  8. #8
    Registered User uponline's Avatar
    Join Date
    Nov 2004
    Posts
    23
    I'v done . Thanks guys.
    Code:
    _LIT(KMBMFILE,"\\system\\apps\\IM\\IM.mbm");
    I changed this,and it's run .
    Code:
    _LIT(KMBMFILE,"\\resource\\apps\\IM.mbm");

  9. #9
    Nokia Developer Champion stenlik's Avatar
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Ohh yes - I overlook the Load() bug...

    BR
    STeN

Similar Threads

  1. [moved] Theme Studio Error
    By TalJ in forum Themes/Carbide.ui
    Replies: 2
    Last Post: 2009-09-06, 03:39
  2. Fastest way to draw stretched bitmap
    By neois in forum Symbian C++
    Replies: 5
    Last Post: 2008-03-10, 07:17
  3. problem when importing from carbide c++ to vs 2003!
    By misfit.physics in forum Symbian Tools & SDKs
    Replies: 12
    Last Post: 2008-02-19, 09:45
  4. How can I reverse the color in the screen?
    By sanmu163 in forum Symbian User Interface
    Replies: 11
    Last Post: 2006-08-18, 08:12
  5. Replies: 2
    Last Post: 2004-08-04, 09:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved