void CMFC_DemoView::OnDraw(CDC* pDC) { CMFC_DemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: 在此处为本机数据添加绘制代码 CClientDC hdc(this); SetMapMode(hdc, MM_ANISOTROPIC); //设置映像模式 HPEN hP = (HPEN)GetStockObject(BLACK_PEN); //黑色画笔 HBRUSH hB = (HBRUSH)GetStockObject(DKGRAY_BRUSH); //画刷 SelectObject(hdc, hB); //选择画刷 SelectObject(hdc, hP); //选择画笔 RoundRect(hdc, 50, 120, 100, 200, 15, 15); //绘制圆角矩形 hB = (HBRUSH)GetStockObject(LTGRAY_BRUSH); //采用亮灰色画刷 SelectObject(hdc, hB); //选择画刷 Ellipse(hdc, 150, 50, 200, 150); //绘制椭圆 hB = (HBRUSH)GetStockObject(HOLLOW_BRUSH); //虚画刷 SelectObject(hdc, hB); //选择画刷 Pie(hdc, 250, 50, 300, 100, 250, 50, 300, 50); //绘制饼形 hP = CreatePen(PS_DASHDOT, 1, RGB(0, 0, 255)); hB = CreateHatchBrush(HS_HORIZONTAL, RGB(0, 255, 0)); SelectObject(hdc, hP); SelectObject(hdc, hB); RoundRect(hdc, 35, 220, 115, 270, 15, 15); Ellipse(hdc, 125, 170, 225, 220); Pie(hdc, 250, 120, 300, 170, 300, 120, 300, 170); }
// This function draws an elliptical pie slice centered at (x,y) with major // and minor radii given by xradius and yradius. It is filled with the // current fill pattern and color and outlined with the current line color. // The pie slice travels from angle stangle to angle endangle. The angles are // given in degrees in standard mathematical notation, with 0 degrees along // the vector (1,0) and travelling counterclockwise. // void sector( int x, int y, int stangle, int endangle, int xradius, int yradius ) { HDC hDC; WindowData* pWndData = BGI__GetWindowDataPtr( ); // Convert coordinates to those expected by GDI Pie int left, top, right, bottom; int xstart, ystart, xend, yend; int color; // Convert center coordinates to box coordinates CenterToBox( x, y, xradius, yradius, &left, &top, &right, &bottom ); // Convert given arc specifications to pixel start and end points. ArcEndPoints( x, y, xradius, yradius, stangle, endangle, &xstart, &ystart, &xend, ¥d ); // Set the text color for the fill pattern // Convert from BGI color to RGB color color = converttorgb( pWndData->fillInfo.color ); hDC = BGI__GetWinbgiDC( ); SetTextColor( hDC, color ); Pie( hDC, left, top, right, bottom, xstart, ystart, xend, yend ); // Reset the text color to the drawing color color = converttorgb( pWndData->drawColor ); SetTextColor( hDC, color ); BGI__ReleaseWinbgiDC( ); // The update rectangle does not contain the right or bottom edge. Thus // add 1 so the entire region is included. RECT rect = { left, top, right+1, bottom+1 }; RefreshWindow( &rect ); }
void iupDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, unsigned char r, unsigned char g, unsigned char b, int style) { int XStartArc = winDrawCalcArc(x1, x2, a1, 1); int XEndArc = winDrawCalcArc(x1, x2, a2, 0); int YStartArc = winDrawCalcArc(y1, y2, a1, 1); int YEndArc = winDrawCalcArc(y1, y2, a2, 0); if (style==IUP_DRAW_FILL) { HBRUSH hBrush = CreateSolidBrush(RGB(r,g,b)); HPEN hBrushOld = SelectObject(dc->hBitmapDC, hBrush); BeginPath(dc->hBitmapDC); Pie(dc->hBitmapDC, x1, y1, x2+1, y2+1, XStartArc, YStartArc, XEndArc, YEndArc); EndPath(dc->hBitmapDC); FillPath(dc->hBitmapDC); SelectObject(dc->hBitmapDC, hBrushOld); DeleteObject(hBrush); } else { HPEN hPen = CreatePen(style==IUP_DRAW_STROKE_DASH? PS_DASH: PS_SOLID, 1, RGB(r, g, b)); HPEN hPenOld = SelectObject(dc->hBitmapDC, hPen); Arc(dc->hBitmapDC, x1, y1, x2+1, y2+1, XStartArc, YStartArc, XEndArc, YEndArc); SelectObject(dc->hBitmapDC, hPenOld); DeleteObject(hPen); } }
void WinInvertWedge (int x, int y, int rx, int ry, float from, float to, BOOL clockwise,OSPictContext context) { int arx, ary; int cx, cy; int ex, ey; StartInverting (context); arx = abs(rx); ary = abs(ry); cx = x - floor(cos(from)* arx); cy = y + floor(sin(from)* ary); ex = cx + floor(cos(to) * arx); ey = cy - floor(sin(to) * ary); if (clockwise) Pie (context->hDC, cx-rx, cy-ry, cx+rx, cy+ry, x, y, ex, ey); else Pie (context->hDC, cx-rx, cy-ry, cx+rx, cy+ry, ex, ey, x, y); } /* WinInvertWedge */
void sector(int x, int y, int start_angle, int end_angle, int rx, int ry) { ac.x = x; ac.y = y; arc_coords(start_angle, rx, ry, ac.xstart, ac.ystart); arc_coords(end_angle, rx, ry, ac.xend, ac.yend); ac.xstart += x; ac.ystart += y; ac.xend += x; ac.yend += y; pcache.select(color+BG); if (bgiemu_handle_redraw || visual_page != active_page) { Pie(hdc[1], x-rx, y-ry, x+rx, y+ry, ac.xstart, ac.ystart, ac.xend, ac.yend); } if (visual_page == active_page) { Pie(hdc[0], x-rx, y-ry, x+rx, y+ry, ac.xstart, ac.ystart, ac.xend, ac.yend); } }
void CCDInfo::DrawCD(HDC hdc, RECT rc) { double dblAngle = m_dblCurrentAngle; double dblRadius = (rc.right - rc.left) / 2; short nTracks, nTrack, nTotalLength; POINT pt1, pt2, ptCenter, ptStart; HBRUSH hBrush, hOldBrush; HPEN hOldPen; LOGBRUSH logbrush; COLORREF col; ptCenter.x = (rc.right + rc.left) / 2; ptCenter.y = (rc.bottom + rc.top) / 2; nTracks = m_cd.GetNumberOfTracks(); nTotalLength = m_cd.GetTotalLength(); hOldPen = (HPEN)SelectObject(hdc, GetStockObject(BLACK_PEN)); logbrush.lbStyle = BS_SOLID; ptStart = pt1 = CalcPoint(ptCenter, dblRadius, dblAngle); for (nTrack=1; nTrack<=nTracks; nTrack++) { col = m_colSegment[nTrack % (sizeof(m_colSegment)/sizeof(COLORREF))]; logbrush.lbColor = col; hBrush = CreateBrushIndirect(&logbrush); hOldBrush = (HBRUSH)SelectObject(hdc, hBrush); if (nTracks==1) { // As we only have 1 track ensure it is painted correctly Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom); MoveToEx(hdc, ptCenter.x, ptCenter.y, NULL); LineTo(hdc, pt1.x, pt1.y); } dblAngle += m_cd.GetTrackLength(nTrack) / (double)nTotalLength * 2 * PI; if (nTrack==nTracks) pt2 = ptStart; // Ensure we finish where we started else pt2 = CalcPoint(ptCenter, dblRadius, dblAngle); // Only draw the wedge if it is big enough to see if (pt1.x != pt2.x || pt1.y != pt2.y) { Pie(hdc, rc.left, rc.top, rc.right, rc.bottom, pt2.x, pt2.y, pt1.x, pt1.y); pt1 = pt2; } SelectObject(hdc, hOldBrush); DeleteObject(hBrush); } SelectObject(hdc, hOldPen); }
void pieslice(int x, int y, int start_angle, int end_angle, int radius) { pcache.select(color+BG); select_fill_color(); ac.x = x; ac.y = y; ac.xstart = x + int(radius*cos(start_angle*pi/180.0)); ac.ystart = y - int(radius*sin(start_angle*pi/180.0)); ac.xend = x + int(radius*cos(end_angle*pi/180.0)); ac.yend = y - int(radius*sin(end_angle*pi/180.0)); if (bgiemu_handle_redraw || visual_page != active_page) { Pie(hdc[1], x-radius, y-radius, x+radius, y+radius, ac.xstart, ac.ystart, ac.xend, ac.yend); } if (visual_page == active_page) { Pie(hdc[0], x-radius, y-radius, x+radius, y+radius, ac.xstart, ac.ystart, ac.xend, ac.yend); } }
/*LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }*/ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT ps; switch (message) { case WM_PAINT: hDC = BeginPaint(hwnd, &ps); x = 800; y = 600; MoveToEx(hDC, x / 2, 0, 0); // Разметка LineTo(hDC, x / 2, y); MoveToEx(hDC, 0, y / 2, 0); LineTo(hDC, x, y / 2); HGDIOBJ hpenOld, hbrushOld; HBRUSH hbrush; hbrush = CreateSolidBrush(RGB(150, 0, 150)); //Эллипс hbrushOld = (HBRUSH)SelectObject(hDC, hbrush); Ellipse(hDC, x/10, y/10, x/10 + 250, y/10 + 200); hbrush = CreateSolidBrush(RGB(150, 150, 150)); //Прямоугольник hbrushOld = (HBRUSH)SelectObject(hDC, hbrush); Rectangle(hDC, x / 10 * 7, y/10, x / 10 * 7 + 100, y/10 + 200); hbrush = CreateSolidBrush(RGB(255, 255, 0)); //Сектор hbrushOld = (HBRUSH)SelectObject(hDC, hbrush); Pie(hDC, x / 2 + 100, y / 8 * 5, x / 2 + 300, y / 8 * 5 + 200, 550, 100, 100, 200); MoveToEx(hDC, x / 4, y / 10 * 5.5, 0); // Ромб LineTo(hDC, x / 4 + 50, y / 10 * 5.5 + 100); LineTo(hDC, x / 4, y / 10 * 5.5 + 200); LineTo(hDC, x / 4 - 50, y / 10 * 5.5 + 100); LineTo(hDC, x / 4, y / 10 * 5.5); DeleteObject(SelectObject(hDC, hbrush)); DeleteObject(SelectObject(hDC, hbrushOld)); EndPaint(hwnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
/* EXPORT-> HFillArc: Draw filled arc from stAngle thru arcAngle degrees */ void HFillArc(int x0,int y0,int x1,int y1,int stAngle,int arcAngle) { int radius; int Center_x = (x0+x1)/2; int Center_y = (y0+y1)/2; int StartArc_x,StartArc_y; int EndArc_x,EndArc_y; HGDIOBJ oldBrush = SelectObject(memDC,theBrush); HGDIOBJ oldPen = SelectObject(memDC,thinPen); HDC dc = GetDC(theWindow); double startAngle, endAngle,convrt = PI/180; /* degrees to radians */ CheckCorners(&x0,&y0,&x1,&y1); /* calculate point locations */ startAngle = stAngle*convrt; endAngle = (stAngle+arcAngle)*convrt; radius = (((x1-x0) > (y1-y0)) ? x1-x0 : y1-y0)/2; StartArc_x = Center_x + (int) (radius * cos((double) startAngle)); StartArc_y = Center_y - (int) (radius * sin((double) startAngle)); EndArc_x = Center_x + (int) (radius * cos((double) endAngle)); EndArc_y = Center_y - (int) (radius * sin((double) endAngle)); Pie(memDC,x0,y0,x1,y1,StartArc_x,StartArc_y,EndArc_x,EndArc_y); SelectObject(memDC,oldBrush); SelectObject(memDC,oldPen); oldBrush = SelectObject(dc,theBrush); oldPen = SelectObject(dc,thinPen); Pie(dc,x0,y0,x1,y1,StartArc_x,StartArc_y,EndArc_x,EndArc_y); SelectObject(dc,oldBrush); SelectObject(dc,oldPen); ReleaseDC(theWindow,dc); }
// scarfed from a M$ KB article. Apparently, Win95 doesn't support AngleArc BOOL AngleArc2(HDC hdc, int X, int Y, DWORD dwRadius, double fStartDegrees, double fSweepDegrees, BOOL bFilled) { int iXStart, iYStart; // End point of starting radial line int iXEnd, iYEnd; // End point of ending radial line double fStartRadians; // Start angle in radians double fEndRadians; // End angle in radians BOOL bResult; // Function result /* Get the starting and ending angle in radians */ if (fSweepDegrees > 0.0) { fStartRadians = ((fStartDegrees / 360.0) * fTwoPi); fEndRadians = (((fStartDegrees + fSweepDegrees) / 360.0) * fTwoPi); } else { fStartRadians = (((fStartDegrees + fSweepDegrees) / 360.0) * fTwoPi); fEndRadians = ((fStartDegrees / 360.0) * fTwoPi); } /* Calculate a point on the starting radial line via */ /* polar -> cartesian conversion */ iXStart = X + (int) ((double) dwRadius * (double) cos(fStartRadians)); iYStart = Y - (int) ((double) dwRadius * (double) sin(fStartRadians)); /* Calculate a point on the ending radial line via */ /* polar -> cartesian conversion */ iXEnd = X + (int) ((double) dwRadius * (double) cos(fEndRadians)); iYEnd = Y - (int) ((double) dwRadius * (double) sin(fEndRadians)); /* Draw a line to the starting point */ LineTo(hdc, iXStart, iYStart); /* Draw the arc */ if (bFilled) bResult = Pie(hdc, X - dwRadius, Y - dwRadius, X + dwRadius, Y + dwRadius, iXStart, iYStart, iXEnd, iYEnd); else bResult = Arc(hdc, X - dwRadius, Y - dwRadius, X + dwRadius, Y + dwRadius, iXStart, iYStart, iXEnd, iYEnd); /* Move to the ending point - Arc() wont do this and ArcTo() */ /* wont work on Win32s or Win16 */ MoveToEx(hdc, iXEnd, iYEnd, NULL); return bResult; }
static void calculate_pie(void) { WINT XStart, YStart, XEnd, YEnd; RECT rect; WINT temp; HPEN hOldPen; HBRUSH hOldBrush; do { rect.left = get_rand(0, xMax); rect.top = get_rand(0, yMax); rect.right = get_rand(0, xMax); rect.bottom = get_rand(0, yMax); if (rect.left > rect.right) { temp = rect.left; rect.left = rect.right; rect.right = temp; } if (rect.top > rect.bottom) { temp = rect.top; rect.top = rect.bottom; rect.bottom = temp; } XStart = get_rand(rect.left, rect.right); YStart = get_rand(rect.top, rect.bottom); XEnd = get_rand(rect.left, rect.right); YEnd = get_rand(rect.top, rect.bottom); hOldPen = SelectObject(hMemDC, create_pen()); hOldBrush = SelectObject(hMemDC, create_brush()); SetBkColor(hMemDC, colors[get_rand(0, num_colors)]); SetBkMode(hMemDC, get_rand(1,3)); SetROP2(hMemDC, get_rand(1,17)); Pie(hMemDC, rect.left, rect.top, rect.right, rect.bottom, XStart, YStart, XEnd, YEnd); DeleteObject(SelectObject(hMemDC, hOldPen)); DeleteObject(SelectObject(hMemDC, hOldBrush)); if (TestSemaphore(&PainterRequired) < 0) { InvalidateRect(hWnd, &rect, FALSE); UpdateWindow(hWnd); } } while ((TestSemaphore(&DemoRun)) && (!TestSemaphore(&SingleRun))); if (!TestSemaphore(&SingleRun)); Signal(&Done); }
PHP_METHOD(WinGdiPath, pie) { wingdi_devicecontext_object *dc_obj; wingdi_path_object *path_obj; int x1, y1, x2, y2, xr1, yr1, xr2, yr2; WINGDI_ERROR_HANDLING(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llllllll", &x1, &y1, &x2, &y2, &xr1, &yr1, &xr2, &yr2) == FAILURE) return; WINGDI_RESTORE_ERRORS(); path_obj = zend_object_store_get_object(getThis() TSRMLS_CC); dc_obj = zend_object_store_get_object(path_obj->device_context TSRMLS_CC); RETURN_BOOL(Pie(dc_obj->hdc, x1, y1, x2, y2, xr1, yr1, xr2, yr2)); }
//Adds lines and figures that are on the gradients void DrawGeometry(const HDC& hdc,const RECT& rect) { HPEN hPen; HBRUSH hBrush; hPen=CreatePen(PS_SOLID,2,RGB(30,30,30)); SelectObject(hdc,hPen); hBrush=CreateSolidBrush(RGB(0,180,180)); SelectObject(hdc,hBrush); RoundRect(hdc,rect.right*15/16-10,rect.bottom*7/8,rect.right*15/16+rect.right*1/16-10,rect.bottom*7/8+rect.right*1/16,15,15); DeleteObject(hPen); DeleteObject(hBrush); hPen=CreatePen(PS_DASH,1,RGB(255,0,0)); SelectObject(hdc,hPen); hBrush=CreateSolidBrush(RGB(130,0,130)); SelectObject(hdc,hBrush); Ellipse(hdc,rect.right*3/4,rect.bottom*7/8,rect.right*3/4+rect.right*1/16,rect.bottom*7/8+rect.right*1/16); DeleteObject(hPen); DeleteObject(hBrush); hPen=(HPEN)GetStockObject(NULL_PEN); SelectObject(hdc,hPen); hBrush=CreateSolidBrush(RGB(80,80,0)); SelectObject(hdc,hBrush); Chord(hdc,rect.right*3/4,rect.bottom*3/4,rect.right*3/4+rect.right*1/16,rect.bottom*3/4+rect.right*1/16,5000,1500,100,155); DeleteObject(hPen); DeleteObject(hBrush); hPen=CreatePen(PS_DOT,1,RGB(255,255,255)); SelectObject(hdc,hPen); hBrush=CreateSolidBrush(RGB(30,30,30)); SelectObject(hdc,hBrush); Pie(hdc,rect.right*15/16-10,rect.bottom*3/4,rect.right*15/16+rect.right*1/16-10,rect.bottom*3/4+rect.right*1/16,10,500,100,15); DeleteObject(hPen); DeleteObject(hBrush); SelectObject(hdc,GetStockObject(BLACK_PEN)); SelectObject(hdc,GetStockObject(NULL_BRUSH)); }
VOID CDrvDefExt::PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT pDrawItem) { HBRUSH hBrush; if (pDrawItem->CtlID == 14013) { hBrush = CreateSolidBrush(RGB(0, 0, 255)); if (hBrush) { FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush); DeleteObject((HGDIOBJ)hBrush); } } else if (pDrawItem->CtlID == 14014) { hBrush = CreateSolidBrush(RGB(255, 0, 255)); if (hBrush) { FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush); DeleteObject((HGDIOBJ)hBrush); } } else if (pDrawItem->CtlID == 14015) { HBRUSH hBlueBrush = CreateSolidBrush(RGB(0, 0, 255)); HBRUSH hMagBrush = CreateSolidBrush(RGB(255, 0, 255)); HPEN hDarkBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 128)); HPEN hDarkMagPen = CreatePen(PS_SOLID, 1, RGB(128, 0, 128)); INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right)/2; INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10)/2; INT cx = pDrawItem->rcItem.right - pDrawItem->rcItem.left; INT cy = pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - 10; TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f, cx); HBRUSH hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush); INT xRadial = xCenter + (INT)(cos(M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f)*cx/2); INT yRadial = yCenter - (INT)(sin(M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f)*cy/2); Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10, pDrawItem->rcItem.left, yCenter, xRadial, yRadial); SelectObject(pDrawItem->hDC, hBlueBrush); Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10, xRadial, yRadial, pDrawItem->rcItem.left, yCenter); SelectObject(pDrawItem->hDC, hbrOld); HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen); for (INT x = pDrawItem->rcItem.left; x < pDrawItem->rcItem.right; ++x) { if (m_FreeSpacePerc < 50 && x == xRadial) SelectObject(pDrawItem->hDC, hDarkBluePen); double cos_val = (x - xCenter)*2.0f/cx; INT y = yCenter+(INT)(sin(acos(cos_val))*cy/2); MoveToEx(pDrawItem->hDC, x, y, NULL); LineTo(pDrawItem->hDC, x, y + 10); } SelectObject(pDrawItem->hDC, hOldPen); DeleteObject(hBlueBrush); DeleteObject(hMagBrush); DeleteObject(hDarkBluePen); DeleteObject(hDarkMagPen); } }
void pie(int left, int top, int right, int bottom, int xr1, int yr1, int xr2, int yr2) { ACL_ASSERT_BEGIN_PAINT; Pie(g_hmemdc,left,top,right,bottom,xr1,yr1,xr2,yr2); }
// ============================================================================ LRESULT AngleControl::Paint() { PAINTSTRUCT ps; HDC hDC = BeginPaint(m_hWnd, &ps); SetBkMode(hDC, TRANSPARENT); float rad = m_diameter * 0.5f; POINT start; start.x= rad + cos(DegToRad(m_startDegrees))*rad + 0.5f; start.y= sin(DegToRad(m_startDegrees))*rad + 0.5f; if (m_dirCCW) start.y = rad - start.y; else start.y += rad; POINT end; end.x = rad + cos(DegToRad(m_degrees+m_startDegrees))*rad + 0.5f; end.y = sin(DegToRad(m_degrees+m_startDegrees))*rad + 0.5f; if (m_dirCCW) end.y = rad - end.y; else end.y += rad; if(IsWindowEnabled(m_hWnd)) { SelectObject(hDC, GetStockObject(BLACK_PEN)); SelectBrush(hDC, m_hBrush); } else { SelectObject(hDC, GetStockObject(WHITE_PEN)); SelectBrush(hDC, GetStockObject(LTGRAY_BRUSH)); } if(m_degrees != 0.f) { BOOL drawCCW = TRUE; if (m_degrees <= 0.f) drawCCW = FALSE; if (!m_dirCCW) drawCCW = !drawCCW; // if(m_degrees > 0.f) if(drawCCW) Pie(hDC, 0, 0, m_diameter, m_diameter, start.x, start.y, end.x, end.y); else Pie(hDC, 0, 0, m_diameter, m_diameter, end.x, end.y, start.x, start.y); } // else { // MoveToEx(hDC, rad, rad, NULL); // LineTo(hDC, start.x, start.y); // } DeleteObject(SelectObject(hDC, GetStockObject(WHITE_PEN))); Arc(hDC, 0, 0, m_diameter, m_diameter, 0, m_diameter, m_diameter, 0); MoveToEx(hDC, rad, rad, NULL); LineTo(hDC, start.x, start.y); MoveToEx(hDC, rad, rad, NULL); LineTo(hDC, end.x, end.y); DeleteObject(SelectObject(hDC, GetStockObject(BLACK_PEN))); Arc(hDC, 0, 0, m_diameter, m_diameter, m_diameter, 0, 0, m_diameter); EndPaint(m_hWnd, &ps); return 0; }
//-------------------------------------------------------------------------- // WindowProc() -> Processa as mensagens enviadas para o programa //-------------------------------------------------------------------------- LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // Variáveis para manipulação da parte gráfica do programa HDC hDC = NULL; PAINTSTRUCT psPaint; // Canetas e pincéis HPEN hPen = NULL; HPEN hPenOld = NULL; HBRUSH hBrush = NULL; HBRUSH hBrushOld = NULL; // Verifica qual foi a mensagem enviada switch(uMsg) { case WM_CREATE: // Janela foi criada { // Retorna 0, significando que a mensagem foi processada corretamente return(0); } break; case WM_PAINT: // Janela (ou parte dela) precisa ser atualizada { // Obtém identificador do DC e preenche PAINTSTRUCT hDC = BeginPaint(hWnd, &psPaint); // Cria e seleciona nova caneta no DC e salva caneta antiga hPen = CreatePen(PS_SOLID, 1, RGB(0, 128, 0)); hPenOld = (HPEN)SelectObject(hDC, hPen); // Cria e seleciona novo pincel no DC e salva pincel antigo hBrush = CreateSolidBrush(RGB(255, 255, 0)); hBrushOld = (HBRUSH)SelectObject(hDC, hBrush); // Desenha elipse Ellipse(hDC, 80, 100, 180, 200); // Desenha combinação de arco e corda Chord(hDC, 10, 10, 100, 100, 80, 80, 50, 25); // Desenha "pizza" Pie(hDC, 110, 10, 200, 100, 180, 80, 150, 25); // Desenha "pizza" no formato Pac-Man Pie(hDC, 210, 10, 400, 200, 380, 50, 380, 130); // Restaura pincel antigo e deleta novo pincel SelectObject(hDC, hBrushOld); DeleteObject(hBrush); // Restaura caneta antiga e deleta nova caneta SelectObject(hDC, hPenOld); DeleteObject(hPen); // Libera DC e valida área EndPaint(hWnd, &psPaint); return(0); } break; case WM_CLOSE: // Janela foi fechada { // Destrói a janela DestroyWindow(hWnd); return(0); } break; case WM_DESTROY: // Janela foi destruída { // Envia mensagem WM_QUIT para o loop de mensagens PostQuitMessage(0); return(0); } break; default: // Outra mensagem { /* Deixa o Windows processar as mensagens que não foram verificadas na função */ return(DefWindowProc(hWnd, uMsg, wParam, lParam)); } } }
static void gwdraw(GUIWIN *gw, long fg, long bg, int bits, Char *text, int len) { register int i; GUI_WINDOW *gwp = (GUI_WINDOW *)gw; COLORREF fgc, bgc; HBRUSH hBrush, hPrevBrush; HPEN hPen, hPrevPen; HDC hDC; HFONT hFont; RECT rect; int ileft; int xleft, xcenter, xright, ytop, ycenter, ybottom, radius; UINT options; /* Italics are slanted rightward from the bottom of the character cell. * We'd like for them to look slanted from the center of the characters, * and we can achieve that effect by shifting italic text slightly leftward. */ ileft = 0; if ((bits & COLOR_GRAPHIC) != COLOR_GRAPHIC && (bits & COLOR_ITALIC)) ileft = (gwp->ycsize - 3) / 6; /* just a guess */ /* Convert fg and bg args into COLORREF values */ fgc = (COLORREF)fg; bgc = (COLORREF)bg; /* compute the update RECT */ rect.top = gwp->currow * gwp->ycsize; rect.left = gwp->curcol * gwp->xcsize + gwp->xcsize / 2; rect.bottom = rect.top + gwp->ycsize; rect.right = rect.left + gwp->xcsize * len; /* Get the window's DC */ hDC = GetDC (gwp->clientHWnd); SetMapMode (hDC, MM_TEXT); /* hide caret */ if (gwp->cursor_type != CURSOR_NONE && gwp->clientHWnd == GetFocus ()) { HideCaret (gwp->clientHWnd); gwp->cursor_type = CURSOR_NONE; } /* graphic chars are a special case */ if ((bits & COLOR_GRAPHIC) == COLOR_GRAPHIC) { /* Strip out the COLOR_GRAPHIC bits */ bits &= ~COLOR_GRAPHIC; /* Erase the area */ #ifdef FEATURE_IMAGE if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg) { gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled); } else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg) { gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled); } else #endif { hBrush = CreateSolidBrush (bgc); FillRect (hDC, &rect, hBrush); DeleteObject(hBrush); } /* Select the foreground color */ hPen = CreatePen(PS_SOLID, 0, fgc); hPrevPen = SelectObject(hDC, hPen); /* Find special points in the first character cell */ radius = gwp->xcsize / 3; xleft = rect.left; xright = xleft + gwp->xcsize; xcenter = (xleft + xright) / 2; ytop = rect.top; ybottom = rect.bottom; ycenter = (ytop + ybottom) / 2; /* For each graphic character... */ for (i = 0; i < len; text++, i++) { /* Draw line segments, as appropriate for this character */ if (strchr("123456|", *text)) { MoveToEx(hDC, xcenter, ytop, NULL); LineTo(hDC, xcenter, ycenter); } if (strchr("456789|", *text)) { MoveToEx(hDC, xcenter, ycenter, NULL); LineTo(hDC, xcenter, ybottom); } if (strchr("235689-", *text)) { MoveToEx(hDC, xleft, ycenter, NULL); LineTo(hDC, xcenter, ycenter); } if (strchr("124578-", *text)) { MoveToEx(hDC, xcenter, ycenter, NULL); LineTo(hDC, xright, ycenter); } if (*text == 'o') { Arc(hDC, xcenter - radius, ycenter - radius, xcenter + radius, ycenter + radius, xcenter - radius, ycenter, xcenter - radius, ycenter); } if (*text == '*') { HBRUSH oldbrush, newbrush; newbrush = CreateSolidBrush(fgc); oldbrush = SelectObject(hDC, newbrush); Pie(hDC, xcenter - radius, ycenter - radius, xcenter + radius, ycenter + radius, xcenter - radius, ycenter, xcenter - radius, ycenter); SelectObject(hDC, oldbrush); DeleteObject(newbrush); } /* Advance the points to the next cell */ xleft = xright; xcenter += gwp->xcsize; xright += gwp->xcsize; } /* Restore foreground color to its previous value, so we can delete * the local hPen object. */ SelectObject(hDC, hPrevPen); DeleteObject(hPen); } else { /* Find a font with the right bold/italic/underlined attributes */ i = 0; if (bits & COLOR_BOLD) i += 1; if (bits & COLOR_ITALIC) i += 2; if (bits & COLOR_UNDERLINED) i += 4; hFont = gwp->fonts[i]; /* prepare DC & output text */ SetTextColor(hDC, fgc); SetBkColor(hDC, bgc); SetBkMode(hDC, OPAQUE); SelectObject(hDC, hFont); options = ETO_OPAQUE | ETO_CLIPPED; #ifdef FEATURE_IMAGE if (normalimage && (long)bgc == colorinfo[COLOR_FONT_NORMAL].bg) { gw_erase_rect(hDC, &rect, normalimage, gwp->scrolled); options = ETO_CLIPPED; SetBkMode(hDC, TRANSPARENT); } else if (idleimage && (long)bgc == colorinfo[COLOR_FONT_IDLE].bg) { gw_erase_rect(hDC, &rect, idleimage, gwp->scrolled); options = ETO_CLIPPED; SetBkMode(hDC, TRANSPARENT); } #endif ExtTextOut(hDC, rect.left - ileft, rect.top, options, &rect, (char *)text, len, gwp->font_size_array); #ifdef FEATURE_IMAGE SetBkColor(hDC, bgc); SetBkMode(hDC, OPAQUE); #endif } /* If COLOR_BOXED then draw a rectangle around the text */ if (bits & (COLOR_BOXED | COLOR_LEFTBOX | COLOR_RIGHTBOX)) { /* Select the foreground color */ hPen = CreatePen(PS_SOLID, 0, fgc); hPrevPen = SelectObject(hDC, hPen); /* Draw the rectangle */ if (bits & COLOR_BOXED) { MoveToEx(hDC, rect.left, rect.top, NULL); LineTo(hDC, rect.right, rect.top); MoveToEx(hDC, rect.left, rect.bottom - 1, NULL); LineTo(hDC, rect.right, rect.bottom - 1); } if (bits & COLOR_RIGHTBOX) { MoveToEx(hDC, rect.right - 1, rect.top, NULL); LineTo(hDC, rect.right - 1, rect.bottom); } if (bits & COLOR_LEFTBOX) { MoveToEx(hDC, rect.left, rect.top, NULL); LineTo(hDC, rect.left, rect.bottom); } /* Restore foreground color to its previous value, so we can delete * the local hPen object. */ SelectObject(hDC, hPrevPen); DeleteObject(hPen); } /* release the window's device context */ ReleaseDC(gwp->clientHWnd, hDC); /* update cursor position */ gwp->curcol += len; }
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_CREATE: { HWND radioButton_1 = CreateWindowEx(0, "Button", "Rectangle", WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, 4, 10, 100, 20, hwnd, (HMENU)1, NULL, NULL); HWND radioButton_2 = CreateWindowEx(0, "Button", "Ellipse", WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, 4, 30, 100, 20, hwnd, (HMENU)2, NULL, NULL); HWND radioButton_3 = CreateWindowEx(0, "Button", "Pie", WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON, 4, 50, 100, 20, hwnd, (HMENU)3, NULL, NULL); HWND checkBox_1 = CreateWindowEx(0,"Button","Red",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,4,70,100,20,hwnd,(HMENU)4,NULL,NULL); HWND checkBox_2 = CreateWindowEx(0,"Button","Green",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,4,90,100,20,hwnd,(HMENU)5,NULL,NULL); HWND checkBox_3 = CreateWindowEx(0,"Button","Blue",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,4,110,100,20,hwnd,(HMENU)6,NULL,NULL); HWND pushButton_1 = CreateWindow( "Button", "Play", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,4,130,50,20,hwnd,(HMENU)7,NULL,NULL); HWND pushButton_2 = CreateWindow( "Button", "Pause", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,54,130,50,20,hwnd,(HMENU)8,NULL,NULL); checks[0] = checkBox_1; checks[1] = checkBox_2; checks[2] = checkBox_3; break; } case WM_COMMAND: { switch (wParam) { case 1: figure = 0; break; case 2: figure = 1; break; case 3: figure = 2; break; case 4: color = 0; if (SendMessage(checks[0], BM_GETCHECK,0,0 ) == BST_CHECKED) { EnableWindow(checks[1], false); EnableWindow(checks[2], false); } else { EnableWindow(checks[1], true); EnableWindow(checks[2], true); } break; case 5: if (SendMessage(checks[1], BM_GETCHECK,0,0 ) == BST_CHECKED) { EnableWindow(checks[0], false); EnableWindow(checks[2], false); } else { EnableWindow(checks[0], true); EnableWindow(checks[2], true); } color = 1; break; case 6: if (SendMessage(checks[2], BM_GETCHECK,0,0 ) == BST_CHECKED) { EnableWindow(checks[0], false); EnableWindow(checks[1], false); } else { EnableWindow(checks[0], true); EnableWindow(checks[1], true); } color = 2; break; case 7: SetTimer(hwnd, 7, 100, NULL); break; case 8: KillTimer(hwnd, 7); break; default: break; } InvalidateRect(hwnd, NULL, FALSE); break; } case WM_PAINT: { PAINTSTRUCT ps; RECT rc; GetClientRect(hwnd, &rc); HDC hdc = BeginPaint (hwnd, &ps) ; FillRect(hdc, &rc, CreateSolidBrush(RGB(255,255,255))); switch (color) { case 0: SelectObject(hdc, CreateSolidBrush(RGB(255,0,0))); break; case 1: SelectObject(hdc, CreateSolidBrush(RGB(0,255,0))); break; case 2: SelectObject(hdc, CreateSolidBrush(RGB(0,0,255))); break; } int x= 300 + cos(angle)*100; int y= 150 + sin(angle)*100; switch (figure) { case 0: Rectangle(hdc, x-10, y-10, x+10, y+10); break; case 1: Ellipse(hdc, x-15, y-10, x+15, y+10); break; case 2: Pie(hdc, x-10, y-10, x+10, y+10, x-5,y-10,x+10,y+5); break; } EndPaint (hwnd, &ps) ; break; } case WM_TIMER: { angle+=3.14*5/180; InvalidateRect(hwnd, NULL, FALSE); break; } case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
static void DrawOrFillArc( Display *display, Drawable d, GC gc, int x, int y, /* left top */ unsigned int width, unsigned int height, int start, /* start: three-o'clock (deg*64) */ int extent, /* extent: relative (deg*64) */ int fill) /* ==0 draw, !=0 fill */ { HDC dc; HBRUSH brush, oldBrush; HPEN pen, oldPen; TkWinDCState state; int clockwise = (extent < 0); /* non-zero if clockwise */ int xstart, ystart, xend, yend; double radian_start, radian_end, xr, yr; if (d == None) { return; } dc = TkWinGetDrawableDC(display, d, &state); SetROP2(dc, tkpWinRopModes[gc->function]); /* * Compute the absolute starting and ending angles in normalized radians. * Swap the start and end if drawing clockwise. */ start = start % (64*360); if (start < 0) { start += (64*360); } extent = (start+extent) % (64*360); if (extent < 0) { extent += (64*360); } if (clockwise) { int tmp = start; start = extent; extent = tmp; } radian_start = XAngleToRadians(start); radian_end = XAngleToRadians(extent); /* * Now compute points on the radial lines that define the starting and * ending angles. Be sure to take into account that the y-coordinate * system is inverted. */ xr = x + width / 2.0; yr = y + height / 2.0; xstart = (int)((xr + cos(radian_start)*width/2.0) + 0.5); ystart = (int)((yr + sin(-radian_start)*height/2.0) + 0.5); xend = (int)((xr + cos(radian_end)*width/2.0) + 0.5); yend = (int)((yr + sin(-radian_end)*height/2.0) + 0.5); /* * Now draw a filled or open figure. Note that we have to increase the * size of the bounding box by one to account for the difference in pixel * definitions between X and Windows. */ pen = SetUpGraphicsPort(gc); oldPen = SelectObject(dc, pen); if (!fill) { /* * Note that this call will leave a gap of one pixel at the end of the * arc for thin arcs. We can't use ArcTo because it's only supported * under Windows NT. */ SetBkMode(dc, TRANSPARENT); Arc(dc, x, y, (int) (x+width+1), (int) (y+height+1), xstart, ystart, xend, yend); } else { brush = CreateSolidBrush(gc->foreground); oldBrush = SelectObject(dc, brush); if (gc->arc_mode == ArcChord) { Chord(dc, x, y, (int) (x+width+1), (int) (y+height+1), xstart, ystart, xend, yend); } else if (gc->arc_mode == ArcPieSlice) { Pie(dc, x, y, (int) (x+width+1), (int) (y+height+1), xstart, ystart, xend, yend); } DeleteObject(SelectObject(dc, oldBrush)); } DeleteObject(SelectObject(dc, oldPen)); TkWinReleaseDrawableDC(d, dc, &state); }
/*************************************************************************** * bConicCommon - The mother of all conic translations. * They are Arc, Chord, Pie, Ellipse, Rectangle and RoundRect. **************************************************************************/ BOOL bConicCommon (PLOCALDC pLocalDC, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4, DWORD mrType) { SHORT sx1, sx2, sx3, sx4, sy1, sy2, sy3, sy4 ; LONG nPointls ; POINTL aptl[4] ; BOOL b ; // If we're recording the drawing orders for a path // then just pass the drawing order to the helper DC. // Do not emit any Win16 drawing orders. if (pLocalDC->flags & RECORDING_PATH) { switch(mrType) { case EMR_ARC: b = Arc(pLocalDC->hdcHelper, x1, y1, x2, y2, x3, y3, x4, y4) ; break ; case EMR_CHORD: b = Chord(pLocalDC->hdcHelper, x1, y1, x2, y2, x3, y3, x4, y4) ; break ; case EMR_ELLIPSE: b = Ellipse(pLocalDC->hdcHelper, x1, y1, x2, y2) ; break ; case EMR_PIE: b = Pie(pLocalDC->hdcHelper, x1, y1, x2, y2, x3, y3, x4, y4) ; break ; case EMR_RECTANGLE: b = Rectangle(pLocalDC->hdcHelper, x1, y1, x2, y2) ; break ; case EMR_ROUNDRECT: b = RoundRect(pLocalDC->hdcHelper, x1, y1, x2, y2, x3, y3) ; break ; default: RIP("MF3216: bConicCommon, bad mrType"); break ; } ASSERTGDI(b, "MF3216: bConicCommon, in path render failed\n") ; return(b) ; } // Do the transformations. // And emit the Win16 drawing orders. if (pLocalDC->flags & STRANGE_XFORM) { b = bRenderCurveWithPath(pLocalDC, (LPPOINT) NULL, (PBYTE) NULL, 0, x1, y1, x2, y2, x3, y3, x4, y4, 0, 0.0f, 0.0f, mrType); return(b); } // Do the simple transform case. // Compute the number of points nPointls = (LONG) (sizeof(aptl) / sizeof(POINTL)) ; // Assign all the coordinates into an array for conversion. aptl[0].x = x1 ; aptl[0].y = y1 ; aptl[1].x = x2 ; aptl[1].y = y2 ; aptl[2].x = x3 ; aptl[2].y = y3 ; aptl[3].x = x4 ; aptl[3].y = y4 ; // Take care of the arc direction. switch (mrType) { case EMR_ARC: case EMR_CHORD: case EMR_PIE: vDoArcReflection(pLocalDC, &aptl[2]) ; break ; default: break ; } // Do the Record-time World to Play-time Page transformations. // The radial definitions need only a world to page xform, // and the ellipse definitions for roundrects only require // a magnitude transformation. if (mrType != EMR_ROUNDRECT) { b = bXformRWorldToPPage(pLocalDC, (PPOINTL) aptl, nPointls) ; if (!b) goto exit1 ; } else { /* For roundrects do a Record-time-World to Play-time-Page transform of the bounding box only. Then a magnatude only transform of the corner ellipse definitions. */ b = bXformRWorldToPPage(pLocalDC, (PPOINTL) aptl, 2) ; if (!b) goto exit1 ; aptl[2].x = iMagnitudeXform(pLocalDC, aptl[2].x, CX_MAG) ; aptl[2].y = iMagnitudeXform(pLocalDC, aptl[2].y, CY_MAG) ; aptl[3].x = iMagnitudeXform(pLocalDC, aptl[3].x, CX_MAG) ; aptl[3].y = iMagnitudeXform(pLocalDC, aptl[3].y, CY_MAG) ; } // The bounding boxes for // all the conics and rectangles that are handled by this // common routine are inclusive-inclusive, and they must // be transformed to the inclusive-exclusive Win16 form. b = bIncIncToIncExcXform(pLocalDC, (PRECTL) &aptl[0]) ; if (!b) goto exit1 ; // Assign the converted coordinates variables suited to // the Win16 metafile. sx1 = LOWORD(aptl[0].x) ; sy1 = LOWORD(aptl[0].y) ; sx2 = LOWORD(aptl[1].x) ; sy2 = LOWORD(aptl[1].y) ; sx3 = LOWORD(aptl[2].x) ; sy3 = LOWORD(aptl[2].y) ; sx4 = LOWORD(aptl[3].x) ; sy4 = LOWORD(aptl[3].y) ; // Emit the Win16 drawing orders to the Win16 metafile. switch(mrType) { case EMR_ARC: b = bEmitWin16Arc(pLocalDC, sx1, sy1, sx2, sy2, sx3, sy3, sx4, sy4) ; break ; case EMR_CHORD: b = bEmitWin16Chord(pLocalDC, sx1, sy1, sx2, sy2, sx3, sy3, sx4, sy4) ; break ; case EMR_ELLIPSE: b = bEmitWin16Ellipse(pLocalDC, sx1, sy1, sx2, sy2) ; break ; case EMR_PIE: b = bEmitWin16Pie(pLocalDC, sx1, sy1, sx2, sy2, sx3, sy3, sx4, sy4) ; break ; case EMR_RECTANGLE: b = bEmitWin16Rectangle(pLocalDC, sx1, sy1, sx2, sy2) ; break ; case EMR_ROUNDRECT: b = bEmitWin16RoundRect(pLocalDC, sx1, sy1, sx2, sy2, sx3, sy3) ; break ; default: RIP("MF3216: bConicCommon, bad mrType"); break ; } exit1: return (b) ; }
VOID CMimicsArcCtrl::DrawCtrl(HDC hDC, CONST RECT *pRect, BOOL bShape) { INT nPt; INT nPts; INT nMode; HPEN hOldPen; HPEN hBorderPen; POINT ptRadial[2]; double fxRadial; double fyRadial; HBRUSH hOldBrush; HBRUSH hInteriorBrush; HBITMAP hInteriorBitmap; LOGBRUSH sInteriorBrush; COLORREF nOldColor[2]; if ((hBorderPen = CreatePen(PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | m_nBorderStyle, m_nBorderSize, GetNearestColor(hDC, (!bShape) ? m_nBorderColor : VGA_COLOR_WHITE)))) { if ((hInteriorBitmap = LoadBitmap(GetModuleInstance(), (m_nInteriorHatch == HT_SOLID || m_nInteriorHatch < 0) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHSOLID) : ((m_nInteriorHatch == HT_HORIZONTAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHHORIZONTAL) : ((m_nInteriorHatch == HT_VERTICAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHVERTICAL) : ((m_nInteriorHatch == HT_BDIAGONAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHDIAGONALDOWN) : ((m_nInteriorHatch == HT_FDIAGONAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHDIAGONALUP) : ((m_nInteriorHatch == HT_CROSS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHCROSS) : ((m_nInteriorHatch == HT_DIAGCROSS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHCROSSDIAGONAL) : ((m_nInteriorHatch == HT_LPOINTS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSLOW) : ((m_nInteriorHatch == HT_MPOINTS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSMEDIUM) : MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSHIGH)))))))))))) { sInteriorBrush.lbStyle = (m_nInteriorColor != (COLORREF)-1) ? ((m_nInteriorHatch > 0) ? BS_PATTERN : BS_SOLID) : BS_HOLLOW; sInteriorBrush.lbColor = (sInteriorBrush.lbStyle == BS_SOLID) ? GetNearestColor(hDC, (!bShape) ? m_nInteriorColor : VGA_COLOR_WHITE) : 0; sInteriorBrush.lbHatch = (sInteriorBrush.lbStyle == BS_PATTERN) ? (ULONG_PTR)hInteriorBitmap : (ULONG_PTR)NULL; if ((hInteriorBrush = CreateBrushIndirect(&sInteriorBrush)) != (HBRUSH)NULL) { if ((hOldPen = (HPEN)SelectObject(hDC, hBorderPen)) != (HPEN)NULL) { if ((hOldBrush = (HBRUSH)SelectObject(hDC, hInteriorBrush))) { for (nPt = 0, nPts = sizeof(ptRadial) / sizeof(POINT); nPt < nPts; nPt++) { fxRadial = (INT)((double)(pRect->left + pRect->right) / 2.0 + ((double)(pRect->right - pRect->left + pRect->bottom - pRect->top) / 2.0)*cos(2.0*M_PI - m_ptRadial[nPt])); fyRadial = (INT)((double)(pRect->top + pRect->bottom) / 2.0 + ((double)(pRect->right - pRect->left + pRect->bottom - pRect->top) / 2.0)*sin(2.0*M_PI - m_ptRadial[nPt])); ptRadial[nPt].x = (fxRadial >= 0.0) ? (INT)(fxRadial + 0.5) : (INT)(fxRadial - 0.5); ptRadial[nPt].y = (fyRadial >= 0.0) ? (INT)(fyRadial + 0.5) : (INT)(fyRadial - 0.5); } for (nMode = SetBkMode(hDC, OPAQUE), nOldColor[0] = SetBkColor(hDC, GetNearestColor(hDC, (!bShape) ? m_nInteriorColor : VGA_COLOR_WHITE)), nOldColor[1] = SetTextColor(hDC, GetNearestColor(hDC, (!bShape) ? m_nHatchColor : VGA_COLOR_WHITE)); m_nStyle & MIMICSARCCTRL_TYPE_ARC; ) { Arc(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } for (; m_nStyle & MIMICSARCCTRL_TYPE_PIE; ) { Pie(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } for (; m_nStyle & MIMICSARCCTRL_TYPE_CHORD; ) { Chord(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } SetBkMode(hDC, nMode); SetBkColor(hDC, nOldColor[0]); SetTextColor(hDC, nOldColor[1]); SelectObject(hDC, hOldBrush); } SelectObject(hDC, hOldPen); } DeleteObject(hInteriorBrush); } DeleteObject(hInteriorBitmap); } DeletePen(hBorderPen); } }