Using SetWindowRgn on bitmap buttons
-
I've got a bitmap on a button and I want the user to be only able to click the area of the button that is covered by the bitmap. For circular bitmaps I've used the following code:
CRect button_rect ; // size of button
HRGN rgn ;button->GetClientRect ( &button_rect ) ;
rgn = CreateEllipticRgn( 0,
0,
button_rect.Width(),
button_rect.Height() );button->SetWindowRgn ( rgn,
TRUE ) ;However I've got a bitmap that has a rectangle that is diagonal across the bitmap, does anyone know how I can create a HRGN object with the points for the diagonal rectangle. TIA,
-
I've got a bitmap on a button and I want the user to be only able to click the area of the button that is covered by the bitmap. For circular bitmaps I've used the following code:
CRect button_rect ; // size of button
HRGN rgn ;button->GetClientRect ( &button_rect ) ;
rgn = CreateEllipticRgn( 0,
0,
button_rect.Width(),
button_rect.Height() );button->SetWindowRgn ( rgn,
TRUE ) ;However I've got a bitmap that has a rectangle that is diagonal across the bitmap, does anyone know how I can create a HRGN object with the points for the diagonal rectangle. TIA,
-
I think you can use
CreatePolygonRgn(...)
Also, you can use the CRgn wrapper instead of HRGN:CRgn rgn; CPoint pt[3]; pt[0].x = 10; pt[0].y = 10; pt[1].x = 100; pt[1].y = 100; pt[2].x = 10; pt[2].y = 100; rgn.CreatePolygonRgn(pt,3,ALTERNATE);
this is this.