|
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
|