Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy the following code is not working?
    primarykey
    data
    text
    <p>I have Created a static control using following styles...</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); SetWindowLongPtr(picBoxDisp,GWLP_WNDPROC,(LONG) dispWndProc); </code></pre> <p>from someplace in my program I have the following code..</p> <pre><code>SendMessage(picBoxDisp,STM_SETIMAGE, (WPARAM) IMAGE_BITMAP,(LPARAM) hBitmap); </code></pre> <p>now inside the dispWndProc I have the following code..</p> <pre><code>LRESULT CALLBACK dispWndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam) { static HDC hdc; static PAINTSTRUCT paintSt; static RECT aRect; switch(msg) { case WM_PAINT: { hdc = BeginPaint(hwnd,&amp;paintSt); GetClientRect(hwnd,&amp;aRect); // the code for painting EndPaint(hwnd,&amp;paintSt); } break; case STM_SETIMAGE: { //painting code; HBITMAP img = (HBITMAP)lParam; BITMAP bmp; GetObject(img,sizeof(bmp),&amp;bmp); HDC imgDC = GetDC((HWND)img); HDC memDC = CreateCompatibleDC(imgDC); SelectObject(memDC,img); if((img==NULL))// ||(imgDC==NULL)||(memDC==NULL)) { MessageBox(NULL,"img is NULL","Bad Programming!!! Error",MB_OK); } else { StretchBlt(hdc,0,0,aRect.right,aRect.bottom, memDC,0,0,bmp.bmWidth,bmp.bmHeight, SRCCOPY); } } break; default: return DefWindowProc(hwnd,msg,wParam,lParam); } return 0; } </code></pre> <p><strong>can anyone tell why the lParam doesnt typecast back to HBITMAP.... why img is NULL ?</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