void drawrect( HDC hdc, int x1, int y1, int x2, int y2, int color1, int color2, int width, int rn) { HPEN newpen, oldpen; HBRUSH newbrush, oldbrush; newbrush = GetStockObject(color1 & 0xFF000000 ? NULL_BRUSH : DC_BRUSH); oldbrush = (HBRUSH)SelectObject(hdc, newbrush); if (!oldbrush) { log_err("ERROR in drawrect(): failed SelectObject(GetStockObject)\n"); } if (SetDCBrushColor(hdc, color1) == CLR_INVALID) { log_err("ERROR in drawrect(): failed SetDCBrushColor\n"); } newpen = CreatePen(width ? PS_SOLID : PS_NULL, width, color2); if (!newpen) { log_err("ERROR in drawrect(): failed CreatePen\n"); } oldpen = (HPEN)SelectObject(hdc, newpen); if (!oldpen) { log_err("ERROR in drawrect(): failed SelectObject(newpen)\n"); } if (rn) { RoundRect(hdc, x1, y1, x2, y2, rn, rn); } else { Rectangle(hdc, x1, y1, x2, y2); } if (!SelectObject(hdc, oldpen)) log_err("ERROR in drawrect(): failed SelectObject(oldpen)\n"); if (!SelectObject(hdc, oldbrush)) log_err("ERROR in drawrect(): failed SelectObject(oldbrush)\n"); if (!DeleteObject(newpen)) log_err("ERROR in drawrect(): failed SelectObject(newpen)\n"); }