当前位置: 首页>>代码示例>>C++>>正文


C++ SetCursor函数代码示例

本文整理汇总了C++中SetCursor函数的典型用法代码示例。如果您正苦于以下问题:C++ SetCursor函数的具体用法?C++ SetCursor怎么用?C++ SetCursor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetCursor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetWindowRect

//鼠标消息
VOID CSkinSplitter::OnMouseMove(UINT nFlags, CPoint Point)
{
	__super::OnMouseMove(nFlags,Point);

	if (m_bMouseDown==true)
	{
		//获取位置
		CRect rcWindow;
		GetWindowRect(&rcWindow);

		//效验位置
		CPoint PointParent=Point;
		MapWindowPoints(GetParent(),&PointParent,1);

		//控件位置
		CSize SizeControl;
		SizeControl.SetSize(rcWindow.Width(),rcWindow.Height());

		//设置光标
		if (m_SplitterType==SplitterType_Hor)
		{
			if ((PointParent.y>(m_nMaxDragPos-SizeControl.cy/2))||(PointParent.y<(m_nMinDragPos+SizeControl.cy/2)))
			{
				//设置光标
				SetCursor(LoadCursor(NULL,IDC_NO));

				//设置位置
				PointParent.y=__min(m_nMaxDragPos-SizeControl.cy/2,PointParent.y);
				PointParent.y=__max(m_nMinDragPos+SizeControl.cy/2,PointParent.y);
			}
			else SetCursor(LoadCursor(NULL,IDC_SIZENS));
		}
		else
		{
			if ((PointParent.x>(m_nMaxDragPos-SizeControl.cx/2))||(PointParent.x<(m_nMinDragPos+SizeControl.cx/2)))
			{
				//设置光标
				SetCursor(LoadCursor(NULL,IDC_NO));

				//设置位置
				PointParent.x=__min(m_nMaxDragPos-SizeControl.cx/2,PointParent.x);
				PointParent.x=__max(m_nMinDragPos+SizeControl.cx/2,PointParent.x);
			}
			else SetCursor(LoadCursor(NULL,IDC_SIZEWE));
		}

		//转换位置
		CPoint PointScreen=PointParent;
		GetParent()->ClientToScreen(&PointScreen);
		
		//计算区域
		CRect rcCurrentDraw=m_rcDrawLine;
		if (m_SplitterType==SplitterType_Hor)
		{
			rcCurrentDraw.top=PointScreen.y-SizeControl.cy/2;
			rcCurrentDraw.bottom=rcCurrentDraw.top+SizeControl.cy;
		}
		else
		{
			rcCurrentDraw.left=PointScreen.x-SizeControl.cx/2;
			rcCurrentDraw.right=rcCurrentDraw.left+SizeControl.cx;
		}
		
		//绘画线条
		if (rcCurrentDraw!=m_rcDrawLine)
		{
			//设置 DC
			CDC * pDC=CDC::FromHandle(::GetDC(NULL));
			pDC->SelectObject(CDC::GetHalftoneBrush());

			//绘画拆分
			pDC->PatBlt(m_rcDrawLine.left,m_rcDrawLine.top,m_rcDrawLine.Width(),m_rcDrawLine.Height(),PATINVERT);
			pDC->PatBlt(rcCurrentDraw.left,rcCurrentDraw.top,rcCurrentDraw.Width(),rcCurrentDraw.Height(),PATINVERT);

			//释放资源
			::ReleaseDC(NULL,pDC->m_hDC);

			//设置变量
			m_rcDrawLine=rcCurrentDraw;
		}
	}

	return;
}
开发者ID:Michael-Z,项目名称:qipai-game,代码行数:85,代码来源:SkinSplitter.cpp

示例2: PGrid_OnLButtonDown

BOOL CALLBACK PGrid_OnLButtonDown(HELE hEle,UINT flags,POINT *pPt)
{
	propertyGrid_ *pObj=(propertyGrid_*)hEle;

	if(pPt->x<pObj->spacePoint &&  pPt->x>(pObj->spacePoint-5))
	{
		pObj->bDown=TRUE;
		XEle_SetCapture(hEle);
		SetCursor(LoadCursor(NULL,IDC_SIZEWE));
		return FALSE;
	}
	RECT rcView;
	XSView_GetViewRect(hEle,&rcView);
	if(FALSE==PtInRect(&rcView,*pPt))
		return FALSE;

	POINT pt=*pPt;
	pt.y-=XSView_GetVViewPos(hEle);

	int left=XSView_GetSpacingLeft(hEle)-XSView_GetHViewPos(hEle);

	PGridNode_ *pNode=pObj->pItemList;
	while(pNode)
	{
		if(1==pNode->type)  //组
		{
			PGridGroup_ *pGroup=(PGridGroup_*)pNode->pItem;
			RECT rcBtn={left+pObj->indentBtn,pGroup->posy+pObj->itemHeight/2-5,
				left+pObj->indentBtn+9,pGroup->posy+(pObj->itemHeight/2)+4};
			if(PtInRect(&rcBtn,pt))
			{
				if(pGroup->bExpand)
				{
					pGroup->bExpand=FALSE;
				}else
				{
					pGroup->bExpand=TRUE;
				}
				if(-1!=pObj->selId)
				{
					int oldSel=pObj->selId;
					PGrid_HideEle(hEle);
					//	PGrid_CheckValueChange(hEle,PGrid_GetItem(hEle,oldSel));
					pObj->selId=-1;
					Ele_SendEvent(hEle,XE_PGRID_SELCHANGE,oldSel,pObj->selId);
				}
				PGrid_Adjust(hEle);
				XEle_RedrawEle(hEle);
				return FALSE;
			}else
			{
				if(pGroup->bExpand)
				{
					//子项
					PGridItem_ *pItem=pGroup->pItemList;
					while(pItem)
					{
						if(PGrid_LButtonDownItem(hEle,pItem,&pt))
							return FALSE;
						pItem=pItem->pNext;
					}
				}
			}
		}else //项
		{
			if(PGrid_LButtonDownItem(hEle,(PGridItem_*)pNode->pItem,&pt))
				return FALSE;
		}
		pNode=pNode->pNext;
	}

	//点击在空白处
	if(-1!=pObj->selId)
	{
		int oldSel=pObj->selId;
		PGrid_HideEle(hEle);
		//	PGrid_CheckValueChange(hEle,PGrid_GetItem(hEle,oldSel));
		pObj->selId=-1;
		Ele_SendEvent(hEle,XE_PGRID_SELCHANGE,oldSel,pObj->selId);

	}
	XEle_RedrawEle(hEle);

	return FALSE;
}
开发者ID:BraveStone,项目名称:xcgui,代码行数:85,代码来源:propertyGrid.cpp

示例3: switch

INT_PTR TlevelsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
    case WM_DESTROY:
        SelectObject(hdcGradient, oldHDCgradient);
        DeleteDC(hdcGradient);
        DeleteBitmap(bmpGradient);
        DeleteFont(fontGradient);
        SendMessage(GetDlgItem(m_hwnd, IDC_LBX_LEVELS_CURVES), WM_SETFONT, NULL, FALSE);
        DeleteFont(fontCurier);
        break;
    case WM_DRAWITEM:
        switch (wParam) {
        case IDC_BMP_HISTOGRAM: {
            LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam);
            int full = cfgGet(IDFF_levelsFullY);
            StretchDIBits(dis->hDC, 0, 0, dis->rcItem.right, dis->rcItem.bottom, full ? 0 : 16, 0, full ? 256 : 234 - 16 + 1, 64, histogramBits, (BITMAPINFO*)&histogramBmp, DIB_RGB_COLORS, SRCCOPY);
            wIn->draw(dis);
            return TRUE;
        }
        case IDC_BMP_LEVELS_IN: {
            LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam);
            StretchBlt(dis->hDC, 0, 0, dis->rcItem.right, 10, hdcGradient, 0, 0, 256, 1, SRCCOPY);
            RECT r = dis->rcItem;
            r.top = 10;
            FillRect(dis->hDC, &r, GetSysColorBrush(COLOR_BTNFACE));
            if (filter && getCheck(IDC_CHB_LEVELS_INPUT_AUTO)) {
                int min, max;
                filter->getInAuto(&min, &max);
                drawTriangle(dis, min, true);
                drawTriangle(dis, max, true);
            }
            drawTriangle(dis, cfgGet(IDFF_levelsInMin));
            drawTriangle(dis, cfgGet(IDFF_levelsInMax));
            return TRUE;
        }
        case IDC_BMP_LEVELS_OUT: {
            LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam);
            StretchBlt(dis->hDC, 0, 0, dis->rcItem.right, 10, hdcGradient, 0, 0, 256, 1, SRCCOPY);
            RECT r = dis->rcItem;
            r.top = 10;
            FillRect(dis->hDC, &r, GetSysColorBrush(COLOR_BTNFACE));
            drawTriangle(dis, cfgGet(IDFF_levelsOutMin));
            drawTriangle(dis, cfgGet(IDFF_levelsOutMax));
            return TRUE;
        }
        case IDC_BMP_LEVELS_CURVES: {
            LPDRAWITEMSTRUCT dis = LPDRAWITEMSTRUCT(lParam);
            StretchDIBits(dis->hDC, 0, 0, dis->rcItem.right, dis->rcItem.bottom, 0, 0, 256, 256, histogramBits, (BITMAPINFO*)&curvesBmp, DIB_RGB_COLORS, SRCCOPY);
            wCurves->draw(dis);
            return TRUE;
        }
        }
        break;
    case WM_SETCURSOR:
        if (HWND(wParam) == hcurves) {
            if (wCurves->setCursor()) {
                SetCursor(LoadCursor(NULL, IDC_SIZEALL));
                setDlgResult(TRUE);
            }
            return TRUE;
        }
        break;
    }
    return TconfPageDecVideo::msgProc(uMsg, wParam, lParam);
}
开发者ID:xinjiguaike,项目名称:ffdshow,代码行数:66,代码来源:Clevels.cpp

示例4: winproc

LRESULT CALLBACK winproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
 
  switch (uMsg) {
  case WM_DESTROY:    
    PostQuitMessage(0);
    break;
  case WM_CREATE:
    break;

#ifdef OO_FULLSCREEN
  case WM_SETCURSOR: {
	  SetCursor(NULL);
  } break;
#endif

  case WM_PAINT: {
	//PAINTSTRUCT PtStr;
    //windata.desthDC = BeginPaint(hWnd,&PtStr);
    //render(&windata);
    //EndPaint(hWnd,&PtStr);
  }
    break;

	case WM_ACTIVATE:
		if(  wParam==WA_INACTIVE ) {
			windata.activeWindow = oofalse;
		}
		else {
			windata.activeWindow = ootrue;
		}
		break;

 case WM_ERASEBKGND:
	 return (LRESULT)1; // this is needed to reduce flickering

  case WM_SYSKEYDOWN:
  case WM_SYSKEYUP:
  case WM_KEYDOWN:
  case WM_KEYUP: {
	  unsigned int keyCode = (unsigned int)wParam;
	  oobool keyIsDown = ((lParam & (1 << 31)) == 0);
	  oobool keyWasDown = ((lParam & (1 << 30)) != 0);


	  if( keyCode==VK_ESCAPE && keyIsDown ) {
		  windata.running = oofalse;
	  }

	  if( keyIsDown!=keyWasDown ) {
		  if( keyCode>=0 && keyCode<OOGameInput_Keys_Max ) {
			  windata.gameinput.keyboard[keyCode] = keyIsDown;
		  }
	  }
  } break;

  default:
    return DefWindowProc (hWnd, uMsg, wParam, lParam);
    break;
  }
  return 0;
}
开发者ID:ali-motisi,项目名称:CerealBox,代码行数:61,代码来源:win32main.c

示例5: WndProc

LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
     static HRGN hRgnClip ;
     static int  cxClient, cyClient ;
     double      fAngle, fRadius ;
     HCURSOR     hCursor ;
     HDC         hdc ;
     HRGN        hRgnTemp[6] ; // HRGN just like RECT is a self-defined area.
     int         i ;
     PAINTSTRUCT ps ;
     
     switch (iMsg)
     {
     // The task of WM_SIZE case is used to create a self-defined region as valid client area. 
     case WM_SIZE:
          cxClient = LOWORD (lParam) ;
          cyClient = HIWORD (lParam) ;

          hCursor = SetCursor (LoadCursor (NULL, IDC_WAIT)) ;
          ShowCursor (TRUE) ;
          
          if (hRgnClip)
               DeleteObject (hRgnClip) ; // delete old region before create a new one.
          
          // The apis below are used to create RGN just like RECT
          // other apis including CreateRoundRectRgn & CreatePolygonRgn etc..
          // These apis will create region and be ready to be selected, after that the valid client area
          // will be changed to the region created instead of tranditional rect area.
          hRgnTemp[0] = CreateEllipticRgn (0, cyClient / 3,
                                           cxClient / 2, 2 * cyClient / 3) ;
          hRgnTemp[1] = CreateEllipticRgn (cxClient / 2, cyClient / 3,
                                           cxClient, 2 * cyClient / 3) ;
          hRgnTemp[2] = CreateEllipticRgn (cxClient / 3, 0,
                                           2 * cxClient / 3, cyClient / 2) ;
          hRgnTemp[3] = CreateEllipticRgn (cxClient / 3, cyClient / 2,
                                           2 * cxClient / 3, cyClient) ;
          hRgnTemp[4] = CreateRectRgn (0, 0, 1, 1) ;
          hRgnTemp[5] = CreateRectRgn (0, 0, 1, 1) ;
          hRgnClip    = CreateRectRgn (0, 0, 1, 1) ;

          // combie region from the second and the third regions to the first region with the fourth style.
          // and the first region should be initialized with a small region.
          // RGN_AND: inter sect
          // RGN_OR: srcRgn1 || srcRgn2
          // RGN_XOR: !RGN_AND
          // RGN_DIFF: the part belong to srcRgn1 but not belong to srcRgn2
          // RGN_COPY: srcRgn1 and ignore srcRgn2 totally.
          // Return value: NULLREGION; SIMPLEREGION; COMPLEXREGION; ERROR
          CombineRgn (hRgnTemp[4], hRgnTemp[0], hRgnTemp[1], RGN_OR) ;
          CombineRgn (hRgnTemp[5], hRgnTemp[2], hRgnTemp[3], RGN_OR) ;
          CombineRgn (hRgnClip,    hRgnTemp[4], hRgnTemp[5], RGN_XOR) ;
          
          for (i = 0 ; i < 6 ; i++)
               DeleteObject (hRgnTemp[i]) ;
          
          SetCursor (hCursor) ;
          ShowCursor (FALSE) ;
          return 0 ;
          
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          
          // draw on region api
          // FillRgn, FrameRgn, InvertRgn, PaintRgn like FillRect, FrameRect ... etc.
          HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0));
          FillRgn(hdc, hRgnClip, hBrush);
          DeleteObject(hBrush);
          
          // set the center position as the origin.
          SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
          
          // select self-defined region as valid client area.
          // so the painting will only happen in self-defined region.
          SelectClipRgn (hdc, hRgnClip) ; // equals to SelectObject(hdc, hRgnClip);
          
          // Use InvalidateRgn and ValidRgn instead of InvalidRect and ValidRect.
          
          fRadius = _hypot (cxClient / 2.0, cyClient / 2.0) ;
          
          for (fAngle = 0.0 ; fAngle < TWO_PI ; fAngle += TWO_PI / 360)
          {
               MoveToEx (hdc, 0, 0, NULL) ;
               LineTo (hdc, (int) ( fRadius * cos (fAngle) + 0.5),
                            (int) (-fRadius * sin (fAngle) + 0.5)) ;
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          DeleteObject (hRgnClip) ; // destroy region
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:95,代码来源:Clover.c

示例6: GROUP_GroupWndProc


//.........这里部分代码省略.........
                    break;
                }

                case LVN_BEGINDRAG:
                {
                    POINT ptMin;

                    BOOL bFirst = TRUE;
                    for (iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
                         iItem != -1;
                         iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, iItem, LVNI_SELECTED))
                    {
                        if (bFirst)
                        {
                            group->hDragImageList = (HIMAGELIST)SendMessageA(group->hListView,
                                                                             LVM_CREATEDRAGIMAGE,
                                                                             iItem,
                                                                             (LPARAM)&pt);
                            ptMin  = pt;
                            bFirst = FALSE;
                        }
                        else
                        {
                            HIMAGELIST hOneImageList, hTempImageList;

                            hOneImageList = (HIMAGELIST)SendMessageA(group->hListView,
                                                                     LVM_CREATEDRAGIMAGE,
                                                                     iItem,
                                                                     (LPARAM)&pt);
                            hTempImageList = ImageList_Merge(group->hDragImageList,
                                                             0,
                                                             hOneImageList,
                                                             0,
                                                             pt.x - ptMin.x,
                                                             pt.y - ptMin.y);
                            ImageList_Destroy(group->hDragImageList);
                            ImageList_Destroy(hOneImageList);
                            group->hDragImageList = hTempImageList;
                            ptMin.x = min(ptMin.x, pt.x);
                            ptMin.y = min(ptMin.y, pt.y);
                        }
                    }
                    // pt = ((LPNMLISTVIEW)lParam)->ptAction;
                    pt.x = ((LPNMLISTVIEW)lParam)->ptAction.x;
                    pt.y = ((LPNMLISTVIEW)lParam)->ptAction.y;
                    group->ptStart = pt;
                    pt.x -= ptMin.x;
                    pt.y -= ptMin.y;
                    ImageList_BeginDrag(group->hDragImageList, 0, pt.x, pt.y);
                    MapWindowPoints(group->hListView, Globals.hMDIWnd, &pt, 1);
                    ImageList_DragEnter(Globals.hMDIWnd, pt.x, pt.y);
                    group->bDragging = TRUE;
                    group->hOldCursor = GetCursor();
                    SetCapture(group->hWnd);

                    break;
                }
            }
            break;

        case WM_MOUSEMOVE:
            if (group->bDragging)
            {
                pt.x = GET_X_LPARAM(lParam);
                pt.y = GET_Y_LPARAM(lParam);
                MapWindowPoints(group->hWnd, Globals.hMDIWnd, &pt, 1);
                ImageList_DragMove(pt.x, pt.y);
            }
            break;

        case WM_LBUTTONUP:
            if (group->bDragging)
            {
                // LVHITTESTINFO lvhti;
                POINT ptHit;

                group->bDragging = FALSE;
                ImageList_DragLeave(Globals.hMDIWnd);
                ImageList_EndDrag();
                ImageList_Destroy(group->hDragImageList);
                ReleaseCapture();
                SetCursor(group->hOldCursor);
                ptHit.x = GET_X_LPARAM(lParam);
                ptHit.y = GET_Y_LPARAM(lParam);
                MapWindowPoints(group->hWnd, group->hListView, &ptHit, 1);
                for (iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
                     iItem != -1;
                     iItem = SendMessageA(group->hListView, LVM_GETNEXTITEM, iItem, LVNI_SELECTED))
                {
                    SendMessageA(group->hListView, LVM_GETITEMPOSITION, iItem, (LPARAM)&pt);
                    pt.x += ptHit.x - group->ptStart.x;
                    pt.y += ptHit.y - group->ptStart.y;
                    SendMessageA(group->hListView, LVM_SETITEMPOSITION, iItem, MAKELPARAM(pt.x, pt.y));
                }
            }
            break;
    }

    return DefMDIChildProcW(hWnd, uMsg, wParam, lParam);
}
开发者ID:Moteesh,项目名称:reactos,代码行数:101,代码来源:group.c

示例7: WindowToWorkspace

/*
================
rvGEWorkspace::HandleMouseMove

Handles the moving of the mouse for dragging and cursor updating
================
*/
int	rvGEWorkspace::HandleMouseMove ( WPARAM wParam, LPARAM lParam )
{
	idVec2	cursor;
	
	cursor.Set ( (short)LOWORD(lParam), (short)HIWORD(lParam) );

	// Convert the window point to the workspace before updating the 
	// cursor with the position
	WindowToWorkspace ( cursor );

	// Scrolling the window around
	if ( mDragScroll )
	{
		Scroll ( SB_HORZ, mDragPoint.x - cursor.x );
		Scroll ( SB_VERT, mDragPoint.y - cursor.y );
		
		SetCursor ( mHandCursor );
		
		mDragPoint = cursor;
		
		return 0;
	}			

	// If not dragging then just update the cursor and return
	if ( mDragType == rvGESelectionMgr::HT_NONE )
	{
		UpdateCursor ( cursor.x, cursor.y );
		return 0;
	}

	// Dont allow a drag move start until the button has been down for 100 ms or so
	if ( mDragType == rvGESelectionMgr::HT_MOVE && Sys_Milliseconds() - mDragTime <= 50 )
	{
		return 0;
	}

	// Handle grid snapping
	if ( gApp.GetOptions().GetGridSnap ( ) )
	{
		cursor.x = (float)(((int)cursor.x + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth());
		cursor.y = (float)(((int)cursor.y + gApp.GetOptions().GetGridWidth()/2) / gApp.GetOptions().GetGridWidth() * gApp.GetOptions().GetGridWidth());
	}
	
	// If the cursor hasnt moved then there is nothing to update with the drag
	if ( (int) cursor.x == (int) mDragPoint.x && (int) cursor.y == (int) mDragPoint.y )
	{
		return 0;
	}
	
	switch ( mDragType )
	{		
		case rvGESelectionMgr::HT_MOVE:
			AddModifierMove ( "Move", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
			break;
			
		case rvGESelectionMgr::HT_SIZE_BOTTOM:
			AddModifierSize ( "Size", 0, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_TOP:
			AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_RIGHT:
			AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_LEFT:
			AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_TOPLEFT:
			AddModifierSize ( "Size", cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, 0, 0, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_TOPRIGHT:
			AddModifierSize ( "Size", 0, cursor.y - mDragPoint.y, cursor.x - mDragPoint.x, 0, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT:
			AddModifierSize ( "Size", cursor.x - mDragPoint.x, 0, 0, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
			break;

		case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT:
			AddModifierSize ( "Size", 0, 0, cursor.x - mDragPoint.x, cursor.y - mDragPoint.y, mApplication->GetOptions().GetGridSnap ( ) );
			break;
	}

	UpdateCursor ( mDragType );

	// If the x coordinate has changed then update it
	if ( (int)cursor.x != (int)mDragPoint.x && mDragX )
	{
//.........这里部分代码省略.........
开发者ID:galek,项目名称:fhDOOM,代码行数:101,代码来源:GEWorkspace.cpp

示例8: wxFileDialog

void MyFrame::OnLoadLinearModes(wxCommandEvent& event)
{
  wxFileDialog *dlg = new wxFileDialog(this, _T("Load linear modes"), uiState.currentWorkingDirectory, _T(""), _T("Modal Matrix Files(*.Ulin)|*.Ulin|Modal Matrix Files(*.U)|*.U|All files(*.*)|*.*"), wxFD_OPEN /*| wxHIDE_READONLY*/, wxDefaultPosition);

  if ( dlg->ShowModal() == wxID_OK )
  {
    wxString linearModesFilename( dlg->GetPath());
    SaveCurrentWorkingDirectory(linearModesFilename);
    if( !linearModesFilename.empty() )
    {
      int newr;
      double * newLinearModes = NULL;

      int n1;
      SetCursor(*wxHOURGLASS_CURSOR);
      const char * filename = linearModesFilename.mb_str();
      int code = ReadMatrixFromDisk((char*)filename, &n1, &newr, &newLinearModes);
      SetCursor(*wxSTANDARD_CURSOR);

      if (code != 0)
      {
        this->errMsg( _T("Loading error"),  _T("Unable to load linear modes from ") + linearModesFilename );
        dlg->Destroy();
        return;
      }

      if (n1 != 3 * precomputationState.simulationMesh->getNumVertices())
      {
        this->errMsg( _T("Loading error"), _T("The number of vertices in ") + linearModesFilename + _T(" does not match the simulation mesh."));
        free(newLinearModes);
        dlg->Destroy();
        return;
      }

      if (precomputationState.frequenciesAvailable)
      {
        // check that the number of modes is consistent with the existing number of frequencies
        if (newr != precomputationState.rLin)
        {
          wxMessageDialog * confirmationDialog = new wxMessageDialog (this, _T("Warning: number of existing frequencies does not match the number of modes. Delete existing frequencies?"), _T("Mismatch in the number of frequencies"), wxYES_NO | wxICON_EXCLAMATION);

          if (confirmationDialog->ShowModal() != wxID_YES)
          {
            free(newLinearModes);
            delete(confirmationDialog);
            dlg->Destroy();
            return;
          }
          else
          {
            delete(confirmationDialog);
            free(precomputationState.frequencies);
            precomputationState.frequenciesAvailable = false;
          }
        }
      }

      // success
      delete(precomputationState.linearModalMatrix);
      precomputationState.rLin = newr;
      precomputationState.linearModalMatrix = new ModalMatrix(
        precomputationState.simulationMesh->getNumVertices(), precomputationState.rLin, newLinearModes);
      free(newLinearModes);

      precomputationState.linearModesAvailable = true;

      uiState.numComputedNonLinearModes = 2 * (precomputationState.rLin - precomputationState.numRigidModes);
      uiState.eraseRangeHi = precomputationState.rLin;

      modeSelectionControl->SetValue(1);

      SelectView(UIState::VIEW_LINEAR_MODES);
      SetAutoRenderingMagnitude(precomputationState.linearModalMatrix);

      UpdateMenus();

      myGLCanvas->UpdateLinearModesRenderData();

      Refresh();
    }
  }

  dlg->Destroy();
}
开发者ID:schumacb,项目名称:VegaFEM-qmake,代码行数:84,代码来源:linearModes.cpp

示例9: if

void MyFrame::OnComputeLinearModes(wxCommandEvent& event)
{
  char numLinearModesStringC[256];

  int numSuggestedModes = uiState.numComputedLinearModes;
  if (uiState.firstModalComputation)
  {
    // increase the number of suggested modes based on the number of constrained vertices
    if (precomputationState.fixedVertices.size() == 2)
    {
      numSuggestedModes += 1;
    }
    else if (precomputationState.fixedVertices.size() == 1)
    {
      numSuggestedModes += 3;
    }
    else if (precomputationState.fixedVertices.size() == 0)
    {
      numSuggestedModes += 6;
    }
  }

  sprintf(numLinearModesStringC, "%d", numSuggestedModes);

  wxDialog * dlg = new wxDialog(this, -1, _T("Select number of modes"),
    wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("dialogBox") );
  
  wxBoxSizer * dlgSizer = new wxBoxSizer(wxVERTICAL);

  wxStaticText * numModesText = new wxStaticText(dlg, -1, 
       _T("Number of modes: "), wxDefaultPosition, wxDefaultSize, 
       wxALIGN_CENTER, _T( "staticText"));

  wxTextCtrl * numModesControl = new wxTextCtrl(dlg, -1, 
      wxString(numLinearModesStringC, wxConvUTF8), wxDefaultPosition, wxSize(100,-1));

  wxBoxSizer * numModesSizer = new wxBoxSizer(wxHORIZONTAL);
  numModesSizer->Add(numModesText, 0, wxCENTER);
  numModesSizer->Add(numModesControl, 0, wxCENTER);
  dlgSizer->Add(numModesSizer, 0, wxALL | wxCENTER, 8);

  dlgSizer->Add(dlg->CreateButtonSizer(wxOK | wxCANCEL), 0, wxLEFT | wxRIGHT | wxBOTTOM | wxCENTER, 8);

  dlg->SetSizer(dlgSizer);
  dlgSizer->SetSizeHints(dlg);

  if (dlg->ShowModal() != wxID_OK)
  {
    delete(dlg);
    return;
  }

  wxString valueString = numModesControl->GetValue();

  delete(dlg);

  long value;
  bool goodInput = valueString.ToLong(&value);

  if (goodInput)
  {
    if ((value <= 0) || (value > 16384))
      goodInput = false;
  }

  if (goodInput)
  {
    int oldNumModes = uiState.numComputedLinearModes;
    uiState.numComputedLinearModes = value;

    double * newFrequencies = NULL;
    double * newLinearModes = NULL;
    int newr;

    SetCursor(*wxHOURGLASS_CURSOR);
    LinearModesWorker(
      uiState.numComputedLinearModes,
      &newr, &newFrequencies, &newLinearModes );
    SetCursor(*wxSTANDARD_CURSOR);

    if (newr != uiState.numComputedLinearModes)
    {
      uiState.numComputedLinearModes = oldNumModes;
      this->errMsg( _T("Linear mode computation failed"), 
             _T("Linear mode computation failed.") );
      free(newFrequencies);
      free(newLinearModes);
      return;
    }
    else
    {
      precomputationState.linearModesAvailable = true;
      uiState.firstModalComputation = false;
      UpdateMenus();
 
      delete(precomputationState.linearModalMatrix);
      precomputationState.rLin = uiState.numComputedLinearModes;
      precomputationState.linearModalMatrix = new ModalMatrix(
        precomputationState.simulationMesh->getNumVertices(), 
        precomputationState.rLin, newLinearModes);
//.........这里部分代码省略.........
开发者ID:schumacb,项目名称:VegaFEM-qmake,代码行数:101,代码来源:linearModes.cpp

示例10: GetScreen


//.........这里部分代码省略.........
            {
                m_requestAutoPan = false;
                GetParent()->HandleBlockPlace( &DC );
                m_ignoreNextLeftButtonRelease = true;
            }
        }
        else if( ( m_canStartBlock >= 0 )
                && ( event.LeftIsDown() || ( !m_enableMiddleButtonPan && event.MiddleIsDown() ) )
                && !IsMouseCaptured() )
        {
            // Mouse is dragging: if no block in progress,  start a block command.
            if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
            {
                //  Start a block command
                int cmd_type = kbstat;

                if( !m_enableMiddleButtonPan && event.MiddleIsDown() )
                    cmd_type |= MOUSE_MIDDLE;

                // A block command is started if the drag is enough.  A small
                // drag is ignored (it is certainly a little mouse move when
                // clicking) not really a drag mouse
                if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
                    m_minDragEventCount++;
                else
                {
                    if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) )
                    {
                        // should not occur: error
                        GetParent()->DisplayToolMsg(
                            wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
                    }
                    else
                    {
                        m_requestAutoPan = true;
                        SetCursor( wxCURSOR_SIZING );
                    }
                }
            }
        }

        if( event.ButtonUp( wxMOUSE_BTN_LEFT ) ||
            ( !m_enableMiddleButtonPan && event.ButtonUp( wxMOUSE_BTN_MIDDLE ) ) )
        {
            /* Release the mouse button: end of block.
             * The command can finish (DELETE) or have a next command (MOVE,
             * COPY).  However the block command is canceled if the block
             * size is small because a block command filtering is already
             * made, this case happens, but only when the on grid cursor has
             * not moved.
             */
            #define BLOCK_MINSIZE_LIMIT 1
            bool BlockIsSmall =
                ( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
                && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );

            if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
            {
                if( m_endMouseCaptureCallback )
                {
                    m_endMouseCaptureCallback( this, &DC );
                    m_requestAutoPan = false;
                }

                SetCursor( (wxStockCursor) m_currentCursor );
           }
            else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
            {
                m_requestAutoPan = false;
                GetParent()->HandleBlockEnd( &DC );
                SetCursor( (wxStockCursor) m_currentCursor );
                if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
                {
                    m_requestAutoPan = true;
                    SetCursor( wxCURSOR_HAND );
                }
           }
        }
    }

    // End of block command on a double click
    // To avoid an unwanted block move command if the mouse is moved while double clicking
    if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
    {
        if( !screen->IsBlockActive() && IsMouseCaptured() )
        {
            m_endMouseCaptureCallback( this, &DC );
        }
    }

#if 0
    wxString msg_debug;
    msg_debug.Printf( " block state %d, cmd %d",
                      screen->m_BlockLocate.GetState(),
                      screen->m_BlockLocate.GetCommand() );
    GetParent()->PrintMsg( msg_debug );
#endif

    lastPanel = this;
}
开发者ID:Elphel,项目名称:kicad-source-mirror,代码行数:101,代码来源:draw_panel.cpp

示例11: WinMain

//WinMain -- Main Window
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine, int nCmdShow )
{
    MSG msg;
    msg.message = WM_CREATE;

    WNDCLASS wc;
    wc.style = CS_HREDRAW|CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(GetModuleHandle(NULL), IDI_APPLICATION);
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "chockngt";

    RegisterClass (&wc);

    // Create the window
    //mainWnd = CreateWindow (szAppName,szAppName,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,1024,600,0,0,hInstance,0);
    mainWnd = CreateWindow("chockngt","chockngt",WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,hInstance,0);
    glInit();

    ShowWindow(mainWnd,SW_SHOW);
    UpdateWindow(mainWnd);

    // Initialize Swarm positions and stuff
    initSwarm();

    long startTime = timeGetTime();
    long lastTime = 0;

    // start music playback
    BASS_Init(-1,44100,0,mainWnd,NULL);
    mp3Str=BASS_StreamCreateFile(FALSE,"GT_muc.mp3",0,0,0);
    BASS_ChannelPlay(mp3Str, TRUE);
    BASS_Start();
    float fCurTime;
    GetAsyncKeyState(VK_ESCAPE);

    do
    {
        SetCursor(FALSE);

        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            if (!IsDialogMessage(mainWnd, &msg))
            {
                TranslateMessage (&msg);
                DispatchMessage (&msg);
            }
        }
        if (msg.message == WM_QUIT) break; // early exit on quit

        // update timer
        long curTime = timeGetTime() - startTime;
        fCurTime = (float)curTime * 0.001f;
        long deltaTime = curTime - lastTime;
        float fDeltaTime = (float) deltaTime * 0.001f;
        lastTime = curTime;

        // render
        wglMakeCurrent(mainDC, mainRC);

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glDisable(GL_DEPTH_TEST);

        // draw background
        //drawQuad(-1.0f, 1.0f, -1.0f, 1.0f, 0.4f, 1.0f, 1.0f);
        glEnable(GL_DEPTH_TEST);

        // Distance to the center object
        // TODO: Hitchcock-effect by means of gluPerspective!
        float cameraDist = 20.0f;
        float cameraComeTime = 150.0f;
        if (fCurTime > cameraComeTime)
        {
            cameraDist = 3.0f + 17.0f / (1.0f + 0.1f * ((fCurTime - cameraComeTime) * (fCurTime - cameraComeTime)));
        }

        // set up matrices
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        // TODO aspect
        //gluPerspective(25.0,  1.8, 0.1, 100.0);
        gluPerspective(500.0f / cameraDist,  1.8, 0.1, 100.0);
        //gluPerspective(25.0,  1.8, 1.1, 100.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        //gluLookAt(0.0, 0.0, -cameraDist,
        //		  0.0, 0.0, 0.0,
        //		  0.0, 1.0, 0.0);
        gluLookAt(1., 0.5, -cameraDist,
                  1., 0.5, 0.0,
                  0.0, 1.0, 0.0);

//.........这里部分代码省略.........
开发者ID:chock-mostlyharmless,项目名称:mostlyharmless,代码行数:101,代码来源:chockNgt.cpp

示例12: Clear

/*
===============
idEditField::SetBuffer
===============
*/
void idEditField::SetBuffer( const char *buf )
{
	Clear();
	idStr::Copynz( buffer, buf, sizeof( buffer ) );
	SetCursor( strlen( buffer ) );
}
开发者ID:revelator,项目名称:MHDoom,代码行数:11,代码来源:EditField.cpp

示例13: sizeof

/*
===============
idEditField::AutoComplete
===============
*/
void idEditField::AutoComplete( void )
{
	char completionArgString[MAX_EDIT_LINE];
	idCmdArgs args;
	
	if( !autoComplete.valid )
	{
		args.TokenizeString( buffer, false );
		idStr::Copynz( autoComplete.completionString, args.Argv( 0 ), sizeof( autoComplete.completionString ) );
		idStr::Copynz( completionArgString, args.Args(), sizeof( completionArgString ) );
		autoComplete.matchCount = 0;
		autoComplete.matchIndex = 0;
		autoComplete.currentMatch[0] = 0;
		
		if( strlen( autoComplete.completionString ) == 0 )
		{
			return;
		}
		
		globalAutoComplete = autoComplete;
		
		cmdSystem->CommandCompletion( FindMatches );
		cvarSystem->CommandCompletion( FindMatches );
		
		autoComplete = globalAutoComplete;
		
		if( autoComplete.matchCount == 0 )
		{
			return;	// no matches
		}
		
		// when there's only one match or there's an argument
		if( autoComplete.matchCount == 1 || completionArgString[0] != '\0' )
		{
		
			/// try completing arguments
			idStr::Append( autoComplete.completionString, sizeof( autoComplete.completionString ), " " );
			idStr::Append( autoComplete.completionString, sizeof( autoComplete.completionString ), completionArgString );
			autoComplete.matchCount = 0;
			
			globalAutoComplete = autoComplete;
			
			cmdSystem->ArgCompletion( autoComplete.completionString, FindMatches );
			cvarSystem->ArgCompletion( autoComplete.completionString, FindMatches );
			
			autoComplete = globalAutoComplete;
			
			idStr::snPrintf( buffer, sizeof( buffer ), "%s", autoComplete.currentMatch );
			
			if( autoComplete.matchCount == 0 )
			{
				// no argument matches
				idStr::Append( buffer, sizeof( buffer ), " " );
				idStr::Append( buffer, sizeof( buffer ), completionArgString );
				SetCursor( strlen( buffer ) );
				return;
			}
		}
		else
		{
		
			// multiple matches, complete to shortest
			idStr::snPrintf( buffer, sizeof( buffer ), "%s", autoComplete.currentMatch );
			
			if( strlen( completionArgString ) )
			{
				idStr::Append( buffer, sizeof( buffer ), " " );
				idStr::Append( buffer, sizeof( buffer ), completionArgString );
			}
		}
		
		autoComplete.length = strlen( buffer );
		autoComplete.valid = ( autoComplete.matchCount != 1 );
		SetCursor( autoComplete.length );
		
		common->Printf( "]%s\n", buffer );
		
		// run through again, printing matches
		globalAutoComplete = autoComplete;
		
		cmdSystem->CommandCompletion( PrintMatches );
		cmdSystem->ArgCompletion( autoComplete.completionString, PrintMatches );
		cvarSystem->CommandCompletion( PrintCvarMatches );
		cvarSystem->ArgCompletion( autoComplete.completionString, PrintMatches );
		
	}
	else if( autoComplete.matchCount != 1 )
	{
	
		// get the next match and show instead
		autoComplete.matchIndex++;
		
		if( autoComplete.matchIndex == autoComplete.matchCount )
		{
			autoComplete.matchIndex = 0;
//.........这里部分代码省略.........
开发者ID:revelator,项目名称:MHDoom,代码行数:101,代码来源:EditField.cpp

示例14: LicenseProc

static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  page *m_this_page=g_this_page;
  HWND hwLicense;
  static int ignoreWMCommand;

  if (uMsg == WM_INITDIALOG)
  {
    TCHAR *l = (TCHAR *)GetNSISStringNP(GetNSISTab(this_page->parms[1]));
    int lt = *l;
    EDITSTREAM es = {
      (DWORD)(++l),
      0,
      StreamLicense
    };

    int selected = (this_page->flags & PF_LICENSE_SELECTED) | !(this_page->flags & PF_LICENSE_FORCE_SELECTION);

    SetUITextFromLang(IDC_LICENSEAGREE,this_page->parms[2]);
    SetUITextFromLang(IDC_LICENSEDISAGREE,this_page->parms[3]);
    CheckDlgButton(hwndDlg,IDC_LICENSEAGREE+!selected,BST_CHECKED);
    EnableNext(selected);

    hwLicense=GetUIItem(IDC_EDIT1);
    SetActiveCtl(hwLicense);
    SendMessage(hwLicense,EM_AUTOURLDETECT,TRUE,0);
#define lbg g_header->license_bg
    SendMessage(hwLicense,EM_SETBKGNDCOLOR,0,lbg>=0?lbg:GetSysColor(-lbg));
#undef lbg
    SendMessage(hwLicense,EM_SETEVENTMASK,0,ENM_LINK|ENM_KEYEVENTS); //XGE 8th September 2002 Or'd in ENM_KEYEVENTS
    dwRead=0;
    SendMessage(hwLicense,EM_EXLIMITTEXT,0,mystrlen(l));
    SendMessage(hwLicense,EM_STREAMIN,lt,(LPARAM)&es);
    ignoreWMCommand = 0;
    return FALSE;
  }
  if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED && !ignoreWMCommand) {
    if (m_this_page->flags & PF_LICENSE_FORCE_SELECTION) {
      int is = SendMessage(GetUIItem(IDC_LICENSEAGREE), BM_GETCHECK, 0, 0) & BST_CHECKED;
      m_this_page->flags &= ~PF_LICENSE_SELECTED;
      m_this_page->flags |= is;
      EnableNext(is);
      SetNextDef();
    }
  }
  if (uMsg == WM_NOTIFY) {
    hwLicense=GetUIItem(IDC_EDIT1);
    #define nmhdr ((NMHDR *)lParam)
    #define enlink ((ENLINK *)lParam)
    #define msgfilter ((MSGFILTER *)lParam)
    if (nmhdr->code==EN_LINK) {
      if (enlink->msg==WM_LBUTTONDOWN) {
        TEXTRANGE tr = {
          {
            enlink->chrg.cpMin,
            enlink->chrg.cpMax,
          },
          ps_tmpbuf
        };
        if (tr.chrg.cpMax-tr.chrg.cpMin < sizeof(ps_tmpbuf)) {
          SendMessage(hwLicense,EM_GETTEXTRANGE,0,(LPARAM)&tr);
          SetCursor(LoadCursor(0, IDC_WAIT));
          ShellExecute(hwndDlg,_T("open"),tr.lpstrText,NULL,NULL,SW_SHOWNORMAL);
          SetCursor(LoadCursor(0, IDC_ARROW));
        }
      }
    }
    //Ximon Eighteen 8th September 2002 Capture return key presses in the rich
    //edit control now that the control gets the focus rather than the default
    //push button. When the user presses return ask the outer dialog to move
    //the installer onto the next page. MSDN docs say return non-zero if the
    //rich edit control should NOT process this message, hence the return 1.
    //
    //This is required because the RichEdit control is eating all the key hits.
    //It does try to release some and convert VK_ESCAPE to WM_CLOSE, VK_ENTER
    //to a push on the default button and VM_TAB to WM_NEXTDLGCTL. But sadly it
    //it sends all of these messages to its parent instead of just letting the
    //dialog manager handle them. Instead of properly handling WM_GETDLGCODE,
    //it mimics the dialog manager.
    if (nmhdr->code==EN_MSGFILTER)
    {
      if (msgfilter->msg==WM_KEYDOWN)
      {
        if (msgfilter->wParam==VK_RETURN) {
          SendMessage(g_hwnd, WM_COMMAND, IDOK, 0);
        }
        if (msgfilter->wParam==VK_ESCAPE) {
          SendMessage(g_hwnd, WM_CLOSE, 0, 0);
        }
        return 1;
      }
    }
    #undef nmhdr
    #undef enlink
    #undef msgfilter
  }
  if (uMsg == WM_NOTIFY_INIGO_MONTOYA)
  {
    ignoreWMCommand++;
  }
//.........这里部分代码省略.........
开发者ID:kichik,项目名称:nsis-1,代码行数:101,代码来源:Ui.c

示例15: memset

HRESULT APPLICATION::Init(HINSTANCE hInstance, int width, int height, bool windowed)
{
	debug.Print("Application initiated");

	//Create Window Class
	WNDCLASS wc;
	memset(&wc, 0, sizeof(WNDCLASS));
	wc.style         = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = (WNDPROC)::DefWindowProc; 
	wc.hInstance     = hInstance;
	wc.lpszClassName = "D3DWND";

	//Register Class and Create new Window
	RegisterClass(&wc);
	m_mainWindow = CreateWindow("D3DWND", "Example 4.1: Heightmaps from Images", WS_EX_TOPMOST, 0, 0, width, height, 0, 0, hInstance, 0); 
	SetCursor(NULL);
	ShowWindow(m_mainWindow, SW_SHOW);
	UpdateWindow(m_mainWindow);

	//Create IDirect3D9 Interface
	IDirect3D9* d3d9 = Direct3DCreate9(D3D_SDK_VERSION);

    if(d3d9 == NULL)
	{
		debug.Print("Direct3DCreate9() - FAILED");
		return E_FAIL;
	}

	//Check that the Device supports what we need from it
	D3DCAPS9 caps;
	d3d9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);

	//Hardware Vertex Processing or not?
	int vp = 0;
	if(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
		vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	//Check vertex & pixelshader versions
	if(caps.VertexShaderVersion < D3DVS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
	{
		debug.Print("Warning - Your graphic card does not support vertex and pixelshaders version 2.0");
	}

	//Set D3DPRESENT_PARAMETERS
	D3DPRESENT_PARAMETERS d3dpp;
	d3dpp.BackBufferWidth            = width;
	d3dpp.BackBufferHeight           = height;
	d3dpp.BackBufferFormat           = D3DFMT_A8R8G8B8;
	d3dpp.BackBufferCount            = 1;
	d3dpp.MultiSampleType            = D3DMULTISAMPLE_NONE;
	d3dpp.MultiSampleQuality         = 0;
	d3dpp.SwapEffect                 = D3DSWAPEFFECT_DISCARD; 
	d3dpp.hDeviceWindow              = m_mainWindow;
	d3dpp.Windowed                   = windowed;
	d3dpp.EnableAutoDepthStencil     = true; 
	d3dpp.AutoDepthStencilFormat     = D3DFMT_D24S8;
	d3dpp.Flags                      = 0;
	d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
	d3dpp.PresentationInterval       = D3DPRESENT_INTERVAL_IMMEDIATE;

	//Create the IDirect3DDevice9
	if(FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mainWindow,
								 vp, &d3dpp, &m_pDevice)))
	{
		debug.Print("Failed to create IDirect3DDevice9");
		return E_FAIL;
	}

	//Release IDirect3D9 interface
	d3d9->Release();

	D3DXCreateFont(m_pDevice, 18, 0, 0, 1, false,  
				   DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
				   DEFAULT_PITCH | FF_DONTCARE, "Arial", &m_pFont);

	return S_OK;
}
开发者ID:Alriightyman,项目名称:RTS,代码行数:78,代码来源:app.cpp


注:本文中的SetCursor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。