TeamsWindow::TeamsWindow( HINSTANCE hInst, HWND hWndParent, unsigned short usWidth, unsigned short usHeight ) : ChildWindow(hInst, TEAMS_CLASS_NAME, GetAppName(), WS_CHILD, CHILD_ID_TEAMS, hWndParent) { unsigned short i; fInBitmap = FALSE; usSelectedTeam = 0; usClientWidth = usWidth; usClientHeight = usHeight; usMiniCarWidth = usClientWidth / TEAMS_NUM_X; usMiniCarHeight = usClientHeight / TEAMS_NUM_Y; pClientBitmap = new Bitmap(pF1CarBitmap, usClientWidth, usClientHeight); ASSERT(pClientBitmap != NULL); pCursorTeamCar = new Cursor(Instance(), APP_CURSOR_TEAMCAR); ASSERT(pCursorTeamCar != NULL); CAR_REGIONS *pCR = car_regions; for (i = 0; i < NUM_ELEMENTS(car_regions); i++, pCR++) { pCR->hRgn = CreatePolygonRgn(pCR->points, pCR->usPoints, ALTERNATE); ASSERT(pCR->hRgn != NULL); } UpdateMemoryImage(); DragAcceptFiles(Handle(), TRUE); }
void CFileAskDlg::SetDlgReign() { int UI_ROUNDRECT_WIDTH = 16; int UI_ROUNDRECT_HEIGHT = 16; CRect rc; POINT Points[6]; GetClientRect(&rc); HRGN rgn1 = CreateRoundRectRgn(0, 0, rc.Width() / 2, rc.Height() / 2, UI_ROUNDRECT_WIDTH, UI_ROUNDRECT_HEIGHT); Points[0].x = 0; Points[0].y = UI_ROUNDRECT_HEIGHT; Points[1].x = 0; Points[1].y = rc.Height() + UI_ROUNDRECT_HEIGHT; Points[2].x = rc.Width() + UI_ROUNDRECT_WIDTH; Points[2].y = rc.Height() + UI_ROUNDRECT_HEIGHT; Points[3].x = rc.Width() + UI_ROUNDRECT_WIDTH; Points[3].y = 0; Points[4].x = UI_ROUNDRECT_WIDTH; Points[4].y = 0; Points[5].x = UI_ROUNDRECT_WIDTH; Points[5].y = UI_ROUNDRECT_HEIGHT; HRGN rgn2 = CreatePolygonRgn(Points, 6, ALTERNATE); CombineRgn(rgn1, rgn1, rgn2, RGN_OR); SetWindowRgn(rgn1, TRUE); DeleteObject(rgn2); }
TEST(NtGdiTests, CreatePolygonRgn) { /* Test i#809 */ /* Allocate a 0-sized array, which raised a false pos in i#809 */ POINT *points = new POINT[0]; HRGN hrgn = CreatePolygonRgn(points, 0, ALTERNATE); EXPECT_EQ((HRGN)NULL, hrgn); delete [] points; points = new POINT[3]; memset(points, 0, 3*sizeof(POINT)); hrgn = CreatePolygonRgn(points, 3, ALTERNATE); EXPECT_NE((HRGN)NULL, hrgn); DeleteObject(hrgn); delete [] points; }
CXTPColorHex::CRgnCell::CRgnCell(CRect& rect, COLORREF color, int u, int d, int x, int y, BOOL bLarge /*=FALSE*/) : m_color(color) { m_iCell[0] = u; m_iCell[1] = d; rect = CRect(x, y, x + (bLarge? XTP_CXCELL: XTP_CXSMCELL), y + (bLarge? XTP_CYCELL: XTP_CYSMCELL)); m_rect = rect; if (bLarge) { m_pts[0] = CPoint(rect.left+14, rect.top); m_pts[1] = CPoint(rect.right, rect.top+8); m_pts[2] = CPoint(rect.right, rect.top+24); m_pts[3] = CPoint(rect.left+14, rect.bottom+2); m_pts[4] = CPoint(rect.left, rect.top+24); m_pts[5] = CPoint(rect.left, rect.top+8); } else { m_pts[0] = CPoint(rect.left+7, rect.top); m_pts[1] = CPoint(rect.right, rect.top+4); m_pts[2] = CPoint(rect.right, rect.top+12); m_pts[3] = CPoint(rect.left+7, rect.bottom+1); m_pts[4] = CPoint(rect.left, rect.top+12); m_pts[5] = CPoint(rect.left, rect.top+4); } VERIFY(CreatePolygonRgn(m_pts, 6, WINDING)); }
HRGN WinCreatePolygonRgn (POINT * lppt, int cPoints, int fnPolyFillMode) { HRGN theRegion; theRegion = CreatePolygonRgn (lppt, cPoints, fnPolyFillMode == 1 ? ALTERNATE : WINDING); if (theRegion==NULL) ErrorExit ("Fatal error in WinCreatePolygonRgn: CreatePolygonRgn returned NULL."); return theRegion; } /* WinCreatePolygonRgn */
// 设置窗口圆角2012.10.15 yyf void CIMWnd::SetWndRgn(void) { POINT m_arPoints[8]; CRect winRect; GetWindowRect(&winRect); ScreenToClient(&winRect); //m_arPoints[0].x = winRect.left; //m_arPoints[0].y = winRect.top+4; //m_arPoints[1].x = winRect.left+4; //m_arPoints[1].y = winRect.top; //m_arPoints[2].x = winRect.right-4; //m_arPoints[2].y = winRect.left; //m_arPoints[3].x = winRect.right; //m_arPoints[3].y = winRect.left+4; //m_arPoints[4].x = winRect.right; //m_arPoints[4].y = winRect.bottom-4; //m_arPoints[5].x = winRect.right-4; //m_arPoints[5].y = winRect.bottom; //m_arPoints[6].x = winRect.left+4; //m_arPoints[6].y = winRect.bottom; //m_arPoints[7].x = winRect.left; //m_arPoints[7].y = winRect.bottom-4; //左上角 m_arPoints[0].x = winRect.left; m_arPoints[0].y = winRect.top+3; m_arPoints[1].x = winRect.left+3; m_arPoints[1].y = winRect.top; //右上角 m_arPoints[2].x = winRect.right-3; m_arPoints[2].y = winRect.top; m_arPoints[3].x = winRect.right; m_arPoints[3].y = winRect.top+3; //右下角 m_arPoints[4].x = winRect.right; m_arPoints[4].y = winRect.bottom-4; m_arPoints[5].x = winRect.right-4; m_arPoints[5].y = winRect.bottom; //左下角 m_arPoints[6].x = winRect.left+4; m_arPoints[6].y = winRect.bottom; m_arPoints[7].x = winRect.left; m_arPoints[7].y = winRect.bottom-4; HRGN hRgn = CreatePolygonRgn(m_arPoints, 8, WINDING); if (hRgn!=NULL) { SetWindowRgn(hRgn,TRUE); DeleteObject(hRgn); } }
void DrawMapBoundsPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings, Boolean erasePolygon) { long numPts = (**MapPolyHdl).pointCount; POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT)); POINT *pointsPtr = (POINT*)_NewPtr(numPts *sizeof(POINT)); LongPoint** thisPointsHdl=nil; Point pt; LongPoint wPt; long i; Boolean offQuickDrawPlane = false; RGBColor saveColor; // JLM ?? wouldn't compile without this if(!pointsH || !pointsPtr) {SysBeep(5); return;} thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl; for(i = 0; i< numPts;i++) { wPt = INDEXH(thisPointsHdl,i); pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane); INDEXH(pointsH,i) = MakePOINT(pt.h,pt.v); (pointsPtr)[i] = MakePOINT(pt.h,pt.v); // code goes here, make sure this point does not equal previous point JLM } GetForeColor (&saveColor); /* save original forecolor */ if (erasePolygon) { RgnHandle newClip=0; HBRUSH whiteBrush; newClip = CreatePolygonRgn((const POINT*)pointsPtr,numPts,ALTERNATE); whiteBrush = (HBRUSH)GetStockObject(WHITE_BRUSH); //err = SelectClipRgn(currentHDC,savedClip); FillRgn(currentHDC, newClip, whiteBrush); //DeleteObject(newClip); DisposeRgn(newClip); //SelectClipRgn(currentHDC,0); } else { POINT p[2]; p[0] = INDEXH(pointsH,numPts-1); p[1] = INDEXH(pointsH,0); RGBForeColor(&colors[BLACK]); if(numPts >= 2) { Polyline(currentHDC,*pointsH,numPts); Polyline(currentHDC,p,2); // close the polygon } } RGBForeColor (&saveColor); DisposeHandle((Handle)pointsH); if(pointsPtr) {_DisposePtr((Ptr)pointsPtr); pointsPtr = 0;} }
// Construct polygon region FXRegion::FXRegion(const FXPoint* points,FXuint npoints,FXbool winding){ #ifdef WIN32 register FXuint i; POINT pts[1024]; for(i=0; i<npoints; i++){ pts[i].x=points[i].x; pts[i].y=points[i].y; } region=(void*)CreatePolygonRgn(pts,npoints,winding?WINDING:ALTERNATE); #else region=XPolygonRegion((XPoint*)points,npoints,winding?WindingRule:EvenOddRule); #endif }
static BOOL render_set_background (POINT *rgn_points, int num_points) { HRGN rgn = CreatePolygonRgn (rgn_points, num_points, WINDING); if (!rgn) return FALSE; if (!SetWindowRgn (m_hwnd, rgn, TRUE)) return FALSE; return TRUE; }
static void hugsprim_CreatePolygonRgn_8(HugsStackPtr hugs_root) { HsPtr arg1; HsInt arg2; HsInt32 arg3; HsPtr res1; arg1 = hugs->getPtr(); arg2 = hugs->getInt(); arg3 = hugs->getInt32(); res1 = CreatePolygonRgn(arg1, arg2, arg3); hugs->putPtr(res1); hugs->returnIO(hugs_root,1); }
HRGN qt_tryCreatePolygonRegion(const QPolygon &a, Qt::FillRule fillRule) { const int tries = 10; for (int i = 0; i < tries; ++i) { HRGN region = CreatePolygonRgn(reinterpret_cast<const POINT*>(a.data()), a.size(), fillRule == Qt::OddEvenFill ? ALTERNATE : WINDING); if (region) { if (GetRegionData(region, 0, 0)) return region; else DeleteObject(region); } } return 0; }
void PaintSur::PolygonImage(const std::vector<RenderVertex> &rgv, HBITMAP hbm, const float left, const float top, const float right, const float bottom, const int bitmapwidth, const int bitmapheight) { const int ix = SCALEXf(left); const int iy = SCALEYf(top); const int ix2 = SCALEXf(right); const int iy2 = SCALEYf(bottom); const HDC hdcNew = CreateCompatibleDC(m_hdc); const HBITMAP hbmOld = (HBITMAP)SelectObject(hdcNew, hbm); std::vector<POINT> rgpt(rgv.size()); for (size_t i = 0; i < rgv.size(); i++) { rgpt[i].x = SCALEXf(rgv[i].x); rgpt[i].y = SCALEYf(rgv[i].y); } if (GetWinVersion() >= 2600) // For everything newer than Windows XP: use the alpha in the bitmap (RGB needs to be premultiplied with alpha, too, then! see CopyTo_ConvertAlpha()) { const HRGN hrgn = CreatePolygonRgn(rgpt.data(), (int)rgv.size(), WINDING); SelectClipRgn(m_hdc, hrgn); const BLENDFUNCTION blendf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; AlphaBlend(m_hdc, ix, iy, ix2 - ix, iy2 - iy, hdcNew, 0, 0, bitmapwidth, bitmapheight, blendf); SelectClipRgn(m_hdc, NULL); DeleteObject(hrgn); } else // do XOR trick for masking (draw image, draw black polygon, draw image again, and the XOR will do an implicit mask op) { SetStretchBltMode(m_hdc, HALFTONE); // somehow enables filtering StretchBlt(m_hdc, ix, iy, ix2 - ix, iy2 - iy, hdcNew, 0, 0, bitmapwidth, bitmapheight, SRCINVERT); SelectObject(m_hdc, GetStockObject(BLACK_BRUSH)); SelectObject(m_hdc, GetStockObject(NULL_PEN)); ::Polygon(m_hdc, rgpt.data(), (int)rgv.size()); SetStretchBltMode(m_hdc, HALFTONE); // somehow enables filtering StretchBlt(m_hdc, ix, iy, ix2 - ix, iy2 - iy, hdcNew, 0, 0, bitmapwidth, bitmapheight, SRCINVERT); } SelectObject(hdcNew, hbmOld); DeleteDC(hdcNew); }
CXTPColorHex::CRgnCell::CRgnCell(CRect& rect, COLORREF color, int u, int d) : m_color(color) { m_iCell[0] = u; m_iCell[1] = d; rect.OffsetRect(XTP_CXSMCELL, 0); m_rect = rect; m_pts[0] = CPoint(rect.left+7, rect.top); m_pts[1] = CPoint(rect.right, rect.top+4); m_pts[2] = CPoint(rect.right, rect.top+12); m_pts[3] = CPoint(rect.left+7, rect.bottom+1); m_pts[4] = CPoint(rect.left, rect.top+12); m_pts[5] = CPoint(rect.left, rect.top+4); VERIFY(CreatePolygonRgn(m_pts, 6, WINDING)); }
static HRGN MakeBalloonRegion(int width,int height,int radius,int AlignStyle, int TailSize,int TailX,int TailY) { POINT Tail[3]; HRGN hrgnRect,hrgnTail; int top,bottom,rad; // attach the tail to the balloon switch (AlignStyle) { case BAA_TOP: top=TailSize; bottom=height; Tail[0].y=Tail[2].y=top; break; case BAA_BOTTOM: top=0; bottom=height-TailSize; Tail[0].y=Tail[2].y=bottom-1; break; } /* switch */ // point tail to left/right, depending on its position rad=(radius+1)/2; // ellipse diameter to radius (round up) Tail[0].x= (TailX>width/2+8) ? TailX-TailSize-4 : TailX+TailSize; if (Tail[0].x>width-rad-TailSize) // clamp base of tail inside the balloon Tail[0].x=width-rad-TailSize; if (Tail[0].x<rad) Tail[0].x=rad; Tail[2].x=Tail[0].x+TailSize; if (Tail[2].x>width-rad) // adjust for very narrow balloons Tail[2].x=width-rad; Tail[1].x=TailX; Tail[1].y=TailY; // create combined region if (radius<=0) hrgnRect=CreateRectRgn(0,top,width,bottom); else hrgnRect=CreateRoundRectRgn(0,top,width,bottom,radius,radius); hrgnTail=CreatePolygonRgn(Tail,3,ALTERNATE); CombineRgn(hrgnRect,hrgnRect,hrgnTail,RGN_OR); DeleteObject(hrgnTail); return hrgnRect; }
static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) { //TODO: use freeimage to create merget icon and add RGB(A) support ICONINFO icoi; BITMAP bm; HICON hIcon=NULL; /* load both icons */ HICON hLowerIcon=(HICON)ServiceLoadFlagIcon((WPARAM)lParam,0); if (hLowerIcon == NULL) return NULL; HICON hUpperIcon=(HICON)ServiceLoadFlagIcon(wParam,0); /* merge them */ if (GetIconInfo(hLowerIcon,&icoi)) { if (hUpperIcon!=NULL && GetObject(icoi.hbmColor,sizeof(bm),&bm)) { HDC hdc=CreateCompatibleDC(NULL); if (hdc!=NULL) { POINT aptTriangle[3]; memset(&aptTriangle, 0, sizeof(aptTriangle)); aptTriangle[1].y=bm.bmHeight-1; aptTriangle[2].x=bm.bmWidth-1; HRGN hrgn=CreatePolygonRgn(aptTriangle,_countof(aptTriangle),WINDING); if (hrgn!=NULL) { SelectClipRgn(hdc,hrgn); HBITMAP hbmPrev=(HBITMAP)SelectObject(hdc,icoi.hbmColor); if (hbmPrev!=NULL) { /* error on select? */ if (DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_IMAGE)) { if (SelectObject(hdc,icoi.hbmMask)!=NULL) /* error on select? */ DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,NULL,DI_NOMIRROR|DI_MASK); } SelectObject(hdc,hbmPrev); } DeleteObject(hrgn); } DeleteDC(hdc); } } /* create icon */ hIcon=CreateIconIndirect(&icoi); DeleteObject(icoi.hbmColor); DeleteObject(icoi.hbmMask); } return (INT_PTR)hIcon; }
//----------------------------------------------------------------------------- // Purpose: // Input : rc - // fillr - // fillg - // fillb - //----------------------------------------------------------------------------- void CDrawHelper::DrawTriangleMarker( RECT& rc, COLORREF fill, bool inverted /*= false*/ ) { POINT region[3]; int cPoints = 3; if ( !inverted ) { region[ 0 ].x = rc.left - m_x; region[ 0 ].y = rc.top - m_y; region[ 1 ].x = rc.right - m_x; region[ 1 ].y = rc.top - m_y; region[ 2 ].x = ( ( rc.left + rc.right ) / 2 ) - m_x; region[ 2 ].y = rc.bottom - m_y; } else { region[ 0 ].x = rc.left - m_x; region[ 0 ].y = rc.bottom - m_y; region[ 1 ].x = rc.right - m_x; region[ 1 ].y = rc.bottom - m_y; region[ 2 ].x = ( ( rc.left + rc.right ) / 2 ) - m_x; region[ 2 ].y = rc.top - m_y; } HRGN rgn = CreatePolygonRgn( region, cPoints, ALTERNATE ); int oldPF = SetPolyFillMode( m_dcMemory, ALTERNATE ); HBRUSH brFace = CreateSolidBrush( fill ); FillRgn( m_dcMemory, rgn, brFace ); DeleteObject( brFace ); SetPolyFillMode( m_dcMemory, oldPF ); DeleteObject( rgn ); }
static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam, LPARAM lParam) { HICON hIcon = nullptr; /* load both icons */ HICON hLowerIcon = (HICON)ServiceLoadFlagIcon((WPARAM)lParam, 0); if (hLowerIcon == nullptr) return 0; HICON hUpperIcon = (HICON)ServiceLoadFlagIcon(wParam, 0); /* merge them */ ICONINFO icoi; if (GetIconInfo(hLowerIcon, &icoi)) { BITMAP bm; if (hUpperIcon != nullptr && GetObject(icoi.hbmColor, sizeof(bm), &bm)) { HDC hdc = CreateCompatibleDC(nullptr); if (hdc != nullptr) { POINT aptTriangle[3] = { 0 }; aptTriangle[1].y = bm.bmHeight - 1; aptTriangle[2].x = bm.bmWidth - 1; HRGN hrgn = CreatePolygonRgn(aptTriangle, _countof(aptTriangle), WINDING); if (hrgn != nullptr) { SelectClipRgn(hdc, hrgn); DeleteObject(hrgn); HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor); if (hbmPrev != nullptr) { /* error on select? */ if (DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_IMAGE)) if (SelectObject(hdc, icoi.hbmMask) != nullptr) /* error on select? */ DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_MASK); SelectObject(hdc, hbmPrev); } } DeleteDC(hdc); } } /* create icon */ hIcon = CreateIconIndirect(&icoi); DeleteObject(icoi.hbmColor); DeleteObject(icoi.hbmMask); } return (INT_PTR)hIcon; }
//--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { //mwin = FindWindow(NULL,"Untitled - Notepad"); mwin = Form1->Handle; //m_reg = CreateRoundRectRgn(0,0,Form1->Width,Form1->Height,50,50); rgndh.dwSize = Form1->Width*Form1->Height; rgndh.iType = RDH_RECTANGLES; rgndh.nCount = 128; rgndh.nRgnSize VertexPoint[0].x = 0; VertexPoint[0].y = 64; VertexPoint[1].x = 64; VertexPoint[1].y = 0; VertexPoint[2].x = Form1->Width; VertexPoint[2].y = 0; VertexPoint[3].x = Form1->Width; VertexPoint[3].y = 26; VertexPoint[4].x = Form1->Width/2; VertexPoint[4].y = Form1->Height; m_reg = CreatePolygonRgn(VertexPoint,5,WINDING); SetWindowRgn(mwin,m_reg,1); }
LPREGION REGION::CombineRegion( HRGN far * pHrgnPrev) { HRGN hrgnDest, hrgnThisOne; switch(m_type) { case I_RECT: I_ASSERT(m_usNumPoints==2); hrgnThisOne = CreateRectRgnIndirect( (LPRECT)m_aPoints); break; case I_ELLIPSE: I_ASSERT(m_usNumPoints==2); hrgnThisOne = CreateEllipticRgnIndirect( (LPRECT)m_aPoints); break; case I_POLYGON: default: hrgnThisOne = CreatePolygonRgn(m_aPoints, m_usNumPoints, WINDING); break; } hrgnDest = CreateRectRgn(0,0,0,0); if (*pHrgnPrev) { I_ASSERT(m_combineMode != I_COMBINE_INITIAL); CombineRgn(hrgnDest, *pHrgnPrev, hrgnThisOne, GetNativeCombineMode()); DeleteObject(*pHrgnPrev); } else CombineRgn(hrgnDest, hrgnThisOne, NULL, RGN_COPY); DeleteObject(hrgnThisOne); *pHrgnPrev = hrgnDest; return (LPREGION) &m_aPoints[m_usNumPoints]; }
void mxExpressionSlider::DrawThumb( int barnum, HDC& dc ) { RECT rcThumb; GetThumbRect( barnum, rcThumb ); // Draw it HPEN oldPen; HPEN shadow; HBRUSH face; HPEN hilight; shadow = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DDKSHADOW ) ); hilight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DHIGHLIGHT ) ); switch ( barnum ) { default: case MAGNITUDE_BAR: if ( m_flCurrent[ barnum ] != m_flMin[ barnum ] ) { // float frac = ( m_flCurrent[ barnum ] - m_flMin[ barnum ] ) / ( m_flMax[ barnum ] - m_flMin[ barnum ] ); float frac; if (m_flCurrent[ barnum ] < 0) { frac = m_flCurrent[ barnum ] / m_flMin[ barnum ]; } else { frac = m_flCurrent[ barnum ] / m_flMax[ barnum ]; } frac = min( 1.0f, frac ); frac = max( 0.0f, frac ); COLORREF clr = GetSysColor( COLOR_3DFACE ); int r, g, b; r = GetRValue( clr ); g = GetRValue( clr ); b = GetRValue( clr ); // boost colors r = (int)( (1-frac) * b ); b = min( 255, (int)(r + ( 255 - r ) * frac ) ); g = (int)( (1-frac) * g ); face = CreateSolidBrush( RGB( r, g, b ) ); } else { face = CreateSolidBrush( GetSysColor( COLOR_3DFACE ) ); } break; case BALANCE_BAR: { float frac = ( m_flCurrent[ barnum ] - m_flMin[ barnum ] ) / ( m_flMax[ barnum ] - m_flMin[ barnum ] ); frac = min( 1.0f, frac ); frac = max( 0.0f, frac ); COLORREF clr = GetSysColor( COLOR_3DFACE ); int r, g, b; r = GetRValue( clr ); g = GetRValue( clr ); b = GetRValue( clr ); // boost colors toward red if we are not at 0.5 float boost = 2.0 * ( fabs( frac - 0.5f ) ); r = r + ( 255 - r ) * boost; g = ( 1 - boost ) * g; b = ( 1 - boost ) * b; face = CreateSolidBrush( RGB( r, g, b ) ); } break; } //rcThumb.left += 1; //rcThumb.right -= 1; //rcThumb.top += 1; //rcThumb.bottom -= 1; //FillRect( dc, &rcThumb, face ); POINT region[3]; int cPoints = 3; InflateRect( &rcThumb, -2, 0 ); // int height = rcThumb.bottom - rcThumb.top; // int offset = height / 2 + 1; int offset = 2; switch ( barnum ) { case MAGNITUDE_BAR: default: { region[ 0 ].x = rcThumb.left; region[ 0 ].y = rcThumb.top; region[ 1 ].x = rcThumb.right; region[ 1 ].y = rcThumb.top; region[ 2 ].x = ( rcThumb.left + rcThumb.right ) / 2; region[ 2 ].y = rcThumb.bottom - offset; } break; case BALANCE_BAR: { region[ 0 ].x = ( rcThumb.left + rcThumb.right ) / 2; region[ 0 ].y = rcThumb.top + offset; region[ 1 ].x = rcThumb.left; region[ 1 ].y = rcThumb.bottom; region[ 2 ].x = rcThumb.right; region[ 2 ].y = rcThumb.bottom; } break; } HRGN rgn = CreatePolygonRgn( region, cPoints, ALTERNATE ); int oldPF = SetPolyFillMode( dc, ALTERNATE ); FillRgn( dc, rgn, face ); SetPolyFillMode( dc, oldPF ); DeleteObject( rgn ); oldPen = (HPEN)SelectObject( dc, hilight ); MoveToEx( dc, region[0].x, region[0].y, NULL ); LineTo( dc, region[1].x, region[1].y ); SelectObject( dc, shadow ); LineTo( dc, region[2].x, region[2].y ); SelectObject( dc, hilight ); LineTo( dc, region[0].x, region[0].y ); SelectObject( dc, oldPen ); DeleteObject( face ); DeleteObject( shadow ); DeleteObject( hilight ); }
void MWcanvas16::clip() { flush(); // ---- make sure there are multiple points ---- PathRenderInfo* p = &path_; POINT* pt = p->point_; int n = (int) (p->cur_point_ - p->point_); if (n <= 2) { return; } // // The path must be in terms of device units for specification of // clipping... so we transform the path specifications from logical // units (TWIPS) to device units before setting the clipping. // if(drawable_ == nil) // sometimes its null because of event input -- just ignore return; MWassert( LPtoDP(drawable_, pt, n) ); // ---- create a region to represent clipping ---- HRGN clip; if (xrect(pt, n)) { // ---- rectangular clipping area ---- RECT xr; xr.left = Math::min(pt[0].x, pt[2].x); xr.top = Math::min(pt[0].y, pt[2].y); xr.right = Math::max(pt[0].x, pt[2].x); xr.bottom = Math::max(pt[0].y, pt[2].y); clip = CreateRectRgn(xr.left, xr.top, xr.right, xr.bottom ); } else { clip = CreatePolygonRgn(pt, n, WINDING); } #if 1 // ---- merge with existing clipping area ---- HRGN intersect = CreateRectRgn(0,0,0,0); CombineRgn(intersect, clipping_, clip, RGN_AND); DeleteObject(clip); clip = intersect; #endif //DebugMessage // ---- set new clipping area ---- SelectClipRgn(drawable_, clip); DeleteObject(clipping_); clipping_ = clip; #ifdef DEBUG // ---- canvas debug ---- printf("clip "); for (int i = 0; i < n; i++) { printf("[%d,%d] ", pt[i].x, pt[i].y); } printf("\n"); #endif }
// 窗口消息处理函数 LRESULT APIENTRY MainWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; switch (message) { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); break; case WM_COMMAND: // 菜单命令 switch (wParam) { case IDM_VANISH: // 消除客户区(在设置了修剪全其输出范围也会被限制) hdc = GetDC(hwnd); GetClientRect(hwnd, &rc); FillRect(hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); DeleteDC( hdc); break; // 根据用户的菜单输入,设置修剪路径的组合模式 case IDM_AND: iMode = RGN_AND; break; case IDM_COPY: iMode = RGN_COPY; break; case IDM_DIFF: iMode = RGN_DIFF; break; case IDM_OR: iMode = RGN_OR; break; case IDM_XOR: iMode = RGN_XOR; break; case IDM_CLIP: { // 获取窗口客户区的DC hdc = GetDC(hwnd); // 创建并为DC选择字体 // 消息在菜单中点击此项前需先选择字体 hfont = CreateFontIndirect(cf.lpLogFont); hfontOld = (HFONT)SelectObject(hdc, hfont); // 五个点,用于创建五角星区域 POINT point[5]= {{0,200},{600,200},{100,600},{300,0},{500,600}}; // 创建多边形区域,五角星 hrgn = CreatePolygonRgn(point, 5, WINDING); // 将区域选择为修剪区域 SelectClipRgn(hdc, hrgn); // 输出的文字 LPSTR szOut = "Lorem ipsum dolor sit amet, consectetur \n" "adipisicing elit, sed do eiusmod tempor \n" "incididunt ut labore et dolore magna \n" "aliqua. Ut enim ad minim veniam, quis \n" "nostrud exercitation ullamco laboris nisi \n" "ut aliquip ex ea commodo consequat. Duis \n" "aute irure dolor in reprehenderit in \n" "voluptate velit esse cillum dolore eu \n" "fugiat nulla pariatur. Excepteur sint \n" "occaecat cupidatat non proident, sunt \n" "in culpa qui officia deserunt mollit \n" "anim id est laborum.\n"; // 窗口客户区,用于输出文字 RECT rect; GetClientRect(hwnd,&rect); // 设置文字背景为透明 SetBkMode(hdc, TRANSPARENT); // 开始创建路径 BeginPath(hdc); // 路径的形状为输出的文字 DrawText(hdc, szOut, lstrlen(szOut),&rect , DT_CENTER); EndPath(hdc);// 路径已经为DC的当前路径 // 为DC选择修剪路径,使用用户通过菜单输入的模式 // 注意在进行此操作前需通过菜单选择组合模式 SelectClipPath(hdc, iMode); // 输出放射状直线,以左上角为原点 // 计算线的终点 for (i = 0; i < 90; i++) { aflSin[i] = sin( (((double)i) / 180.0) * 3.14159); } for (i = 0; i < 90; i++) { aflCos[i] = cos( (((double)i) / 180.0) * 3.14159); } flRadius = 1000;// 线的长度(窗口大小为600*650) // 画线,第一度画一条线 for (i = 0; i < 90; i++) { MoveToEx(hdc, nXStart, nYStart, (LPPOINT) NULL); LineTo(hdc, nXStart + ((int) (flRadius * aflCos[i])), nYStart + ((int) (flRadius * aflSin[i]))); } // 选择回字体,释放 SelectObject(hdc, hfontOld); DeleteObject(hfont); DeleteDC( hdc); // 刷新窗口 UpdateWindow(hwnd); break; } case IDM_FONT: // 用户选择字体 cf.lStructSize = sizeof (CHOOSEFONT); cf.hwndOwner = hwnd; cf.lpLogFont = &lf; cf.Flags = CF_SCREENFONTS | CF_EFFECTS; cf.rgbColors = RGB(0, 255, 255); cf.nFontType = SCREEN_FONTTYPE; ChooseFont(&cf); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
// 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 static POINT Punkty[100]; // tablica klikniêæ static POINT Punkty2[100]; // tablica klikniêæ static int rozmiary[100], regiony[100]; static int lPunktow = 0; static int lPunktow2 = 0; static int i = 50; static int ii=0; static bool leftMouse; static bool rightMouse; static bool negatyw = false; HMENU mGlowne, mPlik, mRozmiar, mKolor, 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"); mRozmiar = CreateMenu(); AppendMenu(mRozmiar, MF_STRING, 103, "&Du¿e"); AppendMenu(mRozmiar, MF_STRING, 104, "&Ma³e"); mKolor = CreateMenu(); AppendMenu(mKolor, MF_STRING, 105, "&Podstawowy"); AppendMenu(mKolor, MF_STRING, 106, "&Negatyw"); mInfo = CreateMenu(); AppendMenu(mInfo, MF_STRING, 102, "&Autor..."); mGlowne = CreateMenu(); AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mPlik, "&Plik"); AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mRozmiar, "&Rozmiar"); AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mKolor, "&Kolor"); AppendMenu(mGlowne, MF_POPUP, (UINT_PTR) mInfo, "&Info"); SetMenu(Okno, mGlowne); DrawMenuBar(Okno); Punkty[lPunktow].x=200; // wype³nienie pierwszej pozycji tablicy klikniêæ Punkty[lPunktow].y=200; lPunktow++; InvalidateRect(Okno, NULL, TRUE); // wymuszenie meldunku WM_PAINT 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: Katarzyna Wolszon\nnumer indeksu: s8133", "Student PJWSTK", MB_OK); break; case 103: ii = 50; break; case 104: ii = 0; break; case 105: negatyw = false; //kolor podstawowy break; case 106: negatyw = true; //negatyw break; } return 0; case WM_LBUTTONDOWN: // obs³uga wciœniêcia lewego przycisku myszki leftMouse=true; rightMouse=false; if(lPunktow >= sizeof(Punkty)/sizeof(POINT)) lPunktow = 0; // przepe³nienie tablicy klikniêæ Punkty[lPunktow].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ Punkty[lPunktow].y = HIWORD(lParam); rozmiary[lPunktow] = ii; //if (negatyw) negatywT[lPunktow] = true; //else negatywT[lPunktow] = false; lPunktow++; InvalidateRect(Okno, NULL, leftMouse); // wymuszenie meldunku WM_PAINT return 0; case WM_RBUTTONDOWN: // obs³uga wciœniêcia prawego przycisku myszki leftMouse=false; rightMouse=true; if(lPunktow2 >= sizeof(Punkty2)/sizeof(POINT)) lPunktow2 = 0; // przepe³nienie tablicy klikniêæ Punkty2[lPunktow2].x = LOWORD(lParam); // zapisanie wspó³rzêdnych kursora w tablicy klikniêæ Punkty2[lPunktow2].y = HIWORD(lParam); lPunktow2++; InvalidateRect(Okno, NULL, rightMouse); // wymuszenie meldunku WM_PAINT return 0; case WM_PAINT: // obs³uga odœwie¿enia okna { PAINTSTRUCT Paint; HDC Kontekst = BeginPaint(Okno, &Paint); char Tekst[] = "Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon Katarzyna Wolszon"; POINT Wielokat1[] = {{100, 100}, {120+i, 100}, {120+i, 150+i/2}, {170+i, 100},{190+i*2, 100}, {120+i, 170+i}, {190+i*2, 280+i}, {170+i, 280+i},{120+i, 200+i+i/2}, {120+i, 280+i}, {100, 280+i}}; POINT Wielokat2[] = {{200+i*2, 100}, {220+i*3, 100}, {220+i*3, 260}, {260+i*3, 240},{320+i*3, 260}, {320+i*3, 100}, {340+i*4, 100}, {340+i*4, 280+i},{320+i*3, 280+i}, {260+i*3, 260+i}, {220+i*3, 280+i}, {200+i*2, 280+i}}; POINT Wielokat1m[] = {{100, 100}, {120, 100}, {120, 150}, {170, 100},{190, 100}, {120, 170}, {190, 280}, {170, 280},{120, 200}, {120, 280}, {100, 280}}; POINT Wielokat2m[] = {{200, 100}, {220, 100}, {220, 260}, {260, 240},{320, 260}, {320, 100}, {340, 100}, {340, 280},{320, 280}, {260, 260}, {220, 280}, {200, 280}}; HBRUSH Pedzel = CreateSolidBrush(RGB(255,0,0)); // czerwony pêdzel HBRUSH Pedzel1 = CreateSolidBrush(RGB(0,0,255)); HBRUSH Pedzel2 = CreateSolidBrush(RGB(0,255,255)); HBRUSH Pedzel3 = CreateSolidBrush(RGB(255,255,0)); HPEN Pioro2 = CreatePen(PS_SOLID, 2, RGB(0,255,255)); HPEN Pioro3 = CreatePen(PS_SOLID, 2, RGB(255,255,0)); SelectObject(Kontekst, GetStockObject(NULL_PEN)); SetBkMode(Kontekst, TRANSPARENT); HRGN Region0 = CreatePolygonRgn(Wielokat1, 11, WINDING); HRGN Region1 = CreatePolygonRgn(Wielokat2, 12, WINDING); HRGN Region2 = CreateRectRgn(0, 0, 0, 0); // pusty region //HRGN Region3 = CreatePolygonRgn(Wielokat1m, 11, WINDING); //HRGN Region4 = CreatePolygonRgn(Wielokat2m, 12, WINDING); //HRGN RegionT = CreateRectRgn(0, 0, 0, 0); // pusty region for(int n=0; n<lPunktow; n++) { OffsetRgn(Region0, Punkty[n].x-200, Punkty[n].y-200); OffsetRgn(Region1, Punkty[n].x-200, Punkty[n].y-200); CombineRgn(Region2, Region1, Region0, RGN_OR); //SelectClipRgn(Kontekst, Region2); //SelectObject(Kontekst, GetStockObject(WHITE_BRUSH)); // standardowy bia³y pêdzel //PaintRgn(Kontekst, Region2); //FrameRgn(Kontekst, Region2, Pedzel, 15, 15); SelectClipRgn(Kontekst, Region0); SelectObject(Kontekst, Pedzel); PaintRgn(Kontekst, Region0); SelectClipRgn(Kontekst, Region1); SelectObject(Kontekst, Pedzel1); PaintRgn(Kontekst, Region1); //CombineRgn(RegionT, RegionT, Region2, RGN_OR); SelectClipRgn(Kontekst, Region2); WORD Odstep = HIWORD(GetDialogBaseUnits()); for(int y = 0; y < 850; y = y+Odstep) TextOut(Kontekst, 0, y, Tekst, strlen(Tekst)); OffsetRgn(Region0, -Punkty[n].x+200, -Punkty[n].y+200); OffsetRgn(Region1, -Punkty[n].x+200, -Punkty[n].y+200); } for(int j=0; j<lPunktow2; j++){ SetViewportOrgEx(Kontekst,Punkty2[j].x-500,Punkty2[j].y-400,NULL); SelectObject(Kontekst, Pioro2); Polygon(Kontekst, Wielokat1m, 11); SelectObject(Kontekst, Pioro3); Polygon(Kontekst, Wielokat2m, 12); } DeleteObject(Pedzel); DeleteObject(Pedzel1); DeleteObject(Pedzel2); DeleteObject(Pedzel3); DeleteObject(Pioro2); DeleteObject(Pioro3); 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); } }
HRESULT CRTCAVSession::ShowVideo(RTC_VIDEO_DEVICE enDevice, BOOL fShow) { IVideoWindow * pVid = NULL; IRTCClient * pClient = NULL; long lMediaCaps = 0; HWND hWnd = NULL; HRESULT hr; hr = m_pSession->get_Client(&pClient); if (FAILED(hr)) { // get_Client failed return hr; } // Get the media capabilities hr = pClient->get_MediaCapabilities(&lMediaCaps); if (FAILED(hr)) { // get_MediaCapabilities failed SAFE_RELEASE(pClient); return hr; } hr = pClient->get_IVideoWindow( enDevice, &pVid); SAFE_RELEASE(pClient); if (FAILED(hr)) { // get_IVideoWindow failed return hr; } if (enDevice == RTCVD_PREVIEW) { // Determine whether to show the preview video fShow = fShow && (lMediaCaps & RTCMT_VIDEO_SEND); m_fShowPrev = fShow; hWnd = m_hPrevVideoParent; // Show or hide the preview video preview parent window ShowWindow(m_hPrevVideoParent, fShow ? SW_SHOW : SW_HIDE); // Set window region for receive video parent window HRGN hRegion; if (fShow) { // Set the receive video region to make room for the preview // video picture-in-picture POINT rgPoints[6] = { 0, 0, 0, m_lRecvHeight, m_lRecvWidth - m_lPrevWidth, m_lRecvHeight, m_lRecvWidth - m_lPrevWidth, m_lRecvHeight - m_lPrevHeight, m_lRecvWidth, m_lRecvHeight - m_lPrevHeight, m_lRecvWidth, 0 }; hRegion = CreatePolygonRgn(rgPoints, 6, ALTERNATE); } else { // Set the receive video region to be rectangular hRegion = CreateRectRgn(0, 0, m_lRecvWidth, m_lRecvHeight); } SetWindowRgn(m_hRecvVideoParent, hRegion, TRUE); } else { // Determine whether to show the receive video fShow = fShow && (lMediaCaps & RTCMT_VIDEO_RECEIVE); m_fShowRecv = fShow; hWnd = m_hRecvVideoParent; // Always show the video receive parent window ShowWindow(m_hRecvVideoParent, SW_SHOW); } if ( fShow == TRUE ) { // Set the video window style pVid->put_WindowStyle( WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS ); // Set the parent window for the video window pVid->put_Owner( (OAHWND)hWnd ); RECT rc; GetClientRect(hWnd, &rc ); // Position the video window pVid->SetWindowPosition( rc.left, rc.top, rc.right, rc.bottom ); // Make the video window visible pVid->put_Visible(-1); } SAFE_RELEASE(pVid); return S_OK; }
BOOL Game_Init(HWND hwnd) { srand((unsigned)time(NULL)); //用系统时间初始化随机种子 HBITMAP bmp; g_hdc = GetDC(hwnd); g_mdc = CreateCompatibleDC(g_hdc); //创建一个和hdc兼容的内存DC g_bufdc = CreateCompatibleDC(g_hdc);//再创建一个和hdc兼容的缓冲DC bmp = CreateCompatibleBitmap(g_hdc, WINDOW_WIDTH, WINDOW_HEIGHT); //建一个和窗口兼容的空的位图对象 SelectObject(g_mdc, bmp);//将空位图对象放到mdc中 wchar_t filename[20]; //五叶站立 for (int i = 0; i<4; i++) { memset(filename, 0, sizeof(filename)); //filename的初始化 swprintf_s(filename, L"wy\\%d.bmp", i); //调用swprintf_s函数,“组装”出对应的图片文件名称 g_hWyStand[i] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //五叶移动 for (int i = 0; i < 8; i++){ memset(filename, 0, sizeof(filename)); swprintf_s(filename, L"wy\\wyyd\\wyyda%d.bmp", i); g_hWyMove[i] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //时间 for (int i = 0; i < 9; i++){ memset(filename, 0, sizeof(filename)); swprintf_s(filename, L"time\\5\\%d.bmp", i + 1); g_hTime[i] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //闪电技能 /*g_hMagic*/ for (int i = 0; i < 54; i++){ memset(filename, 0, sizeof(filename)); swprintf_s(filename, L"magic\\%d.bmp", i + 1); g_hMagic[i] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //小技能 //g_hXjn for (int i = 0; i < 34; i++){ memset(filename, 0, sizeof(filename)); swprintf_s(filename, L"xjn\\%d.bmp", i + 1); g_hXjn[i] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //载入一系列游戏资源图到位图句柄中 g_hGameOver = (HBITMAP)LoadImage(NULL, L"GameMedia\\gameover.bmp", IMAGE_BITMAP, 1086, 396, LR_LOADFROMFILE); //游戏结束位图 g_hVictory = (HBITMAP)LoadImage(NULL, L"GameMedia\\victory.bmp", IMAGE_BITMAP, 800, 600, LR_LOADFROMFILE); //游戏胜利位图 g_hBackGround = (HBITMAP)LoadImage(NULL, L"bg_al.bmp", IMAGE_BITMAP, 800, 600, LR_LOADFROMFILE); //背景位图 g_hMonsterBitmap = (HBITMAP)LoadImage(NULL, L"nw9.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //怪物角色位图 g_hHeroBitmap = (HBITMAP)LoadImage(NULL, L"nr.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //英雄角色位图 g_hHeroSkill1 = (HBITMAP)LoadImage(NULL, L"GameMedia\\heroslash.bmp", IMAGE_BITMAP, 364, 140, LR_LOADFROMFILE); //英雄1技能位图 g_hHeroSkill2 = (HBITMAP)LoadImage(NULL, L"GameMedia\\heromagic.bmp", IMAGE_BITMAP, 374, 288, LR_LOADFROMFILE); //英雄2技能位图 g_hHeroSkill3 = (HBITMAP)LoadImage(NULL, L"GameMedia\\herocritical.bmp", IMAGE_BITMAP, 574, 306, LR_LOADFROMFILE); //英雄3技能位图 g_hSkillButton1 = (HBITMAP)LoadImage(NULL, L"jnl.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //g_hSkillButton1 = (HBITMAP)LoadImage(NULL,L"GameMedia\\skillbutton1.bmp",IMAGE_BITMAP,50,50,LR_LOADFROMFILE); //技能1图标位图 //g_hSkillButton2= (HBITMAP)LoadImage(NULL,L"GameMedia\\skillbutton2.bmp",IMAGE_BITMAP,50,50,LR_LOADFROMFILE); //技能2图标位图 //g_hSkillButton3= (HBITMAP)LoadImage(NULL,L"GameMedia\\skillbutton3.bmp",IMAGE_BITMAP,50,50,LR_LOADFROMFILE); //技能3图标位图 g_hcw = (HBITMAP)LoadImage(NULL, L"cw_tx.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //技能4图标位图 g_hrw = (HBITMAP)LoadImage(NULL, L"rw_tx.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hBossSkill1 = (HBITMAP)LoadImage(NULL, L"GameMedia\\monsterslash.bmp", IMAGE_BITMAP, 234, 188, LR_LOADFROMFILE); //怪物1技能位图 g_hBossSkill2 = (HBITMAP)LoadImage(NULL, L"GameMedia\\monstermagic.bmp", IMAGE_BITMAP, 387, 254, LR_LOADFROMFILE); //怪物2技能位图 g_hBossSkill3 = (HBITMAP)LoadImage(NULL, L"GameMedia\\monstercritical.bmp", IMAGE_BITMAP, 574, 306, LR_LOADFROMFILE); //怪物3技能位图 g_hSnow = (HBITMAP)LoadImage(NULL, L"GameMedia\\snow.bmp", IMAGE_BITMAP, 20, 20, LR_LOADFROMFILE); //雪花位图 g_hRecoverSkill = (HBITMAP)LoadImage(NULL, L"GameMedia\\recover.bmp", IMAGE_BITMAP, 150, 150, LR_LOADFROMFILE); //恢复技能位图 g_hSprite[0] = (HBITMAP)LoadImage(NULL, L"nr_mv.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hSprite[1] = (HBITMAP)LoadImage(NULL, L"nr_st1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hBackGround_mv = (HBITMAP)LoadImage(NULL, L"bg1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hBackGround_mvzd = (HBITMAP)LoadImage(NULL, L"zd8.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hxbk = (HBITMAP)LoadImage(NULL, L"xbk.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); g_hxbk2 = (HBITMAP)LoadImage(NULL, L"xbk3.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); for (int k = 0; k < 19; k++){ memset(filename, 0, sizeof(filename)); //filename的初始化 swprintf_s(filename, L"wy\\fight\\%d.bmp", k); //调用swprintf_s函数,“组装”出对应的图片文件名称 g_hWySkill[k] = (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); } //g_hWySkill = (HBITMAP)LoadImage(NULL, L"wy\\xbk2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); GetClientRect(hwnd, &g_rect); //取得内部窗口区域的大小 Hero.NowHp = Hero.MaxHp = 500; //设定玩家生命值的当前值及上限 Hero.Level = 6; //设定玩家角色等级 Hero.NowMp = Hero.MaxMp = 60; //玩家魔法值的当前值及上限 Hero.Strength = 10; //设定英雄的力量值 Hero.Agility = 20; //设定英雄的敏捷值 Hero.Intelligence = 10; //设定英雄的智力值 Hero.x = 580; Hero.y = 269; Boss.NowHp = Boss.MaxHp = 500; //设定BOSS生命值的当前值及上限 Boss.Level = 10; //设定BOSS的等级 Boss.Strength = 10; //设定BOSS的力量值 Boss.Agility = 10; //设定BOSS的敏捷值 Boss.Intelligence = 10; //设定BOSS的智力值 Boss.x = 125; Boss.y = 100; Boss_wy.NowHp = Boss_wy.MaxHp = 500; //设定BOSS生命值的当前值及上限 Boss_wy.Level = 10; //设定BOSS的等级 Boss_wy.Strength = 10; //设定BOSS的力量值 Boss_wy.Agility = 10; //设定BOSS的敏捷值 Boss_wy.Intelligence = 10; //设定BOSS的智力值 Boss_wy.x = 140; Boss_wy.y = 140; g_iTxtNum = 0; //初始化显示消息数目 //HFONT hFont; hFont = CreateFont(20, 0, 0, 0, 700, 0, 0, 0, GB2312_CHARSET, 0, 0, 0, 0, TEXT("微软雅黑")); SelectObject(g_mdc, hFont); SetBkMode(g_mdc, TRANSPARENT); //设置文字显示背景透明 //g_iX = pt_canavailable[0].x; //g_iY = pt_canavailable[0].y; g_iX = 1587; g_iY = 950; g_iDirection = 3; g_iNum_mv = 0; canavailable = CreatePolygonRgn(pt_canavailable, 6, WINDING); cannotavailable1 = CreatePolygonRgn(pt_cannotavailable1, 4, WINDING); cannotavailable2 = CreatePolygonRgn(pt_cannotavailable2, 4, WINDING); cannotavailable3 = CreatePolygonRgn(pt_cannotavailable3, 4, WINDING); SetTimer(hwnd, 1, 200, NULL); if (nowscen == 1) Game_Fight(hwnd); //调用一次游戏Main函数 else Game_Paint(hwnd); return TRUE; }