子视窗控制项(二十四)

2010-12-30 21:12:42 · 作者: · 浏览: 33280
cy / 8 ;

Triangle (pdis->hDC, pt) ;
pt[0].x = 3 * cx / 8 ; pt[0].y = 5 * cy / 8 ;
pt[1].x = 5 * cx / 8 ; pt[1].y = 5 * cy / 8 ;
pt[2].x = 4 * cx / 8 ; pt[2].y = 7 * cy / 8 ;

Triangle (pdis->hDC, pt) ;
pt[0].x = 3 * cx / 8 ; pt[0].y = 3 * cy / 8 ;
pt[1].x = 3 * cx / 8 ; pt[1].y = 5 * cy / 8 ;
pt[2].x = 1 * cx / 8 ; pt[2].y = 4 * cy / 8 ;

Triangle (pdis->hDC, pt) ;
break ;
}

// Invert the rectangle if the button is selected

if (pdis->itemState & ODS_SELECTED)
InvertRect (pdis->hDC, &pdis->rcItem) ;

// Draw a focus rectangle if the button has the focus

if (pdis->itemState & ODS_FOCUS)
{
pdis->rcItem.left += cx / 16 ;
pdis->rcItem.top += cy / 16 ;
pdis->rcItem.right -= cx / 16 ;
pdis->rcItem.bottom-= cy / 16 ;

DrawFocusRect (pdis->hDC, &pdis->rcItem) ;
}
return 0 ;

case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}

该程式在其显示区域的中央包含了两个按钮,如图9-2所示。左边的按钮有四个三角形指向按钮的中央,按下该按钮时,视窗的尺寸将缩小10%。右边的按钮有四个向外指的三角形,按下此按钮时,视窗的尺寸将增大10%。

如果您只需要在按钮中显示图示或点阵图,您可以用BS_ICON或BS_BITMAP样式,并用BM_SETIMAGE讯息设定点阵图。但是,对於BS_OWN