• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-341  評(píng)論-2670  文章-0  trackbacks-0
                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++

            評(píng)論:
            # re: Vista的新控件 2008-07-22 08:13 | foxtail
            我也發(fā)現(xiàn)支持C++額哈 他默認(rèn)就是  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-22 23:01 | foxtail
            有空講講你的gui庫的設(shè)計(jì)框架和思路哈  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-23 04:27 | suxiaojack
            MFC的窗體對(duì)象(控件窗體對(duì)象)等等是給用戶的操作層,和系統(tǒng)層面的窗體“實(shí)物”,本來就是通過句柄指針聯(lián)系起來的,互相之間通信依靠的消息處理,怎么說MFC的開發(fā)者執(zhí)著于『不使用指針代表控件』?  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-23 06:02 | 夢(mèng)在天涯
            支持C++了嗎?那真是太好了??!  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-24 06:08 | 陳梓瀚(vczh)
            @suxiaojack
            我的意思是,控件在形式上不是引用。譬如說.net還是delphi,都是引用。因?yàn)镃++語法的緣故,不強(qiáng)迫人們使用new來創(chuàng)建控件的話,結(jié)果就會(huì)變成『存在對(duì)象不等于存在控件』,用起來會(huì)很不舒服。  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-24 19:52 | cexer
            強(qiáng)迫用new來創(chuàng)建對(duì)象,在一些場(chǎng)合當(dāng)中會(huì)造成設(shè)計(jì)上的難題。
            比如假設(shè)有設(shè)計(jì)為了更大的靈活性,要求對(duì)象的創(chuàng)建與對(duì)象管理的資源的初始化與創(chuàng)建能夠要分步進(jìn)行。  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-25 08:42 | MiGL
            @cexer
            可以使用Factory或者prototype模式解決,也許會(huì)好一些。  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-25 19:44 | 陳梓瀚(vczh)
            窗口最需要的是資源文件或者等價(jià)物,這個(gè)已經(jīng)被多年的開發(fā)證明了。所以使用new創(chuàng)建是更加合理的。  回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-26 01:59 | cexer
            這個(gè)沒有絕對(duì)的吧,得看具體的環(huán)境。

            比如有一個(gè)GUI框架,它用prototype模式從xml產(chǎn)生界面。分幾步進(jìn)行
            1.解析器看到一個(gè)結(jié)點(diǎn)
            <window name="xxxx" text="xxx ... />
            2.從prototype的注冊(cè)表里查找節(jié)點(diǎn)名字"window"對(duì)應(yīng)的prototype,并clone出對(duì)象window
            3.將xml結(jié)點(diǎn)傳給對(duì)象,調(diào)用對(duì)象的創(chuàng)建函數(shù)window->create( XmlElement& xml )

            我覺得在這種方式下先new后create會(huì)比一步創(chuàng)建好得多。當(dāng)然也可以第二步時(shí),將xml結(jié)點(diǎn)也同時(shí)傳給prototype創(chuàng)建者,一步創(chuàng)建成功,不過這樣比起分步進(jìn)行,一是少了一個(gè)可控制進(jìn)行其它操作的機(jī)會(huì),二是如果以后創(chuàng)建方式有所更改,就也得同時(shí)更改prototype創(chuàng)建者的代碼。


              回復(fù)  更多評(píng)論
              
            # re: Vista的新控件 2008-07-27 06:28 | 陳梓瀚(vczh)
            所以嘛,如果一直都用new的話就改不了了。而且這實(shí)際上也基本未曾發(fā)生過。我們應(yīng)該阻止創(chuàng)建方法改變而不是允許改變而讓絕大多數(shù)程序都更囧。而且所有的控件庫都有很多set*函數(shù),因此是允許創(chuàng)建后改變的。  回復(fù)  更多評(píng)論
              
            亚洲国产精品无码久久98| 亚洲国产美女精品久久久久∴| 欧美一区二区三区久久综合| 欧洲性大片xxxxx久久久| 亚洲综合婷婷久久| 久久99热精品| 99久久综合国产精品二区| 久久精品国产亚洲av麻豆小说| 综合久久一区二区三区 | 亚洲综合伊人久久综合| 香蕉99久久国产综合精品宅男自 | 国产亚州精品女人久久久久久 | 久久亚洲国产精品五月天婷| 国产福利电影一区二区三区久久久久成人精品综合 | 狠狠88综合久久久久综合网| 亚洲AV无码成人网站久久精品大| 久久国产免费直播| 午夜精品久久久久久中宇| 亚洲日韩中文无码久久| 一本久道久久综合狠狠爱| 久久精品国产久精国产思思| 国产Av激情久久无码天堂| 91精品国产高清久久久久久91| 国产精品综合久久第一页| 久久亚洲AV无码西西人体| 中文字幕久久精品 | 久久青草国产手机看片福利盒子| 亚洲国产精品久久66| 国产精品VIDEOSSEX久久发布| 26uuu久久五月天| 欧美激情精品久久久久久久九九九| 欧洲性大片xxxxx久久久| 久久妇女高潮几次MBA| 久久国产精品成人免费| 久久精品国产只有精品66 | 亚洲国产精品久久电影欧美| 久久99热国产这有精品| 亚洲日本va午夜中文字幕久久| 伊人久久大香线蕉AV色婷婷色| 国内精品久久久久久99| 久久久久99精品成人片牛牛影视 |