MFC tab 绘制效果

1CDC *pDC =&MemDC; 2 CRect rectTab=rcWindow; 3 rectTab.left+=100; 4 rectTab.right=rectTab.left+100; 5 rectTab.top+=5; 6 rectTab.bottom=rectTab.top+25; 7 CList<POINT, POINT> pts; 8 9 POSITION posLeft = pts.AddHead (CPoint (rectTab.left, rectTab.top)); 10 posLeft = pts.InsertAfter (posLeft, CPoint (rectTab.left, rectTab.top + 2)); 11 12 POSITION posRight = pts.AddTail (CPoint (rectTab.right, rectTab.top)); 13 posRight = pts.InsertBefore (posRight, CPoint (rectTab.right, rectTab.top + 2)); 14 15 int xLeft = rectTab.left + 1; 16 int xRight = rectTab.right - 1; 17 18 int y = 0; 19 for (= rectTab.top + 2; y < rectTab.bottom-4;+= 2) 20 { 21 22 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y)); 23 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y+2)); 24 25 posRight = pts.InsertBefore (posRight, CPoint (xRight, y)); 26 posRight = pts.InsertBefore (posRight, CPoint (xRight, y+2)); 27 xLeft++; 28 xRight--; 29 30 } 31 32 xLeft--; 33 xRight++; 34 /**/ 35 36 const int nTabLeft = xLeft - 1; 37 const int nTabRight = xRight + 1; 38 39 for (;< rectTab.bottom - 1; y++) 40 { 41 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft-1, y-1)); 42 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft, y)); 43 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y+1)); 44 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 2, y+2)); 45 46 posRight = pts.InsertBefore (posRight, CPoint (xRight, y)); 47 posRight = pts.InsertBefore (posRight, CPoint (xRight - 1, y + 1)); 48 49 if (== rectTab.bottom - 2) 50 { 51 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 1, y + 1)); 52 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 3, y + 1)); 53 54 posRight = pts.InsertBefore (posRight, CPoint (xRight, y + 1)); 55 posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, y + 1)); 56 } 57 58 xLeft++; 59 xRight--; 60 }/**/ 61 62 posLeft = pts.InsertAfter (posLeft, CPoint (xLeft + 2, rectTab.bottom)); 63 posRight = pts.InsertBefore (posRight, CPoint (xRight - 2, rectTab.bottom)); 64 LPPOINT points = new POINT [pts.GetCount ()]; 65 int i = 0; 66 67 for (POSITION pos = pts.GetHeadPosition (); pos != NULL; i++) 68 { 69 points [i] = pts.GetNext (pos); 70 points [i].y = rectTab.bottom - (points [i].y - rectTab.top); 71 } 72 73 CRgn rgnClip; 74 rgnClip.CreatePolygonRgn (points, (int) pts.GetCount (), WINDING); 75 pDC->SelectClipRgn (&rgnClip); 76 77 //Region rg((HRGN)rgnClip.GetSafeHandle());    78 //CBrush br (RGB(255,255,255)); 79 //pDC->FillRect ( rectTab,&br); 80 //br.DeleteObject(); 81 /***绘制渐变色**/ 82 int R=255; 83 int G=255; 84 int B=255; 85 CPen Bpen (PS_SOLID, 1, RGB(R,G,B)); 86 CPen* pOLdBPen = pDC->SelectObject (&Bpen); 87 for(int i=rectTab.top;i<rectTab.bottom;i++) 88 { 89  CPen pen (PS_SOLID, 1, RGB(R--,G--,B--)); 90      pDC->SelectObject (&pen); 91  pDC->MoveTo (rectTab.left,); 92  pDC->LineTo (rectTab.right,i); 93  pen.DeleteObject(); 94 } 95 Bpen.DeleteObject(); 96 pDC->SelectObject (&pOLdBPen); 97 98 /*graphics.SetSmoothingMode(SmoothingModeHighSpeed); 99 SolidBrush brush22(Color(255,255, 255, 255)); 100 graphics.FillRegion(&brush22,&rg);*/ 101 102 pDC->SelectClipRgn (NULL); 103 CPen pen (PS_SOLID, 1, globalData.clrBarShadow); 104 CPen* pOLdPen = pDC->SelectObject (&pen); 105 106 for (= 0; i < pts.GetCount (); i++) 107 { 108 if ((% 2) != 0) 109 { 110 int x1 = points [- 1].x; 111 int y1 = points [- 1].y; 112 113 int x2 = points [i].x; 114 int y2 = points [i].y; 115 116 if (x1 > rectTab.CenterPoint ().x && x2 > rectTab.CenterPoint ().x) 117 { 118 x1--; 119 x2--; 120 } 121 122 if (y2 >= y1) 123 { 124 pDC->MoveTo (x1, y1); 125 pDC->LineTo (x2, y2); 126 } 127 else 128 { 129 pDC->MoveTo (x2, y2); 130 pDC->LineTo (x1, y1); 131 } 132 } 133 } 134 135 delete [] points; 136 pDC->SelectObject (pOLdPen); 137 rectTab.left = nTabLeft; 138 rectTab.right = nTabRight;

   效果图:

   

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang

Android So动态加载 优雅实现与原理分析

背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我