Creating persistant CBitmap from .bmp file

Creating persistant CBitmap from .bmp file

Post by Trevor Armstro » Thu, 20 Jun 2002 21:01:16



In my application I am trying to store a CBitmap object created from a
bmp file on the Pocket PC.  To accomplish this I am using the
following lines of code;

HBITMAP hBmp = SHLoadDIBitmap(TEXT("\\windows\\main_bg.bmp"));
m_pCBitmap = m_pCBitmap->FromHandle(hBmp);

Of course this doesn't work because the FromHandle operation returns a
pointer to a temporary CBitmap object which gets distroyed the next
time the application is idle.  So the next time I go to use the
pointer it causes an exception.  Which leads me to my question, how
can I create a persistant CBitmap object from a bmp file?  Thanks in
advance for any help you can give.

Trevor

 
 
 

Creating persistant CBitmap from .bmp file

Post by Nathan Lewi » Thu, 20 Jun 2002 21:26:57


Try using the Attach() and Detach() methods from the CGdiObject base class
instead.

--

Nathan Lewis
OCP Software

Check out the WinCE CAB Manager at http://www.ocpsoftware.com
The *Best* Windows CE CAB file viewer / editor on the market!


Quote:> In my application I am trying to store a CBitmap object created from a
> bmp file on the Pocket PC.  To accomplish this I am using the
> following lines of code;

> HBITMAP hBmp = SHLoadDIBitmap(TEXT("\\windows\\main_bg.bmp"));
> m_pCBitmap = m_pCBitmap->FromHandle(hBmp);

> Of course this doesn't work because the FromHandle operation returns a
> pointer to a temporary CBitmap object which gets distroyed the next
> time the application is idle.  So the next time I go to use the
> pointer it causes an exception.  Which leads me to my question, how
> can I create a persistant CBitmap object from a bmp file?  Thanks in
> advance for any help you can give.

> Trevor


 
 
 

Creating persistant CBitmap from .bmp file

Post by Vincenzo Tibull » Mon, 24 Jun 2002 21:45:18


You can also save the HBITMAP handle, and obtain again the CBitmap object
using FromHandle in every message handler you need it.

Vincenzo.


Quote:> In my application I am trying to store a CBitmap object created from a
> bmp file on the Pocket PC.  To accomplish this I am using the
> following lines of code;

> HBITMAP hBmp = SHLoadDIBitmap(TEXT("\\windows\\main_bg.bmp"));
> m_pCBitmap = m_pCBitmap->FromHandle(hBmp);

> Of course this doesn't work because the FromHandle operation returns a
> pointer to a temporary CBitmap object which gets distroyed the next
> time the application is idle.  So the next time I go to use the
> pointer it causes an exception.  Which leads me to my question, how
> can I create a persistant CBitmap object from a bmp file?  Thanks in
> advance for any help you can give.

> Trevor

 
 
 

1. Loading BMP Files and RLE BMP Files?

I have seen several questions regarding BMP file loading and
CreateDIBSection().

I have a sample program with source that loads BMP files and adds RLE
support to the CE platforms.  The program loads BMP files from disk and
displays them in the main window.

It automatically adds proportional scrollbars to the window if needed.  The
code compiles and runs on all of the emulators and was tested HPC2000
(Jornado 720) and PPC2002 (Jornada 568).  The code also compiles for Win32
and runs on 95,98,NT,2K and XP.

The example executables are compiled with my DIB library that supports RLE
compression on all of the above platforms and uses CreateDIBSection().  The
sample source code uses a the LoadImage() and SHLoadDIBitmap() routines and
do not support RLE compression.

Download if your interested at:

www.forbisoft.com

2. smtpmta 1.05 and non delivery reports

3. How can convert .PSW file (POCKET WORD file) to BMP file?

4. Different spin on offscreen bitmaps

5. Why I cann't convert .pwi file to bmp file?

6. senior application developer

7. Converting a PWI file to a BMP file?

8. Getting Oracle7 to work

9. What is the best way 2 programmatically display graphics files (ie JPEG, BMP) in Pocket PC?

10. How can I print a Pocket excel documents to a BMP file?

11. bmp or 2bp files

12. How to load a bitmap from a BMP file?

13. ActiveSync/WINS Persistant entry