Vista的新控件

Vista的新控件
    Vista提供的Common Control Library 6.0的BUTTON类中提供了两种新的按钮:Command Link和Split Button。只需要在CreateWindow里面指定BS_COMMANDLINK与BS_SPLITBUTTON就可以获得这两种新的控件了。

    实习的时候每天自己的时间不是很多,加上有一些预定事项,教程只能在周末写了。闲暇之余,我继续完成半年前没写完的C++ GUI库。这个库的特点在于用起来跟Delphi、VB、C#差不多,而且指定事件很方便(前面 关于2D的文章中有出现)。于是今晚加上了这两个控件。

    话说回来,XP下Common Control Library 6.0的bug似乎在Vista底下消灭了不少。
Vista的新控件_第1张图片
  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为什么要创建一个对象之后调用Create才能够真的构造出一个控件,原因在于MFC的开发者执着于『不使用指针代表控件』,而且C++的构造函数里面调用不到被子类覆盖的虚函数,才搞成了那个样子。

    今天贴代码的时候,发现cppblog终于支持C++了。

你可能感兴趣的:(Vista的新控件)