- 博客(1)
- 资源 (1)
- 收藏
- 关注
转载 KeyAscii
vbKeyLButton 1 鼠标左键 vbKeyRButton 2 鼠标右键 vbKeyCancel 3 CANCEL 键 vbKeyMButton 4 鼠标中键 vbKeyBack 8 BACKSPACE 键 vbKeyTab 9 TAB 键 vbKeyClear 12 CLEAR 键 vbKeyReturn 13 ENTER 键 vbKeyShift 16 S
2012-05-25 10:00:51 179
在vc中方便的实现不规则形状按钮
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_BUTTON1, 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]
2009-04-15
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人