Vista提供的Common Control Library 6.0的BUTTON類中提供了兩種新的按鈕:Command Link和Split Button。只需要在CreateWindow里面指定BS_COMMANDLINK與BS_SPLITBUTTON就可以獲得這兩種新的控件了。
實(shí)習(xí)的時(shí)候每天自己的時(shí)間不是很多,加上有一些預(yù)定事項(xiàng),教程只能在周末寫了。閑暇之余,我繼續(xù)完成半年前沒寫完的C++ GUI庫。這個(gè)庫的特點(diǎn)在于用起來跟Delphi、VB、C#差不多,而且指定事件很方便(前面
關(guān)于2D的文章中有出現(xiàn))。于是今晚加上了這兩個(gè)控件。
話說回來,XP下Common Control Library 6.0的bug似乎在Vista底下消滅了不少。

1 #include "..\..\..\..\VL++\Library\Windows\VL_WinMain.h"
2 #include "..\..\..\..\VL++\Library\Windows\Commctrl\VL_WinButton.h"
3 #include "..\..\..\..\VL++\Library\Windows\Commctrl\VL_WinContainers.h"
4
5 using namespace vl;
6 using namespace vl::windows;
7
8 class MyForm : public VL_WinForm
9 {
10 public:
11 VL_WinGroup* groupA;
12 VL_WinButton* buttonA;
13 VL_WinCheck* checkA;
14 VL_WinCheck* checkB;
15 VL_WinCheck* checkC;
16 VL_WinRadio* radioA;
17 VL_WinRadio* radioB;
18 VL_WinRadio* radioC;
19 VL_WinSplitButton* splitA;
20 VL_WinCommandLink* clA;
21
22 void InitControls()
23 {
24 groupA=new VL_WinGroup(this);
25 groupA->SetLeft(10);
26 groupA->SetTop(10);
27 groupA->SetWidth(380);
28 groupA->SetHeight(380);
29 groupA->SetText(L"Group A");
30
31 buttonA=new VL_WinButton(groupA);
32 buttonA->SetLeft(10);
33 buttonA->SetTop(20);
34 buttonA->SetWidth(100);
35 buttonA->SetHeight(20);
36 buttonA->SetText(L"Button A");
37
38 splitA=new VL_WinSplitButton(groupA);
39 splitA->SetLeft(120);
40 splitA->SetTop(20);
41 splitA->SetWidth(100);
42 splitA->SetHeight(20);
43 splitA->SetText(L"Split A");
44
45 checkA=new VL_WinCheck(groupA);
46 checkA->SetLeft(10);
47 checkA->SetTop(50);
48 checkA->SetWidth(100);
49 checkA->SetHeight(20);
50 checkA->SetText(L"Check A");
51
52 checkB=new VL_WinCheck(groupA);
53 checkB->SetLeft(10);
54 checkB->SetTop(80);
55 checkB->SetWidth(100);
56 checkB->SetHeight(20);
57 checkB->SetText(L"Check B");
58
59 checkC=new VL_WinCheck(groupA);
60 checkC->SetLeft(10);
61 checkC->SetTop(110);
62 checkC->SetWidth(100);
63 checkC->SetHeight(20);
64 checkC->SetText(L"Check A");
65
66 radioA=new VL_WinRadio(groupA);
67 radioA->SetLeft(120);
68 radioA->SetTop(50);
69 radioA->SetWidth(100);
70 radioA->SetHeight(20);
71 radioA->SetText(L"Radio A");
72
73 radioB=new VL_WinRadio(groupA);
74 radioB->SetLeft(120);
75 radioB->SetTop(80);
76 radioB->SetWidth(100);
77 radioB->SetHeight(20);
78 radioB->SetText(L"Radio B");
79
80 radioC=new VL_WinRadio(groupA);
81 radioC->SetLeft(120);
82 radioC->SetTop(110);
83 radioC->SetWidth(100);
84 radioC->SetHeight(20);
85 radioC->SetText(L"Radio A");
86
87 clA=new VL_WinCommandLink(groupA);
88 clA->SetLeft(10);
89 clA->SetTop(140);
90 clA->SetWidth(200);
91 clA->SetHeight(100);
92 clA->SetText(L"Text");
93 clA->SetNote(L"with a command note");
94 }
95
96 MyForm():VL_WinForm(true)
97 {
98 SetClientWidth(400);
99 SetClientHeight(400);
100 SetText(L"Vczh Form");
101 MoveCenter();
102 InitControls();
103 Show();
104 }
105 };
106
107 void main()
108 {
109 new MyForm;
110 GetApplication()->Run();
111 }
至于MFC為什么要?jiǎng)?chuàng)建一個(gè)對(duì)象之后調(diào)用Create才能夠真的構(gòu)造出一個(gè)控件,原因在于MFC的開發(fā)者執(zhí)著于『不使用指針代表控件』,而且C++的構(gòu)造函數(shù)里面調(diào)用不到被子類覆蓋的虛函數(shù),才搞成了那個(gè)樣子。
今天貼代碼的時(shí)候,發(fā)現(xiàn)cppblog終于支持C++了。
posted on 2008-07-22 06:41
陳梓瀚(vczh) 閱讀(1940)
評(píng)論(10) 編輯 收藏 引用 所屬分類:
C++