本文整理匯總了C++中Ellipse函數的典型用法代碼示例。如果您正苦於以下問題:C++ Ellipse函數的具體用法?C++ Ellipse怎麽用?C++ Ellipse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Ellipse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CreateHatchBrush
void quadrupedClass::Draw(HDC hdc)const{
/*//DEBUGGING CODE: draw the redraw box.
//note: the box is not erased due to how this works (drawing what it would be the previous frame...),
//but it's a decent indicator of where the erasing will happen, to be sure it works properly
HBRUSH brushRed = CreateHatchBrush(HS_DIAGCROSS, RGB(255, 0, 0));
FillRect(hdc, &RedrawArea(true), brushRed);
//END debugging*/
HPEN penFront = CreatePen(PS_SOLID, 2, RGB(0, 0, 255));
HPEN penBack = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));//different colors for the legs
HPEN pen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0));//basic pen is black
HPEN oldPen = (HPEN)SelectObject(hdc, pen);//store the original pen
//head
Ellipse(hdc, Head.left, Head.top, Head.right, Head.bottom);
//back
DrawLine(hdc, Back.Start, Back.End);
//legs
//back
SelectObject(hdc, penBack);//change the pen
DrawLine(hdc, LegBB.Start, LegBB.End);
DrawLine(hdc, LegFB.Start, LegFB.End);
//front
SelectObject(hdc, penFront);//change the pen
DrawLine(hdc, LegFF.Start, LegFF.End);
DrawLine(hdc, LegBF.Start, LegBF.End);
//reset hdc
SelectObject(hdc, oldPen);
DeleteObject(pen);
DeleteObject(penFront);
DeleteObject(penBack);
}
示例2: Ellipse
heavysideFunction::value_type
heavysideFunction::operator()( node_type const& pointHat ) const
{
node_type Ellipse( pbeqspace_type::Dim );
node_type point( pbeqspace_type::Dim );
point = element_prod( *M_stretch,pointHat ) + ( *M_translation );
molecule_type::atoms_const_iterator_type atom( M_molecule->begin() );
for ( ; atom != M_molecule->end(); ++atom )
{
Ellipse = point - atom->center();
//if ( norm_inf(Ellipse) > atom->radius() ) continue;
if ( norm_2( Ellipse ) < atom->radius2() )
{
return 0;
}
}
return 1;
}
示例3: WindowProcedure
//.........這裏部分代碼省略.........
case VK_DOWN:
if(resizeCount>10) break;
for(int i=0; i<figureCount; i++) {
for(int j=0; j<4; j++) {
slope=(arrayPoints[i][j].y-(rect.bottom-126)/2)/(float)(arrayPoints[i][j].x-rect.right/2);
displacement=arrayPoints[i][j].y-slope*arrayPoints[i][j].x;
arrayPoints[i][j].x=(rect.right/2)-(rect.right/2-arrayPoints[i][j].x)*0.9;
arrayPoints[i][j].y=roundf(arrayPoints[i][j].x*slope+displacement);
}
}
resizeCount++;
break;
}
InvalidateRect(hwnd,&invalidationRect,TRUE);
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
//Create figures
SelectObject(hdc,GetStockObject(NULL_BRUSH));
for (int i=0; i<figureCount; i++) {
switch(arrayPoints[i][4].x) {
case ID_SWITCH_SQUARE:
Rectangle(hdc,arrayPoints[i][0].x,arrayPoints[i][0].y,arrayPoints[i][1].x,arrayPoints[i][1].y);
break;
case ID_SWITCH_CIRCLE:
Ellipse(hdc,arrayPoints[i][0].x,arrayPoints[i][0].y,arrayPoints[i][1].x,arrayPoints[i][1].y);
break;
case ID_SWITCH_BEZIER:
PolyBezier(hdc,arrayPoints[i],4);
break;
}
}
//Create traces
if (mouse_moving) {
if (drawing_circle) {
Ellipse(hdc,arrayPoints[figureCount][0].x,arrayPoints[figureCount][0].y,xFin,yFin);
}
if (drawing_bezier && !first_point) {
MoveToEx(hdc,arrayPoints[figureCount][0].x,arrayPoints[figureCount][0].y,NULL);
LineTo(hdc,xFin,yFin);
} else if (drawing_bezier) {
MoveToEx(hdc,arrayPoints[figureCount][0].x,arrayPoints[figureCount][0].y,NULL);
LineTo(hdc,xFin,yFin);
MoveToEx(hdc,arrayPoints[figureCount][2].x,arrayPoints[figureCount][2].y,NULL);
LineTo(hdc,xFinSecond,yFinSecond);
}
if (drawing_square) {
Rectangle(hdc,arrayPoints[figureCount][0].x,arrayPoints[figureCount][0].y,xFin,yFin);
}
}
SelectObject(hdc,GetStockObject(WHITE_BRUSH));
//Create the gradients
示例4: ellipse
void ellipse(int left,int top,int right, int bottom)
{
ACL_ASSERT_BEGIN_PAINT;
Ellipse(g_hmemdc,left,top,right,bottom);
}
示例5: DrawPoint
static void DrawPoint(void *data, long x, long y)
{
Ellipse((HDC)data,x-1,y-1,x+1,y+1);
}
示例6: WndProc
// funkcja okna zawieraj¹ca obs³ugê meldunków przesy³anych do okna
LRESULT CALLBACK WndProc (HWND Okno, UINT KodMeldunku, WPARAM wParam, LPARAM lParam)
{
// deklaracja zmiennych
HMENU mGlowne, mPlik, mInfo;
// obs³uga meldunku w zale¿noœci od kodu meldunku
switch (KodMeldunku)
{ case WM_CREATE: // obs³uga utworzenia okna - stworzenie menu
mPlik = CreateMenu();
AppendMenu(mPlik, MF_STRING, 100, "&Gong...");
AppendMenu(mPlik, MF_SEPARATOR, 0, "");
AppendMenu(mPlik, MF_STRING, 101, "&Koniec");
mInfo = CreateMenu();
AppendMenu(mInfo, MF_STRING, 102, "&Autor...");
mGlowne = CreateMenu();
AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mPlik, "&Plik");
AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mInfo, "&Info");
SetMenu(Okno, mGlowne);
DrawMenuBar(Okno);
return 0;
case WM_COMMAND: // obs³uga wyboru opcji z menu
switch (wParam)
{
case 100: if(MessageBox(Okno, "Czy wygenerowaæ gong?", "Gong", MB_YESNO) == IDYES)
MessageBeep(0);
break;
case 101: DestroyWindow(Okno); // wymuszenie meldunku WM_DESTROY
break;
case 102: MessageBox(Okno, "imiê i nazwisko:\nnumer indeksu: ", "Student PJWSTK", MB_OK);
}
return 0;
case WM_PAINT: // obs³uga odœwie¿enia okna
{ PAINTSTRUCT Paint;
HDC Kontekst = BeginPaint(Okno, &Paint);
HPEN Pioro = CreatePen(PS_SOLID, 15, RGB(255,0,0)); // czerwone pióro o gruboœci 15
HBRUSH Pedzel = CreateSolidBrush(RGB(255,0,0)); // czerwony pêdzel
SelectObject(Kontekst, Pioro);
// SelectObject(Kontekst, GetStockObject(WHITE_BRUSH)); // standardowy bia³y pêdzel
Ellipse(Kontekst, 100, 100, 300, 300); // narysowanie okrêgu za pomoc¹ aktywnych pióra i pêdzla
SelectObject(Kontekst, Pedzel);
POINT wielokat[] = {{106, 200}, {118, 248}, {152, 282}, {200, 294}, {248, 282}, {282, 248}, {294, 200}};
Polygon(Kontekst, wielokat, 7); // narysowanie wielok¹ta wype³niaj¹cego doln¹ po³owê okrêgu na czerwono
SetBkMode(Kontekst, TRANSPARENT); // wypisanie tekstu
SetTextAlign(Kontekst, TA_CENTER | TA_BOTTOM);
// SetTextColor(Kontekst, RGB(0,0,0));
TextOut(Kontekst, 200, 200, "P J W S T K", 11);
DeleteObject(Pioro); // usuniêcie niepotrzebnych przyborów graficznych
DeleteObject(Pedzel);
EndPaint(Okno, &Paint);
}
return 0;
case WM_DESTROY: // obs³uga zamkniêcia okna - wygenerowanie meldunku WM_QUIT
PostQuitMessage (0) ;
return 0;
default: // standardowa obs³uga wszystkich pozosta³ych meldunków
return DefWindowProc(Okno, KodMeldunku, wParam, lParam);
}
}
示例7: RenderOffscreen
void RenderOffscreen(HDC hDestDC)
{
HDC hdc = hDestDC; // CreateCompatibleDC(hWndMain);
int err=GetLastError();
HBITMAP hOldBitmap = SelectObject(hdc, hbmpOffscreen);
RECT rect;
HPEN hPen;
double dx, dy, px, py, AngRad, dDeltaAng;
int pos, p1;
long CenterX, CenterY;
hPen = SelectObject(hdc, CreatePen(PS_SOLID, 3, 0L));
GetClientRect(hWndMain, &rect);
/* Draw the table */
CenterX = (rect.right - rect.left)/2;
CenterY = (rect.bottom - rect.top)/2;
Ellipse(hdc, CenterX - 100, CenterY - 100, CenterX + 100, CenterY + 100);
/* Draw the chopsticks */
dDeltaAng = 360 / PHILOSOPHERS;
for (pos = 0; pos < PHILOSOPHERS; pos++) //FIXIT
{
/* Draw the chopsticks */
AngRad = (pos * dDeltaAng)/57.29577951;
dx = CenterX + (sin(AngRad)*60);
dy = CenterY - (cos(AngRad)*60);
MoveToEx(hdc, (int)dx, (int)dy, NULL);
dx = CenterX + (sin(AngRad)*85);
dy = CenterY - (cos(AngRad)*85);
LineTo(hdc, (int)dx, (int)dy);
//Draw the plate
AngRad = ((pos * dDeltaAng+dDeltaAng / 2))/57.29577951;
dx = CenterX + (sin(AngRad) * 72);
dy = CenterY - (cos(AngRad) * 72);
Ellipse(hdc, (int)dx-12, (int)dy-12, (int)dx+12, (int)dy+12);
}
/* delete the black pen */
DeleteObject(SelectObject(hdc, hPen));
/* Draw the philosophers */
for(pos = 0; pos < PHILOSOPHERS; pos++)
{
/* select a pen for each philosopher */
switch (gDinerState[pos])
{
case RESTING:
hPen = SelectObject(hdc, CreatePen(PS_SOLID, 3, RGB(0, 255, 0)));
break;
case WAITING:
case EATING:
hPen = SelectObject(hdc, CreatePen(PS_SOLID, 3, RGB(255, 0, 0)));
break;
default:
hPen = SelectObject(hdc, CreatePen(PS_SOLID, 3, 0L));
}
AngRad = ((pos * dDeltaAng) + dDeltaAng / 2)/57.29577951;
px = CenterX + (sin(AngRad)*150);
py = CenterY - (cos(AngRad)*150);
/* Draw the Philosopher */
Ellipse(hdc, (int)px-25, (int)py-25, (int)px+25, (int)py+25);
//Draw the left arm
if (gChopstickState[pos] == pos)
{
MoveToEx(hdc, (int)px, (int)py, NULL);
AngRad = (pos * dDeltaAng)/57.29577951;
dx = CenterX + (sin(AngRad)*85);
dy = CenterY - (cos(AngRad)*85);
LineTo(hdc, (int)dx, (int)dy);
}
//Draw the right arm
p1 = pos + 1;
if (p1 == PHILOSOPHERS)
p1 = 0;
if (gChopstickState[p1] == pos)
{
MoveToEx(hdc, (int)px, (int)py, NULL);
AngRad = (p1 * dDeltaAng)/57.29577951;
dx = CenterX + (sin(AngRad)*85);
dy = CenterY - (cos(AngRad)*85);
LineTo(hdc, (int)dx, (int)dy);
}
/* Delete the pen */
DeleteObject(SelectObject(hdc, hPen));
} //for pos
BitBlt( hDestDC,
rect.left,
rect.top,
rect.right - rect.left,
//.........這裏部分代碼省略.........
示例8: draw_stat_chart
//繪製實驗統計數據圖表
void draw_stat_chart(PHISTORY history, RECT &rect, int max_round, int min_round, double max_value, double min_value, int type)
{
int x = type == 0 ? rect.left : rect.right;
if(type < 2)
{
draw_line(x, rect.top, x, rect.bottom);
}
int h = (rect.bottom - rect.top) / DRAW_STAT_TAG_NUM;
x += type == 0 ? -DRAW_STAT_TAG_LEN : DRAW_STAT_TAG_LEN;
int y = rect.bottom;
double value = (max_value - min_value) / DRAW_STAT_TAG_NUM;
char buf[MAX_LOADSTRING];
for(int i=0;i<=DRAW_STAT_TAG_NUM;i++)
{
if(type < 2)
{
draw_line(x, y, type == 0 ? rect.left : rect.right, y);
}
sprintf_s(buf, sizeof(buf), "%.1f", min_value + value * i);
switch(type)
{
case 0:
{
RECT r = {gDrawClientRect.left, y - h, x, y};
DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_RIGHT | DT_BOTTOM | DT_SINGLELINE);
}
break;
case 1:
{
RECT r = {x, y - h, gDrawClientRect.right, y};
DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_LEFT | DT_BOTTOM | DT_SINGLELINE);
}
break;
default:
if(i > 0)
{
RECT r = {x, y, gDrawClientRect.right, y + h};
DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_LEFT | DT_TOP | DT_SINGLELINE);
}
break;
}
y -= h;
}
PHISTORYITEM p = history->head;
int height = rect.bottom - rect.top;
int width = rect.right - rect.left;
const int cr = type == 0 ? 4 : 3;
int i = 0;
while(p != NULL)
{
x = rect.left + width * (p->round - min_round) / (max_round - min_round);
switch(type)
{
case 0:
y = rect.bottom - (int)(height * (p->top[0].generation - min_value) / (max_value - min_value));
break;
case 1:
value = (double)p->round / p->top[0].generation;
y = rect.bottom - (int)(height * (value - min_value) / (max_value - min_value));
break;
default:
value = (double)p->top[0].score / gConfig.lab_more_count;
y = rect.bottom - (int)(height * (value - min_value) / (max_value - min_value));
break;
}
if(i > 0)
{
LineTo(gDrawBmpMemDC, x, y);
}
else
{
MoveToEx(gDrawBmpMemDC, x, y, NULL);
Ellipse(gDrawBmpMemDC, x-cr, y-cr, x+cr, y+cr);
}
i++;
p = p->next;
}
if(i > 1)
{
Ellipse(gDrawBmpMemDC, x-cr, y-cr, x+cr, y+cr);
}
switch(type)
{
case 0:
{
RECT r = {rect.left, gDrawClientRect.top, rect.right/3, rect.top};
sprintf_s(buf, sizeof(buf), "%s", "—— 子代");
DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
}
break;
case 1:
{
RECT r = {rect.right/3, gDrawClientRect.top, rect.right*2/3, rect.top};
sprintf_s(buf, sizeof(buf), "%s", "—— 代比");
DrawText(gDrawBmpMemDC, buf, (int)strlen(buf), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
//.........這裏部分代碼省略.........
示例9: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UINT code; // код уведомления
UINT idCtrl; // идентификатор дочернего окна
HWND hChild;
HDC hdc;
HBRUSH hBrush;
switch (msg)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
RECT rc;
// Перерисовываем внутреннюю область окна
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
EndPaint(hWnd, &ps);
break;
case WM_COPYDATA:
szBuf =(int*) ((PCOPYDATASTRUCT)lParam)->lpData;
i = szBuf[0];
j = szBuf[1];
k = szBuf[2];
break;
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
{
if (k == 1)
{
hdc = GetDC(hWnd);
hBrush = CreateSolidBrush(RGB(255, 0, 0));
switch (i)
{
case 1:
hBrush = CreateSolidBrush(RGB(255, 0, 0));
break;
case 2:
hBrush = CreateSolidBrush(RGB(0, 0, 255));
break;
case 3:
hBrush = CreateSolidBrush(RGB(0, 255, 0));
break;
}
SelectObject(hdc, hBrush);
switch (j)
{
case 1:
POINT poly[5];
poly[0].x = LOWORD(lParam);
poly[0].y = HIWORD(lParam)-50;
poly[1].x = LOWORD(lParam) - 40;
poly[1].y = HIWORD(lParam) ;
poly[2].x = LOWORD(lParam);
poly[2].y = HIWORD(lParam) + 50;
poly[3].x = LOWORD(lParam) + 40;
poly[3].y = HIWORD(lParam) ;
poly[4].x = LOWORD(lParam);
poly[4].y = HIWORD(lParam)-50;
Polyline(hdc, poly, 5);
FloodFill(hdc, LOWORD(lParam), HIWORD(lParam), 0);
break;
case 2:
Rectangle(hdc, LOWORD(lParam)-50, HIWORD(lParam)-50, LOWORD(lParam) + 50, HIWORD(lParam) + 50);
break;
case 3:
Ellipse(hdc, LOWORD(lParam)-50, HIWORD(lParam)-50, LOWORD(lParam) + 50, HIWORD(lParam) + 50);
break;
case 4:
POINT poly1[11];
poly1[0].x = LOWORD(lParam);
poly1[0].y = HIWORD(lParam)-90;
poly1[1].x = LOWORD(lParam) - 30;
poly1[1].y = HIWORD(lParam) - 30;
poly1[2].x = LOWORD(lParam) - 90;
poly1[2].y = HIWORD(lParam) - 20;
poly1[3].x = LOWORD(lParam) - 50;
poly1[3].y = HIWORD(lParam) + 30;
poly1[4].x = LOWORD(lParam) - 60;
poly1[4].y = HIWORD(lParam) + 90;
poly1[5].x = LOWORD(lParam);
poly1[5].y = HIWORD(lParam) + 70;
//.........這裏部分代碼省略.........
示例10: GetDC
//.........這裏部分代碼省略.........
int x, y, dx, dy, cx, cy;
OldROP = SetROP2(hDC, R2_NOT);
GetClientRect(hWnd, &ClientRect);
dx = abs(RectWidth(&SelectRect));
dy = abs(RectHeight(&SelectRect));
if (dx > CLOSENESS && dy > CLOSENESS)
{
x = min(SelectRect.left, SelectRect.right);
cx = x;
Image2Control(&cx, &cy);
while (cx >= ClientRect.left)
{
MoveToEx(hDC, cx, ClientRect.top, NULL);
LineTo(hDC, cx, ClientRect.bottom);
x -= dx;
cx = x;
Image2Control(&cx, &cy);
}
x = max(SelectRect.left, SelectRect.right);
cx = x;
Image2Control(&cx, &cy);
while (cx <= ClientRect.right)
{
MoveToEx(hDC, cx, ClientRect.top, NULL);
LineTo(hDC, cx, ClientRect.bottom);
x += dx;
cx = x;
Image2Control(&cx, &cy);
}
y = min(SelectRect.top, SelectRect.bottom);
cy = y;
Image2Control(&cx, &cy);
while (cy >= ClientRect.top)
{
MoveToEx(hDC, ClientRect.left, cy, NULL);
LineTo(hDC, ClientRect.right, cy);
y -= dy;
cy = y;
Image2Control(&cx, &cy);
}
y = max(SelectRect.top, SelectRect.bottom);
cy = y;
Image2Control(&cx, &cy);
while (cy <= ClientRect.bottom)
{
MoveToEx(hDC, ClientRect.left, cy, NULL);
LineTo(hDC, ClientRect.right, cy);
y += dy;
cy = y;
Image2Control(&cx, &cy);
}
}
else
{
Image2Control((LPINT)&SelectRect.left, (LPINT)&SelectRect.top);
Image2Control((LPINT)&SelectRect.right, (LPINT)&SelectRect.bottom);
MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
LineTo(hDC, SelectRect.right, SelectRect.top);
LineTo(hDC, SelectRect.right, SelectRect.bottom);
LineTo(hDC, SelectRect.left, SelectRect.bottom);
LineTo(hDC, SelectRect.left, SelectRect.top);
}
SetROP2(hDC, OldROP);
break;
}
#endif NOTUSED //j
case SL_LINE:
{
OldROP = SetROP2(hDC, R2_NOT);
MoveToEx(hDC, SelectRect.left, SelectRect.top, NULL);
LineTo(hDC, SelectRect.right, SelectRect.bottom);
SetROP2(hDC, OldROP);
break;
}
case SL_ELLIPSE:
{
OldROP = SetROP2(hDC, R2_NOT);
HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
Ellipse(hDC, SelectRect.left, SelectRect.top,
SelectRect.right, SelectRect.bottom);
SetROP2(hDC, OldROP);
SelectObject(hDC, hOldBrush);
break;
}
case SL_BLOCK:
{
PatBlt(hDC, SelectRect.left, SelectRect.top,
SelectRect.right - SelectRect.left,
SelectRect.bottom - SelectRect.top, DSTINVERT);
break;
}
}
if (fNeedDC)
ReleaseDC(hWnd, hDC);
}
示例11: WndProc
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_COMMAND :
switch( LOWORD( wParam ) )
{
case IDM_TEST :
{
BITMAPINFOHEADER bi;
BITMAPINFOHEADER* lpbi;
HBITMAP hBitmap;
HDC hDC, hMemDC;
HANDLE hDIB;
// Initialize the BITMAPINFOHEADER structure.
//...........................................
bi.biSize = sizeof( BITMAPINFOHEADER );
bi.biWidth = 50;
bi.biHeight = 50;
bi.biPlanes = 1;
bi.biBitCount = 4;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
hDC = GetDC( hWnd );
// Create DIB.
//............
hBitmap = CreateDIBitmap( hDC, &bi, 0L, NULL,
NULL, 0 );
// Allocate memory for BITMAPINFO structure.
//..........................................
hDIB = GlobalAlloc( GHND,
sizeof( BITMAPINFOHEADER )+
16 * sizeof( RGBQUAD ) );
lpbi = (BITMAPINFOHEADER*)GlobalLock( hDIB );
// Copy bi to top of BITMAPINFO structure.
//........................................
*lpbi = bi;
// Use GetDIBits() to init bi struct data.
//........................................
GetDIBits( hDC, hBitmap, 0, 50, NULL,
(LPBITMAPINFO)lpbi, DIB_RGB_COLORS );
GlobalUnlock( hDIB );
// Create a memory device context
// and select the DIB into it.
//...............................
hMemDC = CreateCompatibleDC( hDC );
SelectObject( hMemDC, hBitmap );
// Paint on memory device context.
//................................
SelectObject( hMemDC, GetStockObject(BLACK_BRUSH));
Rectangle( hMemDC, 0, 0, 50, 50 );
SelectObject( hMemDC, GetStockObject(WHITE_BRUSH));
Ellipse( hMemDC, 0, 0, 50, 50 );
Ellipse( hMemDC, 10, 0, 40, 50 );
Ellipse( hMemDC, 20, 0, 30, 50 );
// Paint the bitmap on the display.
//.................................
BitBlt( hDC, 0, 0, 50, 50,
hMemDC, 0, 0, SRCCOPY );
DeleteDC( hMemDC );
GlobalFree( hDIB );
ReleaseDC( hWnd, hDC );
}
break;
case IDM_ABOUT :
DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
break;
case IDM_EXIT :
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY :
PostQuitMessage(0);
break;
default :
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}
return( 0L );
//.........這裏部分代碼省略.........
示例12: WinFun
LRESULT CALLBACK WinFun(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
HPEN Pen=CreatePen(PS_DASHDOTDOT, 1, RGB(130,10,130)); // Стиль и цвет границы
HBRUSH br=CreateHatchBrush(HS_DIAGCROSS, RGB(255,255,0)); // Стиль и цвет штриховки
switch(message)
{
case WM_RBUTTONDOWN:
x2=x1=LOWORD(lParam);
y2=y1=HIWORD(lParam);
break;
case WM_MOUSEMOVE:
if (wParam & MK_RBUTTON) // Определяем нажатие правой кнопки мыши
{
x2=LOWORD(lParam);
y2=HIWORD(lParam);
}
break;
case WM_RBUTTONUP: // Отпускаем правую кнопку мыши
hdc=GetDC(hwnd);
SelectObject(hdc, Pen); // Делаем перо активным
Ellipse(hdc, x1, y1, x2, y2); // Определяем размеры эллипса
SelectObject(hdc, br); // Делаем кисть активной
Ellipse(hdc, x1, y1, x2, y2); // Определяем размеры заштрихованной части
DeleteObject(Pen); // Удаляем перо
DeleteObject(br); // Удаляем кисть
ReleaseDC(hwnd, hdc);
p=new EllipsList;
p->L.x1=x1; p->L.x2=x2;
p->L.y1=y1; p->L.y2=y2;
add(pFirst, p);
break;
//case WM_ERASEBKGND: // Не стирает рисунок
case WM_PAINT: // Перерисовка
hdc=BeginPaint(hwnd, &ps);
p=pFirst;
while(p) // Просматриваем список и рисуем эллипс
{
SelectObject(hdc, Pen); // Делаем перо активным
Ellipse(hdc, p->L.x1, p->L.y1, p->L.x2, p->L.y2); // Определяем размеры эллипса
SelectObject(hdc, br); // Делаем кисть активной
Ellipse(hdc, p->L.x1, p->L.y1, p->L.x2, p->L.y2); // Определяем размеры заштрихованной части
p=p->pNext;
}
EndPaint(hwnd, &ps);
break;
case WM_DESTROY: // Завершение программы
PostQuitMessage(0);
break;
default:
// Позволяет Windows обрабатывать любые сообщения, неуказанные в предыдущем случае
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
示例13: switch
BOOL TabletBase::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam)
{
PACKET pkt; /* the current packet */
HDC hDC; /* handle for Device Context */
PAINTSTRUCT psPaint; /* the paint structure */
//渡された message から、イベントの種類を解析する
switch(msg){
case WM_PAINT: { /* Paint the window */
int ZAngle; /* Raw Altitude */
UINT Thata; /* Raw Azimuth */
double ZAngle2; /* Adjusted Altitude */
double Thata2; /* Adjusted Azimuth */
char szOutput[128]; /* String for outputs */
if (m_TiltSupport) {
/*
wintab.h defines .orAltitude
as a UINT but documents .orAltitude
as positive for upward angles
and negative for downward angles.
WACOM uses negative altitude values to
show that the pen is inverted;
therefore we cast .orAltitude as an
(int) and then use the absolute value.
*/
ZAngle = (int)m_ortNew.orAltitude;
ZAngle2 = m_altAdjust - (double)abs(ZAngle)/m_altFactor;
/* adjust azimuth */
Thata = m_ortNew.orAzimuth;
Thata2 = (double)Thata/m_aziFactor;
/* get the length of the diagnal to draw */
m_Z1Angle.x = (int)(ZAngle2*sin(Thata2));
m_Z1Angle.y = (int)(ZAngle2*cos(Thata2));
}
else {
m_Z1Angle.x = 0;
m_Z1Angle.y = 0;
}
if (hDC = BeginPaint(m_hWnd, &psPaint)) {
/* write raw tilt info */
if (m_TiltSupport) {
wsprintf((LPSTR)szOutput,"Tilt: %03i, Thata: %04u\0",
ZAngle,Thata);
}
else {
strcpy(szOutput,"Tilt not supported.");
}
DrawText(hDC,szOutput,strlen(szOutput),&m_rcInfoTilt,DT_LEFT);
/* write current cursor name */
gpWTInfoA(WTI_CURSORS + m_curNew, CSR_NAME, szOutput);
DrawText(hDC,szOutput,strlen(szOutput),&m_rcInfoName,DT_LEFT);
/* write tablet name */
gpWTInfoA(WTI_DEVICES, DVC_NAME, szOutput);
DrawText(hDC,szOutput,strlen(szOutput),&m_rcInfoGen,DT_LEFT);
/* draw circle based on tablet pressure */
Ellipse(hDC, m_ptNew.x - m_prsNew, m_ptNew.y - m_prsNew,
m_ptNew.x + m_prsNew, m_ptNew.y + m_prsNew);
/* draw a line based on tablet tilt */
MoveTo(hDC, m_ptNew.x, m_ptNew.y);
LineTo(hDC, m_ptNew.x + m_Z1Angle.x, m_ptNew.y - m_Z1Angle.y);
/* draw CROSS based on tablet position */
MoveTo(hDC, m_ptNew.x - 20, m_ptNew.y );
LineTo(hDC, m_ptNew.x + 20, m_ptNew.y );
MoveTo(hDC, m_ptNew.x , m_ptNew.y - 20);
LineTo(hDC, m_ptNew.x , m_ptNew.y + 20);
EndPaint(m_hWnd, &psPaint);
}
break;
}
case WT_PACKET: /* A packet is waiting from WINTAB */
if (gpWTPacket((HCTX)lParam, wParam, &pkt)) {
/* old co-ordinates used for comparisons */
POINT ptOld = m_ptNew;
UINT prsOld = m_prsNew;
UINT curOld = m_curNew;
ORIENTATION ortOld = m_ortNew;
/* save new co-ordinates */
m_ptNew.x = (UINT)pkt.pkX;
m_ptNew.y = (UINT)pkt.pkY;
m_curNew = pkt.pkCursor;
m_prsNew = pkt.pkNormalPressure;
m_ortNew = pkt.pkOrientation;
/* If the visual changes update the main graphic */
if (m_ptNew.x != ptOld.x ||
m_ptNew.y != ptOld.y ||
m_prsNew != prsOld ||
//.........這裏部分代碼省略.........
示例14: WindowProcedure
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:
//.........這裏部分代碼省略.........
示例15: WndclProc
LRESULT CALLBACK WndclProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HDC hdcch,hdcch1;
int width=200, height=200;
static HPEN pens, penm, penh;
COLORREF clr;
PAINTSTRUCT ps;
TIME time;
LPARAM param;
RECT rect;
static int timer,min,hour,xs,ys,xm,ym,xh,yh;
HBITMAP hbmp;
switch (message)
{
case WM_CREATE:
hdcch = GetDC(hWnd);
hdcch1 = CreateCompatibleDC(hdcch);
hbmp = CreateCompatibleBitmap(hdcch, width, height);
pens = CreatePen(PS_SOLID, 1,RGB(0,0,0));
penm = CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
penh = CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
SelectObject(hdcch1, hbmp);
rect.left = 0;
rect.top = 0;
rect.right = width;
rect.bottom = height;
FillRect(hdcch1, &rect, (HBRUSH)CreateSolidBrush(RGB(255, 255, 255)));
SelectObject(hdcch1, penh);
Ellipse(hdcch1, 30, 20, 160, 150);
TextOut(hdcch1, 88, 25, L"12", 2);
TextOut(hdcch1, 145, 75, L"3", 1);
TextOut(hdcch1, 90, 130, L"6", 1);
TextOut(hdcch1, 35, 75, L"9", 1);
ReleaseDC(hWnd, hdcch);
timer = SetTimer(hWnd, 1, 1000, NULL);
time.xs = 0;
time.ys = -60;
time.xm = 0;
time.ym = -50;
time.xh = 0;
time.yh = -30;
time.min = 0;
time.hour = 0;
SetTime(time);
xs=time.xs;
ys=time.ys;
xm=time.xm;
ym=time.ym;
xh=time.xh;
yh=time.yh;
min=time.min;
hour=time.hour;
break;
case WM_TIMER:
hdcch = GetDC(hWnd);
min++;
if (min== 60)
{
NewHand(xm, ym);
min = 0;
xs = 0;
ys = -60;
hour++;
}
if (hour == 12)
{
NewHand(xh, yh);
hour = 0;
}
NewHand(xs, ys);
BitBlt(hdcch, 0, 0, 200, 200, hdcch1, 0, 0, SRCCOPY);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, pens);
LineTo(hdcch, xs+95, ys+85);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, penm);
LineTo(hdcch, xm+95, ym+85);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, penh);
LineTo(hdcch, xh+95, yh+85);
ReleaseDC(hWnd, hdcch);
break;
case WM_PAINT:
hdcch = BeginPaint(hWnd, &ps);
BitBlt(hdcch, 0, 0, 200,200 , hdcch1, 0, 0, SRCCOPY);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, pens);
LineTo(hdcch, xs+95, ys+85);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, penm);
LineTo(hdcch, xm+95, ym+85);
MoveToEx(hdcch, 95, 85, NULL);
SelectObject(hdcch, penh);
LineTo(hdcch, xh+95, yh+85);
EndPaint(hWnd, &ps);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
//.........這裏部分代碼省略.........