Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying image in WIN32, Why its not displayed?
    primarykey
    data
    text
    <p>I want to load a BitMap image in a pic box I created inside a window...picBoxDisp is created using following mechanism..</p> <pre><code>picBoxDisp = CreateWindow("STATIC", "image box", WS_VISIBLE |WS_CHILD | SS_BITMAP |WS_TABSTOP | WS_BORDER, 50, 50, 250, 300, hwnd , (HMENU)10000, NULL, NULL); </code></pre> <p>Now Next I created a hBitmap object and loaded an image in to it...</p> <pre><code>hBitmap = (HBITMAP) LoadImage(NULL,szFileName,IMAGE_BITMAP,0,0, LR_LOADFROMFILE| LR_DEFAULTSIZE); SendMessage(picBoxDisp,STM_SETIMAGE,(WPARAM) IMAGE_BITMAP,(LPARAM) NULL); //now assign the new image //Create a compatible DC for the original size bitmap, for example originalMemDc. HDC originalDC = GetDC((HWND)hBitmap); HDC originalMemDC = CreateCompatibleDC(originalDC); if(originalMemDC==NULL){ MessageBox(NULL,"Problem while creating DC.","Error",MB_OK); } //Select hBitmap into originalMemDc. SelectObject(originalMemDC,hBitmap); //Create a compatible DC for the resized bitmap, for example resizedMemDc. HDC picBoxDC = GetDC(picBoxDisp); HDC resizedMemDC = CreateCompatibleDC(picBoxDC); //Create a compatible bitmap of the wanted size for the resized bitmap, HBITMAP hResizedBitmap = CreateCompatibleBitmap(picBoxDC,250,300); //Select hResizedBitmap into resizedMemDc. SelectObject(resizedMemDC,hResizedBitmap); //Stretch-blit from originalMemDc to resizedMemDc. //BitBlt(resizedMemDC,0,0,250,300,originalMemDC,0,0,SRCCOPY); BITMAP bmp_old,bmp_new; GetObject(hBitmap,sizeof(bmp_old),&amp;bmp_old); GetObject(hResizedBitmap,sizeof(bmp_new),&amp;bmp_new); StretchBlt ( resizedMemDC,0,0,bmp_new.bmWidth,bmp_new.bmHeight, originalMemDC,0,0,bmp_old.bmWidth,bmp_new.bmHeight, SRCCOPY); ////De-select the bitmaps. if((resizedMemDC==NULL)||(hResizedBitmap == NULL)) { MessageBox(NULL,"Something is NULL","Error",MB_OK); } else //Set hResizedBitmap as the label image with STM_SETIMAGE SendMessage(picBoxDisp,STM_SETIMAGE, (WPARAM) IMAGE_BITMAP,(LPARAM) hResizedBitmap); </code></pre> <p><strong>I just cant understand, why the above code is not working ?</strong></p> <p>Thanks in advance, </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload