您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 在vc中方便的实现不规则形状按钮
  所属分类: C++
  开发工具:
  文件大小: 8kb
  下载次数: 0
  上传时间: 2009-04-15
  提 供 者: qingyap********
 详细说明: Using CVtxButton Implementing the CVtxButton class is surprisingly easy: Include Vtx.h, Vtx.ccp, VtxButton.h, and VtxButton.cpp in your project. Drop a button on your dialog in Developer Studio. Add #include "VtxButton.h" immediately before #include "MyDlg.h" in MyDlg.cpp and MyApp.cpp. For each button on the dialog that you want to be a CVtxButton, add CVtxButton m_cButton1; immediately after //{{AFX_DATA(CMyDlg) in the public section of your dialog class' specification. Also add DDX_Control(pDX, IDC_BU TTON1, m_cButton1); immediately after //{{AFX_DATA_MAP(CMyDlg) in DoDataExchange() for each button. This is enough to create a default CVtxButton. The button is drawn as a rectangle that takes up the entire client area. The sides will not be shaded the same as CButton because they are colored according to the difference of their angle and the angle of light source. If you use at least one CVtxButton on a dialog, it is suggested that you change all your CButton's to CVtxButton's to maintain a coordinated look. If you want to change the look of the CVtxBuUtton, there are two ways of doing so: Use a predefined shape by adding m_cButton1.SetVtx(VTX_RECT); to OnInitDialog() in MyDlg.cpp. There are four predefined shapes which can be passed as an argument to SetVtx(): VTX_RECT VTX_DIAMOND VTX_CIRCLE VTX_STRETCHEDCIRCLE Create a CVtxPolygons object and pass it as an argument to SetVtx(): CRect rect; m_cButton1.GetClientRect(&rect); // Get the button's original dimensions CVtxPolygons vtxPolygons; int offset[4] = {0, 1, 2, 4}; for (int i = 0; i < 4; i++) // Iterate through each of the polygons { // Add the corners vtxPolygons.Add(i, CVertex(rect.left + offset[i], rect.top + offset[i])); vtxPolygons.Add(i, CVertex(rect.right - offset[i] - 1, rect.top + offset[i])); vtxPolygons.Add(i, CVertex(rect.right - offset[i] - 1, rect.bottom - offset[i] - 1)); vtxPolygons.Add(i, CVertex(rect.left + offset[i], rect.bottom - offset[i] - 1)); } vtxPolygons.ClosePolygons(); // Close the polygons off m_cButton1.SetVtxPolygons(&vtxPolygons); // Set the button's polygons Technical Information CVtxButton is implemented through the use of three classes: CVtxButton itself, CVtxPolygons, and CVertex. To understand how CVtxButton works it is crucial to understand each of these classes. CVertex is essentially a CPoint; however, it is an object derived from CObject, not a structure. It has two member variables, x and y, and has just enough constructors and operators to work with CVtxPolygons. It is not a full-featured storage class. CVtxPolygons is a storage class specifically designed for use with CVtxButton. It contains a private array of four CObArray's called m_oaPolygons. Each CObArray is a list of CVertex's which defines a polygon. These polygons can be tweaked through the use of member functions such as GetSize(), SetAt(), and RemoveAll(). CVtxButton is the button itself, derived from CButton. It draws itself using the m_vtxBtnPolygons member variable, which is of type CVtxPolygons. Each CObArray in a CVtxPolygons object represents a different part of the button. The CObArray at index 0 is the outer border of the button. At index 1 the CObArray is the middle border of the button. Index 2 is the inner border, and index 3 is the focus polygon. If the button is not selected, only the outer and middle polygons are drawn. If the button is focused or selected, all the polygons are drawn. Here is another example of using CVtxButton: CRect rect; m_cButton1.GetClientRect(&rect); CVtxPolygons vtxPolygons; int offset[4] = {0, 1, 2, 4}; for (int i = 0; i < 4; i++) { vtxPolygons.Add(i, CVertex(rect.left + rect.bottom / 4 + offset[i], rect.top + offset[i])); vtxPolygons.Add(i, CVertex(rect.right - offset[i] * 7 / 4 - 1, rect.top + offset[i])); vtxPolygons.Add(i, CVertex(rect.right - rect.bottom / 4 - offset[i] - 1, rect.bottom - offset[i] - 1)); vtxPolygons.Add(i, CVertex(rect.left + offset[i] * 7 / 4, rect.bottom - offset[i] - 1)); } vtxPolygons.ClosePolygons(); m_cButton1.SetVtxPolygons(&vtxPolygons); ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: C++ 不规则按钮 源代码
 输入关键字,在本站1000多万海量源码库中尽情搜索: