Re: Clickable images on a dialog
Alright, heres the code: IDC_DETECTION_ZONE is the ID of the image -
hopefully the rest is self explanatory- the image is going to be white
btw.
Shame it doesn't work! btw, do I need to call OnPaint in the dialog
initialisation routine?
I didn't think you had to (I didn't in this case)
void CLogoDetectConfigure::OnPaint()
{
CWnd *pCanvas = GetDlgItem( IDC_DETECTION_ZONE );
CPaintDC dc( pCanvas ); // device context for painting
//Create a memory dc
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
CRect image_location;
pCanvas->GetClientRect(&image_location);
//create a memory bitmap, and initialize it to all white
CBitmap MemBmp;
MemBmp.CreateCompatibleBitmap(&dc,100,100);
CBitmap *pOldMemBmp = MemDC.SelectObject(&MemBmp);
MemDC.FillSolidRect(image_location.left, image_location.top,
image_location.Width(), image_location.Height() ,RGB(255,255,255));
//create a dc to hold the original bitmap
CDC BmpDC;
BmpDC.CreateCompatibleDC(&dc);
CBitmap Bmp;
CBitmap *pOldBmp = BmpDC.SelectObject(&Bmp);
MemDC.BitBlt(image_location.left, image_location.top,
image_location.Width(), image_location.Height(), &BmpDC,14,14,SRCCOPY);
BmpDC.SelectObject(&pOldBmp);
MemDC.SelectObject(pOldMemBmp);
// Do not call CDialog::OnPaint() for painting messages
}