Click here to get back home

How to display picture on Smartphone 2003?

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
How to display picture on Smartphone 2003? Aaron 09-27-2005
Get Chitika Premium
Posted by Aaron on September 27, 2005, 7:32 am
Please log in for more thread options
I have problem in displaying picture on Smartphone. I cannot see the picture.
The picture is never shown successfully. I copy my code here. It could be
great if someone can tell me where it goes wrong or give same code samples
that I can display picture on the Smartphone.

Code:
LRESULT OnCreate(
HWND hwnd,
CREATESTRUCT* lParam
)
{
// create the menu bar
SHMENUBARINFO mbi;
ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_HELLO_MENUBAR;
mbi.hInstRes = g_hInst;
if(!SHCreateMenuBar(&mbi))
{
// Couldn't create the menu bar. Fail creation of the window.
return(-1);
}

// Get our message text.
if(0 == LoadString(g_hInst, IDS_HELLO_MESSAGE, g_szMessage,
ARRAYSIZE(g_szMessage)))
{
// Couldn't load the string. Fail creation of the window.
return(-1);
}

// Do other window creation related things here.
PAINTSTRUCT ps = ;
RECT rect = ;
BITMAP bm = ;
HDC hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
HBITMAP hBmp = SHLoadImageFile(_T("\Storage\Program
Files\Pics\test.gif"));
if(hBmp == NULL)
{
MessageBox(hwnd, _T("can't load image"), _T("Error"), MB_OK);
}

GetObject(hBmp, sizeof(bm), &bm);

HDC hdcTemp = CreateCompatibleDC(hdc);
HANDLE oldBmp = SelectObject(hdcTemp, hBmp );
//SelectObject(hdcTemp, hBmp );

//BitBlt(hdc, 0, 0,rect.right,rect.bottom, hdcTemp, 0, 0, SRCCOPY);
StretchBlt(hdc,0,0,rect.right,rect.bottom,
hdcTemp,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);

DeleteObject(hBmp);
EndPaint (hwnd, &ps);
SelectObject(hdcTemp,oldBmp);
DeleteDC(hdcTemp);
DeleteDC(hdc) ;

return(0); // continue creation of the window
}


Thanks in advance.

Aaron


Posted by Ilya Manin on October 23, 2005, 10:22 am
Please log in for more thread options
You have to handle WM_PAINT message and draw the picture there. (don't draw
in WM_CREATE message)

>I have problem in displaying picture on Smartphone. I cannot see the
>picture.
> The picture is never shown successfully. I copy my code here. It could be
> great if someone can tell me where it goes wrong or give same code samples
> that I can display picture on the Smartphone.
>
> Code:
> LRESULT OnCreate(
> HWND hwnd,
> CREATESTRUCT* lParam
> )
> {
> // create the menu bar
> SHMENUBARINFO mbi;
> ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
> mbi.cbSize = sizeof(SHMENUBARINFO);
> mbi.hwndParent = hwnd;
> mbi.nToolBarId = IDR_HELLO_MENUBAR;
> mbi.hInstRes = g_hInst;
> if(!SHCreateMenuBar(&mbi))
> {
> // Couldn't create the menu bar. Fail creation of the window.
> return(-1);
> }
>
> // Get our message text.
> if(0 == LoadString(g_hInst, IDS_HELLO_MESSAGE, g_szMessage,
> ARRAYSIZE(g_szMessage)))
> {
> // Couldn't load the string. Fail creation of the window.
> return(-1);
> }
>
> // Do other window creation related things here.
> PAINTSTRUCT ps = ;
> RECT rect = ;
> BITMAP bm = ;
> HDC hdc = BeginPaint(hwnd, &ps);
> GetClientRect(hwnd, &rect);
> HBITMAP hBmp = SHLoadImageFile(_T("\Storage\Program
> Files\Pics\test.gif"));
> if(hBmp == NULL)
> {
> MessageBox(hwnd, _T("can't load image"), _T("Error"), MB_OK);
> }
>
> GetObject(hBmp, sizeof(bm), &bm);
>
> HDC hdcTemp = CreateCompatibleDC(hdc);
> HANDLE oldBmp = SelectObject(hdcTemp, hBmp );
> //SelectObject(hdcTemp, hBmp );
>
> //BitBlt(hdc, 0, 0,rect.right,rect.bottom, hdcTemp, 0, 0, SRCCOPY);
> StretchBlt(hdc,0,0,rect.right,rect.bottom,
> hdcTemp,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
>
> DeleteObject(hBmp);
> EndPaint (hwnd, &ps);
> SelectObject(hdcTemp,oldBmp);
> DeleteDC(hdcTemp);
> DeleteDC(hdc) ;
>
> return(0); // continue creation of the window
> }
>
>
> Thanks in advance.
>
> Aaron




Similar ThreadsPosted
XmlDocument on Smartphone SDK 2003 with VS 2003 July 21, 2005, 11:24 am
Smartphone Application Display October 1, 2005, 11:38 pm
Sign on smartphone display November 27, 2008, 10:32 am
How to implement ICOntact::Display() for smartphone 2003se? January 12, 2007, 8:49 pm
Smartphone Display Design in a VB 2005 program. January 25, 2008, 3:23 pm
Camera and picture June 26, 2008, 2:29 pm
VB.NET: Reduce picture size? July 19, 2005, 9:24 pm
Notification when a picture is snapped June 19, 2006, 3:30 pm
How to replace the title bar area with my own picture? September 26, 2005, 12:03 pm
Question about picture caller id on magneto November 7, 2005, 12:50 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap