<menu id="w8yyk"><menu id="w8yyk"></menu></menu>
  • <dd id="w8yyk"><nav id="w8yyk"></nav></dd>
    <menu id="w8yyk"></menu>
    <menu id="w8yyk"><code id="w8yyk"></code></menu>
    <menu id="w8yyk"></menu>
    <xmp id="w8yyk">
    <xmp id="w8yyk"><nav id="w8yyk"></nav>
  • 網站首頁 > 物聯資訊 > 技術分享

    矩形和區域

    2016-09-28 00:00:00 廣州睿豐德信息科技有限公司 閱讀
    睿豐德科技 專注RFID識別技術和條碼識別技術與管理軟件的集成項目。質量追溯系統、MES系統、金蝶與條碼系統對接、用友與條碼系統對接

    下面有三個繪圖函數需要一個指向矩形結構的指針:

    FillRect(hdc,&rect,hbursh);//填充

    FrameRect(hdc,&rect,hbrush);//掏空

    InvertRect(hdc,&rect);//內部取反

    [cpp] view plaincopy
    1. case WM_PAINT:  
    2.             hdc=BeginPaint(hwnd,&ps);  
    3.             //GetClientRect(hwnd,&rect);  
    4.               
    5.             //hrgn=CreateRectRgn(100,100,300,300);  
    6.             //hbrush=CreateSolidBrush(RGB(255,0,0));  
    7.             //FillRgn(hdc,hrgn,hbrush);  
    8.             //InvertRgn(hdc,hrgn);//取反  
    9.             //FrameRgn(hdc,hrgn,hbrush,0,0);  
    10.   
    11.               
    12.             r1.left=100;  
    13.             r1.top=100;  
    14.             r1.right=200;  
    15.             r1.bottom=200;  
    16.             hbrush=CreateSolidBrush(RGB(255,0,0));//創建畫刷  
    17.             FillRect(hdc,&r1,hbrush);  
    18.   
    19.             r2.left=200;  
    20.             r2.top=100;  
    21.             r2.right=300;  
    22.             r2.bottom=200;  
    23.             FrameRect(hdc,&r2,hbrush);  
    24.   
    25.             r3.left=300;  
    26.             r3.top=100;  
    27.             r3.right=400;  
    28.             r3.bottom=200;  
    29.             InvertRect(hdc,&r3);  
    30.   
    31.             EndPaint(hwnd,&ps);  
    32.             return 0;  

    RFID設備管理軟件

    下面還有八個關于矩形的操作:

    OffsetRect(&rect,x,y) 將矩形移動 InflateRect(&rect,x,y) 增大縮小矩形的尺寸 SetRectEmpty(&rect) 把矩形結構各字段設置為0 CopyRect(&DestRect,&ScrRect) 將一個矩形結構復制到另一個矩形結構 IntersectRect(&destRect,&SrcRect1,&SrcRect2) 獲取兩個矩形的交集 UnionRect(&DestRect,&SrcRect1,&SrcRect2) 獲取兩個矩形的并集 bEmpty=IsRectEmpty(&Rect) 判斷矩形是否為空 bInRect=PtInRect(&rect,point) 判斷點是否在矩形內部

     

    區域跟矩形一樣,有以下四個繪圖函數

    [cpp] view plaincopy
    1. FillRgn(hdc,hrgn,hbrush);  
    2. FrameRgn(hdc,hbrush,xFrame,yFrame);  
    3. InvertRgn(hdc,hrgn);  
    4. PaintRgn(hdc,hrgn);  
    [cpp] view plaincopy
    1. DeleteObject(hrgn);  
    [cpp] view plaincopy
    1. SelectObject(hdc,hrgn)=SelectClipRgn(hdc,hrgn);  

    使得矩形,區域有效和無效的函數

    [cpp] view plaincopy
    1. InvalidateRect       ValidateRect  
    2. InvalidateRgn        ValidateRgn  

    下面是簡單的例子:

    [cpp] view plaincopy
    1. case WM_PAINT:  
    2.             hdc=BeginPaint(hwnd,&ps);  
    3.             //GetClientRect(hwnd,&rect);  
    4.               
    5.             //hrgn=CreateRectRgn(100,100,300,300);  
    6.             //hbrush=CreateSolidBrush(RGB(255,0,0));  
    7.             //FillRgn(hdc,hrgn,hbrush);  
    8.             //InvertRgn(hdc,hrgn);//取反  
    9.             //FrameRgn(hdc,hrgn,hbrush,0,0);  
    10.   
    11.               
    12.             r1.left=100;  
    13.             r1.top=100;  
    14.             r1.right=200;  
    15.             r1.bottom=200;  
    16.             hbrush=CreateSolidBrush(RGB(255,0,0));//創建畫刷  
    17.             //FillRect(hdc,&r1,hbrush);  
    18.   
    19.             r2.left=150;  
    20.             r2.top=100;  
    21.             r2.right=250;  
    22.             r2.bottom=200;  
    23.             //FrameRect(hdc,&r2,hbrush);  
    24.   
    25.             IntersectRect(&r3,&r1,&r2);//r1,r2矩形取交集,存放在r3  
    26.             FillRect(hdc,&r3,hbrush);  
    27.             flag=(int)IsRectEmpty(&r3);//判斷矩形是否為空  
    28.             TextOut(hdc,300,300,szBuffer,wsprintf(szBuffer,TEXT("%d"),flag));  
    29.   
    30.             EndPaint(hwnd,&ps);  
    31.             return 0;  


    RFID設備管理軟件

    [cpp] view plaincopy
    1. hrgn=CreateRectRgn(xleft,ytop,xright,ybottom);  
    2. hrgn=CreateRectRgnIndirect(&rect);  
    3. hrgn=CreateEllipticRgn(xleft,ytop,xright,ybottom);  
    4. hrgn=CreatePolygonRgn(&point,icount,ipolyFillMode);  
    RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成
    最近免费观看高清韩国日本大全