傳統MFC界面主要是在一個.rc文件裡進行窗口的布局,然後在resource.h中維系一個控件ID通過此控件ID在程序中通過此控件ID就可以訪問到該控件,從而對指定控件做出各種操作;DuiEngine與之不同,但是思想仍然類似。以上章我們利用DuiEngineWizard生成的第一個工程為例:
"XXXX\duiengine\tool\residbuilder2.exe" -i "XXXX\duiengine\FirsrtDuiEngineDemo\FirsrtDuiEngineDemo\skin\index.xml" -y –p
skin -r .\duires\winres.rc2 -n .\duires\name2id.xml -h .\duires\winres.h
下面我們就上面這條命令來詳細解說各個文件的作用:
First
-i "XXXX\duiengine\FirsrtDuiEngineDemo\FirsrtDuiEngineDemo\skin\index.xml"
命令-i表示讀取index.xml,即讀取工程中資源文件命名表
<resid type="XML" name="IDR_DUI_INIT" file="xml\init.xml" /> <resid type="XML" name="IDR_DUI_MSGBOX" file="xml\dlg_msgbox.xml" /> <resid type="XML" name="IDR_DUI_MAIN_DIALOG" layer="1" file="xml\dlg_main.xml"/> <resid type="IMGX" name="IDP_MAIN_DLG_FRAME" file="image\dlg_bg_frame.png" /> <resid type="IMGX" name="IDP_BTN_WND_CHECKBOX" file="image\btn_wnd_checkbox.png"/> <resid type="IMGX" name="IDP_BTN_WND_RADIO" file="image\btn_wnd_radio.png" /> <resid type="IMGX" name="IDP_FOCUS_CHECK" file="image\focus_checkbox.png"/> <resid type="IMGX" name="IDP_FOCUS_RADIO" file="image\focus_radio.png" /> <resid type="IMGX" name="IDP_BORDER_EDIT" file="image\img_edit_border.png" /> <resid type="IMGX" name="IDP_BTN_SYS_CLOSE" file="image\btn_sys_close.png" /> <resid type="IMGX" name="IDP_SCROLL" file="image\scrollbar.bmp" />其中主要存放了工程中所要用到的各種類型資源文件命名,DuiEngine支持一下一種資源文件類型定義:
XML:例如我們界面布局文件和樣式文件都是XML類型的
ICO:圖標資源
BMP:位圖資源
IMGX:GDI+圖片資源,當然位圖也可以使用這種類型
細心的朋友可能看到了,在XML類型中name = IDR_DUI_MAIN_DIALOG後面有一個屬性為layer = 1,它的作用我將過會做出說明
Second
-y –p skin
-y表示強制改寫標志(說實話我也沒搞懂什麼意思)
-p表示設置當前路徑為skin目錄下
Three
-r .\duires\winres.rc2
表示將index.xml文件中的內容格式化到資源文件winres.rc2文件中
DEFINE_XML(IDR_DUI_INIT, "skin\\xml\\init.xml") DEFINE_XML(IDR_DUI_MSGBOX, "skin\\xml\\dlg_msgbox.xml") DEFINE_XML(IDR_DUI_MAIN_DIALOG, "skin\\xml\\dlg_main.xml") DEFINE_IMGX(IDP_MAIN_DLG_FRAME, "skin\\image\\dlg_bg_frame.png") DEFINE_IMGX(IDP_BTN_WND_CHECKBOX, "skin\\image\\btn_wnd_checkbox.png") DEFINE_IMGX(IDP_BTN_WND_RADIO, "skin\\image\\btn_wnd_radio.png") DEFINE_IMGX(IDP_FOCUS_CHECK, "skin\\image\\focus_checkbox.png") DEFINE_IMGX(IDP_FOCUS_RADIO, "skin\\image\\focus_radio.png") DEFINE_IMGX(IDP_BORDER_EDIT, "skin\\image\\img_edit_border.png") DEFINE_IMGX(IDP_BTN_SYS_CLOSE, "skin\\image\\btn_sys_close.png") DEFINE_IMGX(IDP_SCROLL, "skin\\image\\scrollbar.bmp")Four
-n .\duires\name2id.xml
表示將index.xml中XML資源中(布局文件XML)且屬性中帶有layer = ''1"中的控件name轉化為相應id存放到當前文件中,我們還記得在index.xml中為IDR_DUI_MAIN_DIALOG設置了layer="1"
所以這裡將根據dlg_main.xml中控件的name屬性生成其id對照存放到name2id.xml文件中
<name2id name="DUI-DEMO" id="65536" /> <name2id name="maindlg" id="65537" /> <name2id name="btn_close" id="1" /> <name2id name="btn_msgbox" id="65538" />
Five
-h .\duires\winres.h
只有在生成項目時選擇了“支持ID系統”才會出現此命令。
/*<------------------------------------------------------------------------------------------------->*/ /*該文件由residbuilder2生成,請不要手動修改*/ /*<------------------------------------------------------------------------------------------------->*/ #define DUI-DEMO 65536 #define maindlg 65537 #define btn_close 1 #define btn_msgbox 65538
Chapter 1: The Sound of the Shell
Piggy and Ralph meet up with each other after escaping from their shot-down plane. A large scar was made in the untouched jungle, symbolizing the first of man's destruction on the island. A war is going on in the outside world, and now for the rest of the book, everyone will be isolated from it and put into their own "world."
Piggy spots a conch shell, and tells Ralph how to use it to make a noise. Ralph does so, and calls all of the other boys on the island who crashed down with the plane. Jack and his Choir, Simon, Sam and Eric, and many other characters join in an assembly (including the littl'uns, which are the youngest kids at about 6 or 7 years old). Rules are set down, and Ralph is to be chief. There is no one else on the island but the young boys, so Jack decides to take his choir out to hunt for wild pigs, although he is unsuccessful in killing a small pig with his knife.
Significance: While Jack's first attempt to kill the pig failed, his quote "next time..." foreshadowed his future of savage hunting.
Chapter 2: Fire on the Mountain
Ralph calls another assembly, and reminds everyone that they are completely alone on the island, and there are no adults. Jack recounts his failure in killing the pig, and reiterates the need for skilled hunters. Several rules are made up, such as "whoever holds the conch gets to speak." Unexpectedly, an unnamed littl'un with a birthmark on his face tells abo......余下全文>>
是啊!但是人家說的是巴赫猜想的那個,不是你說的小學算術。