PolyBezierTo

PolyBezierTo用於將當前畫筆位置設為前一條曲線的終點。

基本介紹

  • 外文名:PolyBezierTo
  • 用途:將當前畫筆位置設為前條曲線終點
  • 函式原型:BOOL PolyBezierToCONST POINT
  • 參數表:hdc - Long在其中繪圖的設備場景
聲明,說明,函式原型,參數表,返回值,代碼示例,

聲明

Declare Function PolyBezierTo Lib "gdi32" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long

說明

描繪一條或多條貝塞爾(Bezier)曲線。PolyBezierTo用於將當前畫筆位置設為前一條曲線的終點

函式原型

(BOOL PolyBezierTo
HDChdc,
CONST POINT*lppt,
DWORDcCount
);

參數表

hdc ------------ Long,要在其中繪圖的設備場景
lppt ----------- POINTAPI,指定一個POINTAPI結構數組。其中的第一個結構指定了起點。剩下的點三個一組——包括兩個控制項點和一個終點
原文:An array of POINTAPI structures. The first structure
specifies the starting point. The remaining points are in groups of three, consisting of
two control points and an end point.
cPoints
Long,lppt數組的總點數

返回值

Long,非零表示成功,零表示失敗

代碼示例

#include<windows.h>LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,PSTRszCmdLine,intiCmdShow){    staticTCHARszAppName[]=TEXT("SysMets");    HWNDhwnd;    MSGmsg;    WNDCLASSwndclass;    wndclass.style=CS_HREDRAW|CS_VREDRAW;    wndclass.lpfnWndProc=WndProc;    wndclass.cbClsExtra=0;    wndclass.cbWndExtra=0;    wndclass.hInstance=hInstance;    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);    wndclass.lpszMenuName=NULL;    wndclass.lpszClassName=szAppName;    if(!RegisterClass(&wndclass))    {    MessageBox(NULL,TEXT("ProgramrequiresWindowsNT!"),szAppName,MB_ICONERROR);        return0;    }    hwnd=CreateWindow(szAppName,TEXT("GetSystemMetrics"),        WS_OVERLAPPEDWINDOW,        CW_USEDEFAULT,CW_USEDEFAULT,        CW_USEDEFAULT,CW_USEDEFAULT,        NULL,NULL,hInstance,NULL);    ShowWindow(hwnd,iCmdShow);    UpdateWindow(hwnd);    while(GetMessage(&msg,NULL,0,0))    {        TranslateMessage(&msg);        DispatchMessage(&msg);    }    returnmsg.wParam;}voidDrawBezier(HDChdc,POINTapt[]){    MoveToEx(hdc,apt[0].x,apt[0].y,NULL);    POINTszApt[]={apt[1],apt[2],apt[3]};    PolyBezierTo(hdc,szApt,3);    MoveToEx(hdc,apt[0].x,apt[0].y,NULL);    LineTo(hdc,apt[1].x,apt[1].y);    MoveToEx(hdc,apt[2].x,apt[2].y,NULL);    LineTo(hdc,apt[3].x,apt[3].y);}LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMlParam){    staticintcxClient,cyClient;    HDChdc;    staticPOINTapt[4];    PAINTSTRUCTps;    switch(message)    {    caseWM_SIZE:        cxClient=LOWORD(lParam);        cyClient=HIWORD(lParam);        apt[0].x=cxClient/4;        apt[0].y=cyClient/2;        apt[1].x=cxClient/2;        apt[1].y=cyClient/4;        apt[2].x=cxClient/2;        apt[2].y=3*cyClient/4;        apt[3].x=3*cxClient/4;        apt[3].y=cyClient/2;        break;    caseWM_LBUTTONDOWN:    caseWM_RBUTTONDOWN:    caseWM_MOUSEMOVE:        if(wParam&MK_LBUTTON||wParam&MK_RBUTTON)        {            hdc=GetDC(hwnd);            SelectObject(hdc,GetStockObject(WHITE_PEN));            DrawBezier(hdc,apt);            if(wParam&MK_LBUTTON)            {                apt[1].x=LOWORD(lParam);                apt[1].y=HIWORD(lParam);            }            if(wParam&MK_RBUTTON)            {                apt[2].x=LOWORD(lParam);                apt[2].y=HIWORD(lParam);            }            SelectObject(hdc,GetStockObject(BLACK_PEN));            DrawBezier(hdc,apt);            ReleaseDC(hwnd,hdc);        }        return0;    caseWM_PAINT:        InvalidateRect(hwnd,NULL,TRUE);        hdc=BeginPaint(hwnd,&ps);        DrawBezier(hdc,apt);        EndPaint(hwnd,&ps);        return0;    caseWM_DESTROY:        PostQuitMessage(0);        return0;    }    returnDefWindowProc(hwnd,message,wParam,lParam);}
結果顯示

相關詞條

熱門詞條

聯絡我們