Click here to Skip to main content
Click here to Skip to main content

Loading images with an undocumented API in PPC 2002

, 12 Aug 2002 CPOL
Rate this:
Please Sign up or sign in to vote.
This article describes an undocumented API that enables you to load images (bmp, gif etc.) from files under Pocket PC 2002


Loading images under windows can always be a painful process, especially if the image formats are like JPEG, GIF or PNG. There's always the Imgdecmp library, that does a good job, but its also a bit of a bother with the documentation being so thin and all that. The other day I was trying to load a bitmap from my device using LoadImage, but somehow I kept getting the dreaded "The handle is invalid" error. So I did a search on the MFC code that ships with the PPC SDK in hope of finding a piece of code that will help me solve the puzzle. 

One thing led to another. I suddenly came across HBITMAP SHLoadImageFile(LPCTSTR pszFileName) in aygshell.h. Bingo! I had suddenly uncovered an undocumented API! No trace of it in MSDN, a search in Google produced nothing!! Since then, I've tried this API with gif's and bmp's also and I guess it will work fine for jpeg's and png's too. Here's a code sample...

// assuming code is in the OnDraw method of a view....

CBitmap bitmap;

// Attach the bitmap object to the HBITMAP returned by SHLoadImageFile
bitmap.Attach(SHLoadImageFile(_T("/My Documents/mcdonalds.gif")));

BITMAP bmpInfo;

CDC bitmapDC;
CBitmap* pOldBitmap = bitmapDC.SelectObject(&bitmap);

pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &bitmapDC, 
            0, 0, SRCCOPY);


That's all for now.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tanzim Husain
Web Developer
United States United States
No Biography provided

Comments and Discussions

GeneralImages not in the Resource directory Pinmemberspret8515-Sep-09 0:34 
Questionhow to load tiff file image from java or c Pinmembermikerahul13-Oct-07 2:40 
Questionloading JPEG from stream? Pinmemberhouari_id20-Mar-06 9:18 
GeneralThe unanimation bug Pinmembereagleanec20-Feb-06 22:15 
QuestionHow to show image from jpeg stream? Pinmemberrobert101417-Sep-05 18:55 
Generalfriends, you solved my great problem Pinmemberjiang shanshan25-Aug-05 20:04 
Generalworks on pocket pc 2003 as well PinsussKang Jodhi7-Mar-05 21:56 
GeneralWorks with JPG too PinsussAnonymous7-Feb-05 17:46 
Questionhow about in eVB ? PinsussAnonymous16-Jan-04 2:50 
QuestionUse SHLoadImageFile in dialog-based application? Pinmembercwei_lim30-Dec-03 15:37 
GeneralAbout SHLoadImageFile PinmemberALopatkin26-Oct-03 23:34 
GeneralRe: About SHLoadImageFile PinsussAnonymous19-Nov-03 19:16 
GeneralRe: About SHLoadImageFile PinmemberLiptenSoup14-Jan-04 12:09 
GeneralIt is in MSDN PinsussAnonymous26-Oct-03 1:06 
GeneralRe: It is in MSDN PinsussAnonymous13-Feb-04 4:22 
GeneralGive a hand pls~~^_^ Pinmemberwehaha10-Sep-03 3:19 
GeneralI couldnt compile.... PinmemberRamees10-May-03 22:14 
GeneralRe: I couldnt compile.... PinmemberTanzim Husain30-May-03 20:11 
GeneralRe: I couldnt compile.... PinsussAnonymous8-Jun-03 1:12 
GeneraleVB PinsussChetan Kapadia17-Jan-03 3:58 
QuestionHow to Images in WinCE4.1 - A Probable solution Pinmembertanzim25-Sep-02 23:41 
QuestionHow to Images in WinCE4.1 ? PinsussDrWatson2-Sep-02 0:12 
AnswerRe: How to Images in WinCE4.1 ? Pinmembertanzim2-Sep-02 23:19 
GeneralRe: How to Images in WinCE4.1 ? PinsussDrWatson3-Sep-02 21:32 
GeneralRe: How to Images in WinCE4.1 ? PinsussHouser8-Sep-02 0:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 13 Aug 2002
Article Copyright 2002 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid