您的位置:逆风者 VC++ 正文
 添加时间:2007-09-11 原文发表:2007-09-11 人气:188 来源:vckbase.com

本文章共9978字,分6页,当前第6页,快速翻页:
 

  通过建立区域和调用SetWindowRgn,已经建立一个不规则形状的窗口,下面的例子程序是修改OnPaint函数使窗口形状看起来象一个球形体。

逆风编程精品

  voik CRoundDlg : : OnPaint ( )
  {
  CPaintDC de (this) // device context for painting
  .
  //draw ellipse with out any border
  dc. SelecStockObject (NULL_PEN)
  //get the RGB colour components of the sphere color
  COLORREF color= RGB( 0 , 0 , 255)
  BYTE byRed =GetRValue (color)
  BYTE byGreen = GetGValue (color)
  BYTE byBlue = GetBValue (color)

  // get the size of the view window
  Crect rect
  GetClientRect (rect)

  // get minimun number of units
  int nUnits =min (rect.right , rect.bottom )

  //calculate he horiaontal and vertical step size
  float fltStepHorz = (float) rect.right /nUnits
  float fltStepVert = (float) rect.bottom /nUnits


  int nEllipse = nUnits/3 // calculate how many to
  draw
  int nIndex
  // current ellipse that is being draw

  CBrush brush
  // bursh used for ellipse fill color
  CBrush *pBrushOld // previous
  brush that was selected into dc
  //draw ellipse , gradually moving towards upper-right
  corner
  for (nIndex = 0 nIndes < + nEllipse nIndes++)
  {
  //creat solid brush
  brush . CreatSolidBrush (RGB ( ( (nIndex*byRed ) /nEllipse ).
  ( ( nIndex * byGreen ) /nEllipse ), ( (nIndex * byBlue)
  /nEllipse ) ) )

  //select brush into dc
  pBrushOld= dc .SelectObject (&brhsh)

  //draw ellipse
  dc .Ellipse ( (int) fltStepHorz * 2, (int) fltStepVert * nIndex ,
  rect. right -( (int) fltStepHorz * nIndex )+ 1,
  rect . bottom -( (int) fltStepVert * (nIndex *2) ) +1)

  //delete the brush
  brush.DelecteObject ( )
  }
  }

  最后,处理WM_NCHITTEST消息,使当击打窗口的任何位置时能移动窗口。

  UINT CRoundDlg : : OnNchitTest (Cpoint point )
  {
  //Let user move window by clickign anywhere on thewindow .
  UINT nHitTest = CDialog : : OnNcHitTest (point)
  rerurn (nHitTest = = HTCLIENT)? HTCAPTION: nHitTest

  }

  (25) 如何获取应用程序的 实例句柄?
  应用程序的实例句柄保存在CWinApp m_hInstance 中,可以这么调用AfxGetInstancdHandle获得句柄.

  Example: HANDLE hInstance=AfxGetInstanceHandle()


 
本文章更多内容<<上一页 - 1 - 2 - 3 - 4 - 5 - 6
相关文章

超强仿QQ自动伸缩窗口
WIN32程序挂钩SetLastError,输出错误描述到
Spy++原理初探
汉诺塔游戏的设计
关于控件注册和使用许可问题的解决办法
基于MFC对话框的NT服务程序框架
计算MDI子窗口数,仅显示文件夹的打开对话框
PE文件格式详解(下)
GDI和GDI 对象的相互转换
软件框架的利器、TangramMini组件应用教程二
VC实用小知识总结 (二)
BMP图象解析
让你的软件界面更漂亮(五)
MFC中基于对话框程序快捷键的实现
用递归的方法画分形图
利用IJG JPEG Library压缩图像为jpg格式
软件框架的利器、TangramMini组件应用教程六
让你的软件界面更漂亮(六)-- 仿QQ主界面之L
对OpenCV中的平面划分相关函数使用探索
探讨性能测试中的计时问题

相关评论


本文章所属分类:首页 VC++

  热门关键字: