程式設(shè)計(jì)實(shí)務(wù)使用ppt課件_第1頁
程式設(shè)計(jì)實(shí)務(wù)使用ppt課件_第2頁
程式設(shè)計(jì)實(shí)務(wù)使用ppt課件_第3頁
程式設(shè)計(jì)實(shí)務(wù)使用ppt課件_第4頁
程式設(shè)計(jì)實(shí)務(wù)使用ppt課件_第5頁
已閱讀5頁,還剩243頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、Windows CE 程式設(shè)計(jì)實(shí)務(wù)運(yùn)用 eMbedded Visual BasicChapter 5Outline CommonDialog Control File and File System Controls App and Clipboard Objects MenuBar and ImageList Controls TreeView and ListView Controls Grid Control TabStrip ControlCommonDialog Control 普通檔案處理程式中,我們要開啟舊檔或另存新檔等,處理這些動作的對話框即是 CommonDialog。Com

2、monDialog Properties CancelError:設(shè)定一個(gè)運(yùn)用者按下“取消按鈕時(shí),會不會產(chǎn)生錯誤代碼,預(yù)設(shè)是 False,即不會。 Color:傳回或設(shè)定 CommonDialog 的顏色。 DefaultExt:設(shè)定預(yù)設(shè)的副檔名。 DialogTitle:設(shè)定對話框的標(biāo)題。當(dāng)我們要開啟的對話框是 “Color或“Font時(shí),這個(gè)屬性不會作用。 object.DialogTitle =titleCommonDialog Properties (Cont.) FileName:傳回或設(shè)定所選取檔案的路徑和檔案名稱。 object.FileName=pathname,pathnam

3、e 表示特定的路徑和檔案名稱,假設(shè)在 “Open對話框結(jié)束之後,F(xiàn)ileName=“,則代表運(yùn)用者沒有選取任何一個(gè)檔案。 FileTitle:和 FileName 很像,但 FileTitle 只包含檔案名稱,不包含檔案的路徑。CommonDialog Properties (Cont.) Filter:比如我們希望找的檔案是 *.bmp 檔,則可以把 *.bmp 副檔名設(shè)定在 Filter 中。 Object.Filter =description1|filter1|description2|filter2 CommonDialog1.Filter = CommonDialog1.Filte

4、r = All files|*.* CommonDialog1.Filter = Text files|*.txt“ CommonDialog1.Filter = Bitmaps|*.2bp;*.bmp|Text Files|*.txt CommonDialog Properties (Cont.) FilterIndex:設(shè)定或傳回一個(gè)內(nèi)定的 filter for “Open或 “Save As。內(nèi)定是 1。 Flags:設(shè)定對話框中的選項(xiàng) object.Flags =Value常數(shù)值內(nèi)容cdlCCFullOpen&H2顯示整個(gè)對話框,包括自訂顏色的部分cdlCCPreventFul

5、lOpen&H4Disables the Define Custom Colors command button and prevents the user from defining custom colors cdlCCRGBInit&H1Sets the initial color value for the dialog box CommonDialog Properties (Cont.) Open 和 SaveAs 對話框CommonDialog Properties (Cont.) FontBold,F(xiàn)ontItalic,F(xiàn)ontUnderline,F(xiàn)ontNam

6、e,F(xiàn)ontSize HelpCommand:returns and sets the type of Help requested object.HelpCommand =valueCommonDialog Properties (Cont.) HelpContext:returns and sets the context identifier of a requested Help topic. object.HelpContext =value HelpFile:應(yīng)用程式假設(shè)有 Help 檔,可以將 Help 檔的檔名和路徑指定給這個(gè)屬性。 InitDir:設(shè)定預(yù)設(shè)的目錄 Max,Mi

7、n:可選取字形的最大和最小值。 MaxFileSize:returns and sets the maximum size of the file name opened using the CommonDialog control. 範(fàn)圍是 132KBCommonDialog Methods ShowOpen:顯示 Open 對話框CommonDialog Methods (Cont.) ShowSave:顯示 “Save As 對話框CommonDialog Methods (Cont.) ShowColor:顯示“Color對話框CommonDialog Methods (Cont.)

8、ShowFont:CommonDialog Methods (Cont.) ShowHelp:MiniSeeImageCtlName:imgShowCheckBoxName:chkStretchcmdOpenlblFileNameCommonDialogName:dlgPic tureOpenMiniSee (Cont.)File and FileSystem Controls 在 eVB 中關(guān)於檔案處理有兩個(gè)元件:File 與 FileSystem。File 提供應(yīng)用程式建立檔案,讀寫檔案的功能。FileSystem 提供應(yīng)用程式刪除,複製,搬移檔案及建立/刪除目錄的功能。File Cont

9、rol Properties Attr:獲得 File Control 開啟檔案的方式,並記錄關(guān)於下次 file read/write 的起點(diǎn)位置。 file.Attr常數(shù)值None0fsModeInput1fsModeOutput2fsModeRandom4fsModeAppend8fsModeBinary32File Control Properties (Cont.) EOF:判斷能否已在檔案的結(jié)尾。 Loc:傳回以開啟的檔案中,目前的讀取或?qū)懭氲奈恢谩?Seek:設(shè)定開啟的檔案中,下一個(gè)要讀取或?qū)懭胭Y料位置。 file.Seek =position Seek 值會不斷比 Loc 多 1

10、,但假設(shè)剛開啟一個(gè)檔案,Seek=Loc=1。 Seek 值不可為 0 或負(fù)數(shù)。 File Control Methods Close(): Get:讀取已開啟的檔案 file.Get Data, Recnumber Recnumber:用來指定讀取檔案的位置。假設(shè)是 Random 方式,所用的單位就是 record number。假設(shè)檔案以 binary 方式開啟,則指定的單位便是 byte。 Input:假設(shè)檔案是以“輸入或binary方式開啟時(shí),我們可以運(yùn)用這個(gè)方法來讀取資料。 file.Input (number) number:指定要讀取的字元數(shù)。 傳回是字串方式的值。 通常我們運(yùn)用

11、 Input 讀取檔案時(shí),會運(yùn)用 LinePrint 寫入資料。File Control Methods (Cont.) InputB:假設(shè)檔案是以“輸入或binary方式開啟時(shí),我們可以運(yùn)用這個(gè)方法來讀取資料。 file.Input (number) number:指定要讀取的 byte 數(shù)。 傳回是陣列方式的值。 通常我們運(yùn)用 InputB 讀取檔案時(shí),會運(yùn)用 LinePrint 或 Put 寫入資料。File Control Methods (Cont.) InputFields:讀取已開啟的循序檔 (“輸入或binary方式)。 InputFields(number) number:要

12、讀取欄位之?dāng)?shù)目,欄位之間以頓號做區(qū)隔。 傳回型態(tài)為 variant 的一維陣列。 通常我們運(yùn)用 InputField 讀取檔案時(shí),會運(yùn)用 WriteField 寫入資料。 InputField 讀取內(nèi)容和資料方式有關(guān)資料內(nèi)容讀取的資料內(nèi)容頓號或者是空行無#NULL#Null#TRUE#或#FALSE#TRUE 或 FALSE#yyyy-mm-dd hh:mm:ss#日期或時(shí)間File Control Methods (Cont.) LineInputString:一次會從循序檔案中讀取一行資料,直到復(fù)位 (Chr(13)或復(fù)位加上換行(Chr(13)+Chr(10)字元為止。 file.Lin

13、eInputString Data read with LineInputString usually is written from a file with LinePrint. LinePrint:writes a single line to an open sequential file. file.LinePrint output output:要寫到檔案中的字串 自動在字串後面加上換行與復(fù)位符號。File Control Methods (Cont.) Open: file.Open pathname, mode, access, lock, reclength mode:開啟檔案

14、的方式。1:input,2:output,4:Random,8:Append,32:binary。 access:存取的方式。讀(1),寫(2),讀寫(3,預(yù)設(shè)值) lock:Operations permitted on the open file by other processes: Shared, LockRead, LockWrite Default, and LockReadWrite. (1, 2, 3, 0) reclength:指定資料記錄的長度,32767 byte。假設(shè)檔案是隨機(jī)存取檔,這個(gè)數(shù)值指的是 record 的長度。假設(shè)是普通的循序檔,指的便是字元數(shù)。File C

15、ontrol Methods (Cont.) Put:將一個(gè)變數(shù)內(nèi)容寫進(jìn)檔案中。 file.Put data,recnumber recnumber:Record number (Random mode files) or byte number (Binary mode files) Put 與 Get 是一對 WriteFields:把資料寫入循序檔中 File.WriteFields data 沒有 “data 時(shí)會寫入一個(gè)空行File System Control Methods Dir:依據(jù)我們設(shè)定的條件和屬性,把符合的檔案名稱列出來。 file.Dir (pathname, att

16、ributes) pathname:String expression that specifies a file name or path. 檔案的屬性選項(xiàng)File System Control Methods (Cont.) FileCopy:複製檔案 filesystem.FileCopy PathName,NewPathName FileDateTime:傳回檔案建立的時(shí)間,或者檔案最近修正的時(shí)間 filesystem.FileDateTime(pathname) FileLen:查詢檔案的長度 filesystem.FileLen(pathname)File System Contr

17、ol Methods (Cont.) GetAttr:獲得檔案或目錄的屬性 filesystem.GetAttr(pathname) Kill:刪除檔案 filesystem.Kill Pathname MkDir:建立新目錄 filesystem.MkDir Pathname MoveFile:更改檔案或目錄名稱 filesystem.MoveFile Pathname,NewPathNameFile System Control Methods (Cont.) RmDir:移除目錄 filesystem.RmDir PathName SetAttr:設(shè)定檔案的屬性 filesystem.S

18、etAttr pathname,attributesFile System Control Methods (Cont.)開啟檔案的模式常數(shù)處理檔案的方法InputFsModeInputInput, InputB, LineInputString, InputFieldsOutputFsModeOutputLinePrint, WriteFieldsAppendFsModeAppendLinePrint, WriteFieldsRandomFsModeAppendGet, PutBinaryFsModeBinaryGet, Put, Input, InputBApp Properties Co

19、mments:傳回或設(shè)定應(yīng)用程式的註解 (型態(tài)為字串),執(zhí)行階段為唯讀。 objectments CompanyName:傳回或設(shè)定應(yīng)用程式的所屬的公司名稱或作者姓名,執(zhí)行階段為唯讀。 objectpanyName EXEName:傳回執(zhí)行檔的名稱,不包含副檔名。 Object.EXEName FileDescription:傳回或設(shè)定應(yīng)用程式的檔案說明資訊 (型態(tài)為字串),執(zhí)行階段為唯讀。 LegalCopyRight:傳回或設(shè)定應(yīng)用程式的著作權(quán)資訊 (型態(tài)為字串),執(zhí)行階段為唯讀。App Properties (Cont.) LegalTrademarks:傳回或設(shè)定應(yīng)用程式的商標(biāo)資訊 (

20、型態(tài)為字串),執(zhí)行階段為唯讀。 Major,Minor:傳回或設(shè)定專案版本編號的主要編號與次要編號,執(zhí)行階段為唯讀。This property provides version information about the running application. The values range from 0 through 9,999. Path:以字串方式傳回或設(shè)定應(yīng)用程式目前的路徑 ProductName:傳回或設(shè)定應(yīng)用程式的產(chǎn)品名稱 (型態(tài)為字串),執(zhí)行階段為唯讀。App Properties (Cont.) Revision:傳回或設(shè)定專案版本編號當(dāng)中的修訂資訊,執(zhí)行階段為唯讀。Th

21、e value of the Revision property is in the range from 0 through 9,999. TaskVisible:設(shè)定應(yīng)用程式在執(zhí)行時(shí)能否會出現(xiàn)在 Windows 的任務(wù)清單當(dāng)中,預(yù)設(shè)值是 True。 Title:傳回或設(shè)定應(yīng)用程式的標(biāo)題。App Methods End:結(jié)束應(yīng)用程式 app.End WaitForEvents:使應(yīng)用程式暫停,不斷到事件發(fā)生才繼續(xù)執(zhí)行。 app.WaitForEvents EndWaitForEvents:使因 WaitForEvents 而暫停的應(yīng)用程式繼續(xù)執(zhí)行。Clipboard Methods Clea

22、r:去除 Clipboard 內(nèi)容 object.Clear GetText:傳回一字串,獲得 Clipboard 文字內(nèi)容 clipboard.GetText(format) SetText:把字串放到 Clipboard 中。 clipboard.SetText Data, formatImageList Control Properties ImageList Control 物件可看程式管理小圖形檔的元件,提供其他物件運(yùn)用小圖示的功能。 大部分是和其他控制項(xiàng)一併運(yùn)用,像是 TreeView、CommandBar 和 TabStrip Count:傳回 ImageList 物件當(dāng)中的圖檔

23、數(shù)量。 object.Count ImageWidth,ImageHeight hImageList:returns a handle to an ImageList control. 假設(shè)其他物件想要運(yùn)用 ImageList 物件的話,可以運(yùn)用此屬性來獲得 ImageList 物件的控制權(quán)。ImageList Control Methods Add (ImageList):把圖形加到 ImageList 物件中。 imagelist.Add(filename) 在 eVB 的 ImageList 物件所援助的圖檔格式只需 bmp、dib 及 2bp。 Images can be differ

24、ent sizes, but after you add the first image, all subsequently added images are sized identically to the first. Remove object.Remove(index) index:要被移除的圖檔之索引值。ImageList Control Methods (Cont.) RemoveAll(ImageList) imageList.RemoveAll Replace:更換 ImageList 物件中的一個(gè)圖檔。 imagelist.Replace(index, filename) R

25、eset:移除一切圖形檔,並重新設(shè)定一切的資料。 imagelist.Reset Reset clears the ImageWidth and ImageHeight entries, enabling the control to be used with differently sized images. Note that this also releases the Win32 ImageList handle. ImageList Exampleimglst1PictureBox1Command1ImageList Example (Cont.)MenuBar Control Pr

26、operties Controls Collection:MenuBar 中一切正在運(yùn)用物件的集合。 在 eVB 中,MenuBar 物件運(yùn)用 MenuControls Collection 集合物件來管理 MenuBar 物件中一切的 Menu 和 Button,我們可以藉由 MenuControls Collection 來替 MenuBar 加上 Menu 或 Button。 object.Controls(index) index:Integer with a range from 0 to the number of controls 1MenuBar Control Propert

27、ies (Cont.) ImageList:指定要運(yùn)用的 ImageList 物件。 object.ImageList =hImagelist himagelist:ImageList object 的屬性。 在 MenuBar 中提供兩種 Menu 型式,一種是普通選單式的 Menu,另一種是類似工具列的 Button 型式的 Menu。 在 Button 型式的 MenuBar 型式有兩種,一種是 CommandButton (文字按鈕),另一種是可以運(yùn)用 ImageList 物件提供小圖示的按鈕 (See Example:MiniWord)。MenuBar Control Propert

28、ies (Cont.) Example: Set MenuBar.ImageList = ImageList1.hImageList MenuBar Control Properties (Cont.) NewButton: object.NewButton =Boolean True:我們沒有對 Menu 做任何設(shè)定就自動會有一個(gè) Menu 項(xiàng)目。假設(shè)不需求這個(gè) Menu 項(xiàng)目的話,把這個(gè)屬性設(shè)為 False。MenuBar Control Events ButtonClick:This event occurs when a user clicks on a button on a Men

29、uBar control. Private Sub menubar_ButtonClick(button) button:Copy of an edited Button object on a MenuBar. MenuBar Control Events (Cont.) MenuClick:This event occurs when a user chooses an Item object from a menu on a MenuBar control. Private Sub object_MenuClick(menu) menu:Copy of the chosen Item o

30、bject. NewClick:This event occurs when the New button on a MenuBar control is clicked. Private Sub MenuBar_NewClickMenuControls Collection Properties Item:在 MenuControls collection 當(dāng)中的項(xiàng)目。eVB 運(yùn)用 Items Collection 來管理 Item。 object.Item(index) Count:物件的總數(shù)MenuControls Collection Methods AddButton:adds a

31、MenuControl button to the MenuControls collection of a MenuBar control. MenuBar.Controls.AddButton (key) key:Unique string for the Key property of the new Button. Example: Dim B As MenuBarButton Set B = MenuBar1.Controls.AddButton() B.Style = mbrCheck MenuControls Collection Methods (Cont.) AddMenu:

32、在 MenuControls collection 當(dāng)中參與一個(gè) Menu 物件。 MenuBar.Controls.AddMenu(caption,key) Example: Dim M As MenuBarMenu Set M = MenuBar1.Controls.AddMenu() M.Style = mbrMenuSeparator Clear:去除 MenuControls collection 中一切的物件。 MenuControlsObject.ClearItems Collection Properties Caption: Checked:布林值,This property

33、 returns and sets a value that determines whether a check mark is displayed next to a menu item. Enabled:This property returns and sets a value that determines whether a form or control can respond to user-generated events. Index:This property returns the number that uniquely identifies an object in

34、 a collection. Key:String。Returns and sets a string that uniquely identifies a member in a collection.Items Collection Properties (Cont.) Parent:This property returns the form, object, or collection that contains a control. Style:This property returns and sets the appearance of a button on a MenuBar

35、 control or a menu item on a MenuBar control. object.Style =ValueItems Collection Properties (Cont.) The following table shows the settings for the Style property for a Button on a MenuBar control. Items Collection Properties (Cont.) The following table shows the settings for the Style property for

36、a Menu Item on a MenuBar control. Items Collection Properties (Cont.) SubItems:This property returns an Items collection from an Item on a MenuBar control. Each Item has a SubItems property that returns an Items collection that contains the submenus of the Item. The SubItems property enables the Men

37、uBar to have menus with submenus. Items Collection Properties (Cont.) Tag:This property returns and sets an expression that stores any extra data needed for an application. Visible:This property returns and sets a value that indicates whether an object is visible or hidden.Items Collection This obje

38、ct represents a collection of Menu objects for a MenuBar or CommandBarMenuBar control. Example:MenuBar.Items(index) Count:集合物件中的物件總數(shù) Item:集合物件當(dāng)中的資料項(xiàng)目 Add:在集合物件當(dāng)中參與一個(gè)資料項(xiàng)目 object.Add(index, type, key, caption, style) Key:獨(dú)一無二的字串,用來代表該資料項(xiàng)目 Style:該資料項(xiàng)目的方式Items Collection (Cont.) The possible values for

39、the type parameter Example: Dim B As CommandBarButton Set B = CommandBar1.Controls.Add(cbrButton) B.Style = cbrCheckItems Collection (Cont.) Add:This method adds a menu bar Item object to the MenuItems collection of a MenuBar control. items.Add(index, key, Caption, style) style:資料項(xiàng)目的方式Items Collecti

40、on (Cont.) Clear:This method clears the contents of a ListBox object, ComboBox object, or the system Clipboard object. object.Clear Remove:移除一項(xiàng)資料項(xiàng)目 object.Remove(index)MenuBarButton Object Properties Image:sets the image associated with an object. object.Image=value value:指定要運(yùn)用 ImageList 物件當(dāng)中的第幾張圖 S

41、tyle:設(shè)定 MenuBarButton Object 的型態(tài) object.Style=value value:按鈕型態(tài)MenuBarButton Object Properties (Cont.)MenuBarButton Object Properties (Cont.) MixedState:This property causes a Button object to appear shaded. object.MixedState=value (boolean) ToolTip:設(shè)定當(dāng)滑鼠移動到按鈕上方時(shí)會顯示的提示文字。 object.ToolTip =String Value

42、:獲得或設(shè)定按鈕目前的狀況 object.Value =valueMenuBarButton Object Properties (Cont.)MenuBar 範(fàn)例menubarMenuBar 範(fàn)例 (Cont.)itemsMenuBar 範(fàn)例 (Cont.)subitemsMenuBar 範(fàn)例 (Cont.)MenuBarName:mnuMenuMenuBar 範(fàn)例 (Cont.)MenuBar 範(fàn)例 (Cont.) 在 MenuBar 上有三個(gè) Menu,為 New,F(xiàn)ile 和 Edit,因?yàn)?New 是預(yù)設(shè)的項(xiàng)目,所以我們只需再新增另兩個(gè) Menu 項(xiàng)目即可。 接著在 File 這個(gè)

43、Menu 項(xiàng)目下參與 4 個(gè)資料項(xiàng)目:Open、Add、分隔線及 delete。 同樣我們在 Edit 這個(gè) Menu 項(xiàng)目下參與 Copy、Cut、Paste 和 find。 在 Paste 資料項(xiàng)目下參與兩個(gè)子項(xiàng)目 (subitem),也是用 Add。MenuBar 範(fàn)例 (Cont.)MenuBar 範(fàn)例 (Cont.) 我們用的是 Menu 型式的 MenuBar,所以運(yùn)用者選擇資料項(xiàng)目引發(fā)的事件是 MenuClick。 參數(shù) Item 型態(tài)為 MenuBar.Item,指的是運(yùn)用者所選擇的項(xiàng)目。範(fàn)例:Button 型式的 Menu範(fàn)例:Button 型式的 Menu (Cont.)範(fàn)

44、例:Button 型式的 Menu (Cont.)範(fàn)例:Button 型式的 Menu (Cont.)MenuBarName:mnbButton範(fàn)例:Button 型式的 Menu (Cont.)範(fàn)例:Button 型式的 Menu (Cont.) 我們運(yùn)用 AddButton 在 MenuBar 中參與按鈕。 因?yàn)榧拥?MenuBar 物件的是按鈕,所以運(yùn)用者引發(fā)的事件為 ButtonClick。 參數(shù) Button 為運(yùn)用者按下的按鈕。Example:MiniWordExample:MiniWord (Cont.)Example:MiniWord (Cont.)FileName: File

45、1FileSystemName: FileSys tem1MenuBarName: mnb ButtonImageListName: ilsALLI ConsCommonDialogName: dlg FileTextBoxName: tex TextLabelName: lbl FileNameExample:MiniWord (Cont.)Example:MiniWord (Cont.)Example:MiniWord (Cont.)Example:MiniWord (Cont.)Example:MiniWord (Cont.)Example:MiniWord (Cont.)Example

46、:MiniWord (Cont.)Example:MiniWord (Cont.)Example:MiniWord (Cont.) 運(yùn)用 ilsALLICons 物件的 Add 把所要顯示的圖檔加到 ImageList 物件當(dāng)中。 將 ilsALLICons 的 hImageList 屬性設(shè)定給 MenuBar 物件 mnbButton 的 ImageList 屬性。 利用 AddButton 把按鈕一個(gè)一個(gè)參與 MenuBar 中。順便設(shè)定 Button 的 Image 屬性,用來指定所運(yùn)用的圖檔。 mbuButton.Controls.AddButton.Enabled= False,產(chǎn)生

47、一個(gè)按鈕空格。假設(shè)我們只想產(chǎn)生一個(gè)分隔線的話,可以把 Button Style 設(shè)成 mbrSeparator,這樣就可以在按鈕間產(chǎn)生分隔線。Example:MiniWord (Cont.) 當(dāng)運(yùn)用者按下“開新檔案按鈕時(shí),假設(shè)文字框中還有文字,必須提示運(yùn)用者存檔,然後再開啟新檔。 ShowSave:This method displays the Save As dialog box of the CommonDialog control. 假設(shè)運(yùn)用者在對話框中輸入檔名(strFileName 不是空字串),則進(jìn)行存檔的動作 (呼叫本人寫的 SaveFile)。假設(shè)沒有輸入檔名,則將文字框內(nèi)容

48、去除。假設(shè)本來就有檔名存在,則直接呼叫 SaveFile。Example:MiniWord (Cont.) 當(dāng)運(yùn)用者按下“開舊檔案按鈕時(shí),假設(shè)文字框中有文字,則我們必須先處理存檔的問題,才干再開啟舊檔。處理完後呼叫 OpenFile 開啟舊檔。 首先先運(yùn)用對話框讓運(yùn)用者選擇要開啟的文字檔。開檔讀檔的動作交給 File1 來處理。我們運(yùn)用 fsModeInput 方式開啟舊檔。 運(yùn)用 LineInputString 一行一行讀資料,把讀到的資料先暫存在 strTempRead 字串當(dāng)中。再加上換行和復(fù)位字元,最後 strTemp 所存放的便是被讀取的文字檔之一切內(nèi)容。Example:MiniWo

49、rd (Cont.) 當(dāng)運(yùn)用者按下“儲存檔案按鈕時(shí),假設(shè)本來運(yùn)用者沒有輸入檔名,則跳出SaveAs 對話框讓運(yùn)用者可以輸入檔名。假設(shè)本來就有檔名,則直接呼叫 SaveFile 程序。 當(dāng)運(yùn)用者按下“複製按鈕時(shí),先用 Clear 把 Clipboard 原先內(nèi)容清掉。而 TextBox 物件的 SelText 就是運(yùn)用者所選取的文字。 當(dāng)運(yùn)用者按下“剪下按鈕時(shí),動作與按下“複製按鈕時(shí)差不多。Example:MiniWord (Cont.) 當(dāng)運(yùn)用者按下“貼上按鈕時(shí),我們運(yùn)用 Clipboard 的 GetText 方法把存放在 Clipboard 的文字取出。 SaveFile 程序用來儲存檔案

50、。假設(shè)先前同名的檔案存在,則先呼叫 Kill 刪除以前的檔案。 儲存檔案時(shí)把文字框 txtText 內(nèi)容先放在 strTemp 中。再用 fsModeOutput 開啟檔案,運(yùn)用 LinePrint 把字串 strTemp 寫到檔案中。Example:MiniWord (Cont.) 當(dāng)運(yùn)用者按下右上角“OK按鈕時(shí),我們要留意文字框中的文字能否已經(jīng)存檔。處理步驟類似按下“開新檔案。 當(dāng)運(yùn)用者有啟動輸入面版 (SIP) 時(shí),我們把文字框的高度縮短,方便運(yùn)用者輸入資料,輸入面版才不會擋到文字框,反之則放大文字框。這在 SIPChange 程序中執(zhí)行。 bSIPVisible=TRUE,代表運(yùn)用者啟

51、動 SIP 面版。TreeView Control Properties TreeView Controls 運(yùn)用 Nodes Collection 來管理當(dāng)中的資料項(xiàng)目(Node 物件)。 HideSelection:決定當(dāng)物件失焦時(shí),本來選取的文字能否要繼續(xù)以明顯的方式顯示。TRUE 代表當(dāng)物件失去焦點(diǎn)時(shí),便不再以明顯的方式顯示本來選取的文字。 object.HideSelection ImageList:指定所要運(yùn)用的 ImageList 物件。 object.ImageList =hImagelistTreeView Control Properties (Cont.) Identat

52、ion:傳回或設(shè)定 TreeView Control 物件的縮排寬度 object.Identation =number LabelEdit:設(shè)定運(yùn)用者能否可以自行更改 TreeView 物件當(dāng)中的資料項(xiàng)目的標(biāo)籤。 object.LabelEdit =integer數(shù)值內(nèi)容0 (預(yù)設(shè)值)自動。當(dāng)使用者在 TreeView 物件當(dāng)中選取資料項(xiàng)目時(shí),就會產(chǎn)生 BeforeLabelEdit Event1(lvwManual/tvwManual)手動。只有在使用 StartLabelEdit 方法時(shí),才會產(chǎn)生 BeforeLabelEdit EventTreeView Control Propert

53、ies (Cont.) LabelEdit 屬性和 StartLabelEdit 方法常並用,我們可以設(shè)定什麼時(shí)候可以更改資料項(xiàng)目的標(biāo)籤。 LineStyle:設(shè)定資料項(xiàng)目間的線條型式 object.LineStyle =number數(shù)值內(nèi)容0 (預(yù)設(shè)值)在資料項(xiàng)目間,只會顯示子節(jié)點(diǎn)和父節(jié)點(diǎn)之間的線條1除了子節(jié)點(diǎn)和父節(jié)點(diǎn)之間的線條外,還會顯示節(jié)點(diǎn)到根節(jié)點(diǎn)間的線條TreeView Control Properties (Cont.) PathSeparator:用來設(shè)定分隔路徑的字串。預(yù)設(shè)值是。 object.PathSeparator =string SelectedItem:這個(gè)屬性會傳回被

54、選取物件的 reference。 object.SelectedItem Sorted:設(shè)定 TreeView 物件當(dāng)中的資料項(xiàng)目要不要依英文字母次序陳列。 object.Sorted =BooleanTreeView Control Properties (Cont.) Style:設(shè)定物件的顯示型態(tài) object.Style =numberTreeView Control Methods GetVisibleCount:用來設(shè)定 TreeView 顯示區(qū)域當(dāng)中可以顯示資料項(xiàng)目的個(gè)數(shù)。 treeview.GetVisibleCount Note that the return value i

55、s the number of items that can be fully visible. If you can see all of 20 items and part of one more item, the return value is 20. StartLabelEdit:讓運(yùn)用者開始編輯 TreeView 物件當(dāng)中資料項(xiàng)目的標(biāo)籤。 control2.StartLabelEditTreeView Control Events BeforeLabelEdit:當(dāng)運(yùn)用者要開始修正資料項(xiàng)目的標(biāo)籤時(shí)會引發(fā)此事件。 AfterLabelEdit:當(dāng)運(yùn)用者始修正資料項(xiàng)目的標(biāo)籤後會引發(fā)此事

56、件。 Expand:當(dāng)運(yùn)用者展開一個(gè)父節(jié)點(diǎn)下面的資料項(xiàng)目時(shí)會引發(fā)此事件。 Collapse:當(dāng)運(yùn)用者關(guān)閉(折疊)一個(gè)父節(jié)點(diǎn)下面一切的資料項(xiàng)目時(shí)會引發(fā)此事件。 NodeClick:當(dāng)運(yùn)用者選擇 Node 物件時(shí)會引發(fā)此事件。Nodes Collection Properties TreeView Object 運(yùn)用 Nodes Collection 物件來管理眾多的資料項(xiàng)目。 Nodes Collection 屬性 Count:傳回 Nodes Collection 物件當(dāng)中存放的物件總數(shù) object.Count Item:物件當(dāng)中的資料項(xiàng)目。 object.Item(index)Nodes

57、Collection Methods Add:在 Nodes Collection 中參與一個(gè) Node 物件 (資料項(xiàng)目) Nodes.Add(relative,relationship,key,text,image,selectedimage) relative:The key of a pre-existing Node object or a Node object. The relationship between the new node and this pre-existing node is found in the relationship parameter. Nodes

58、 Collection Methods (Cont.) relationship:即將要參與的心結(jié)點(diǎn)與舊節(jié)點(diǎn)的關(guān)係。Nodes Collection Methods (Cont.) key:Unique string expression that can be used to access a member (資料項(xiàng)目)of the Nodes collection. text:顯示的文字 image:用來指定所要用的圖檔(圖檔存放在 ImageList 中)。Integer that sets the icon to be displayed from the ImageList cont

59、rol associated with the TreeView control. selectedimage:用來指定當(dāng)運(yùn)用者選擇此節(jié)點(diǎn)時(shí)要顯示的圖檔(圖檔存放在 ImageList 中)。Nodes Collection Methods (Cont.) Clear:移除 collection 中一切資料項(xiàng)目 object.Clear Remove:一次只移除一個(gè)資料項(xiàng)目 object.Remove (index) index:所要移除物件的索引值Node Object Properties Child:獲得子節(jié)點(diǎn)當(dāng)中,第一個(gè)子節(jié)點(diǎn)的 reference。 node.Child Childr

60、en:傳回子點(diǎn)的個(gè)數(shù) treeview.Children Expanded:設(shè)定或獲得物件展開的狀況。當(dāng)這個(gè)屬性值為 True,代表這個(gè)物件被展開。 node.Expanded =valueNode Object Properties (Cont.) ExpandedImage:設(shè)定或獲得當(dāng)這節(jié)點(diǎn)被展開時(shí),要運(yùn)用 ImageList 物件當(dāng)中的哪一個(gè)圖檔。 object.ExpandedImage =value value:integer, 用來指定要運(yùn)用 ImageList 物件當(dāng)中的哪一張圖。 FirstSibling:傳回同一個(gè)階層中的第一個(gè) Node 物件的 reference。 node.FirstSi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論