#pragma once int DivRectX(const CRect rect0, CRect & rect1, CRect & rect2, float w1=0, float w2=0) { int x0, y0, x1, y1, x2;// , y2; int w, h; x0 = rect0.left; y0 = rect0.top; x1 = rect0.right; y1 = rect0.bottom; w = rect0.Width(); h = rect0.Height(); if (w1 > 1&&w2<1) { x2 = int(x0 + w1); } else if (w2 > 1) { x2 = int(x1 - w2); } else{ x2 = int((x0*w2 + x1*w1) / (w1 + w2)); } rect1.SetRect(x0, y0, x2, y1); rect2.SetRect(x2, y0, x1, y1); return 0; }; int DivRectY(const CRect rect0, CRect & rect1, CRect & rect2, float h1=0, float h2=0) { int x0, y0, x1, y1, y2; x0 = rect0.left; y0 = rect0.top; x1 = rect0.right; y1 = rect0.bottom; if (h1 > 1 && h2 < 1) { y2 = int(y0 + h1); } else if (h2 > 1) { y2 = int(y1 - h2); } else { y2 = int((y0*h2 + y1*h1) / (h1 + h2)); } rect1.SetRect(x0, y0, x1, y2); rect2.SetRect(x0, y2, x1, y1); return 0; } int DivRectX3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float w1=0, float w2=0, float w3=0) { int x0, y0, x1, y1, x2, x3;// , y2; x0 = rect0.left; y0 = rect0.top; x1 = rect0.right; y1 = rect0.bottom; x2 = int((x0*(w2+w3) + x1*w1) / (w1 + w2 + w3)); x3 = int((x0*(w3) + x1*(w1+w2)) / (w1 + w2 + w3)); rect1.SetRect(x0, y0, x2, y1); rect2.SetRect(x2, y0, x3, y1); rect3.SetRect(x3, y0, x1, y1); return 0; }; int DivRectY3(const CRect rect0, CRect & rect1, CRect & rect2, CRect & rect3, float h1=0, float h2=0, float h3=0) { int x0, y0, x1, y1, y2, y3; x0 = rect0.left; y0 = rect0.top; x1 = rect0.right; y1 = rect0.bottom; y2 = int((y0*(h2 + h3) + y1*h1) / (h1 + h2 + h3)); y3 = int((y0*h2 + y1*(h1 + h2)) / (h1 + h2 + h3)); rect1.SetRect(x0, y0, x1, y2); rect2.SetRect(x0, y2, x1, y3); rect3.SetRect(x0, y3, x1, y1); return 0; }