I created a custom static window that displays a bitmap; this window is a child window of some other window. Now I want to capture mouse events for this window so that I can provide functionality for cropping the image.
But the problem is that mouse events are not being sent to this child window .... The following is a code snippet of the WndProc
child window.
WNDPROC origStatProc; // Variable which stores the handle of BITMAP image HBITMAP hBitmap=NULL; 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,&paintSt); GetClientRect(hwnd,&aRect); if(hBitmap!=NULL) { HDC memDC = CreateCompatibleDC(hdc); if(memDC!=NULL) { BITMAP bmp; GetObject(hBitmap,sizeof(bmp),&bmp); SelectObject(memDC,hBitmap); SetStretchBltMode(hdc,HALFTONE); StretchBlt(hdc,0,0,aRect.right,aRect.bottom, memDC,0,0,bmp.bmWidth,bmp.bmHeight, SRCCOPY); DeleteObject(&bmp); ReleaseDC(hwnd,memDC); } } // the code for painting EndPaint(hwnd,&paintSt); } break; case STM_SETIMAGE: { InvalidateRect(hwnd,&aRect,true); } break; case WM_LBUTTONDOWN: { int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); char xstr[10]; _itoa(xPos,xstr,10); MessageBox(NULL,xstr,"X Value ",MB_OK); } break; default: return origStatProc(hwnd,msg,wParam,lParam); } return 0; }
Can someone tell me what else I need to capture mouse events inside this Child window ...
source share