国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

走近VB.Net(一),VB中的族,類,對象(摘錄部分MSDN)

2024-07-10 13:01:18
字體:
來源:轉載
供稿:網友
走近vb.net(一),vb中的族,類,對象
vb.net是面向對象(object-oriented)的,又稱為物件(object)導向(oriented)。在vb.net中所有的變量類型都是基于object,而不是variantdim x as variant 會被升級為 dim as object。如果你不理解對象,暫時你可以把他理解為一段數據,他是實際存在于內存的,所以對象以稱為實例(instance)而類(class)就是類別,他定義一群對象,是一個對象的群體,并定義方法成員。所以類只是一個定義,只有在被聲明為實例的對象(object instance)時才能具體 的調用。 你在調用其他的類成員時,彈出錯誤的對話框要求“object instace”,是因為沒有聲明一個實例的對象,你用類似聲明變量的方法聲明他們。如:dim formn as new form2 調用form2的成員方法new建立了一個對象的實例。你添加了一個窗體而并不能在程序中顯示出來,是作為一個類,它并不實際存在。而現在使用formn.visible=true 就可以象以前一樣調用,所以條條大路通北京。只是一個概念的轉變,vb在幕后還是以前的vb。這個可能有人會反駁我反vb的變量稱為對象,如果你把變量作為一個指針,不如把他看作一個變量 如:dim s as string :dim in as integer :in=123:s=in.tostring(注意vb用“:” 示換行)。in是一個變量,在基于integer的類中已定義了tostring的方法。在現在的vb中所有的方法都以這種方式內嵌于不同的類。甚至包括所有的api。雖然vb仍然支持象以前一樣地使用api,除了常用的32位數據類型long應被換為integer(msdn中稱32位是最快的 )。你會感覺不方便,甚至不能達到目的。這是因為vb.net認為你不可能再使用api,而只有形式上的支持。
在vb.net中引入了“族”的的術語,即namespace,一般譯為名稱空間,思考了幾個小時,我個人認為在net中應該譯為族比較合適,名字的集合示意在于對象的空間,族適用于任何對象的空間,在萬事萬物皆比族而分,在人亦如此。故有“非我族類,其心必異” 之語。族不離類,類不離族,族居類之上。大家可以斟酌一下,看是不是有些道理。
在vb.net中把父類定義為族 ,已定義的族有很多,如system是最常用的族,system中包含的類幾乎包容了系統的方方面面,而system較常用的子族有winforms(窗體),drawing(圖形). 待定義的如一個工程,新建一個工程,工程名就是族名。
因為winforms.form類,drawing.bitmap類是最常用的,而vs7中查找的速度實在太慢,我把他摘錄在下面:當然如果你的英文很好,可以到msdn中去查找,因為是集成的ide,如果誰能把vb的幫助整理出來就好了,我對運用成員的方法作了一些初步的探索,我希望有英文好一點的把下面的一段英文譯出來,如果這樣的話,任何一個初學者,即使不懂英文,看了我的系列文章。對照下面的winforms.form成員表,drawing.bitmap成員表,能力強的一定可以在幾天的內初步掌握vb.net。.新建一個工程,默認的就會有對winforms.form與 drawing.bitmap的聲明。這個也是實現windows的圖形界面的最重要的圖徑。


一。system.winforms.form 的成員(form members)

[注:
1.凡注明“to be supplied”是msdn準備在將來提供的空的文檔(大部分文檔都是空缺的),所以沒有翻譯
2.我只能翻譯一些常用項目,不是我懶,我沒有任何中文的參考,如果弄錯了就不太好
3.凡注明“instance”的是要求對象實例,在拙作《vb.net問題集》有詳細的解釋
4.其他如共享定義,基本語法等在我的系列文章中有詳細的介紹,這是就不必要重復了
.................]

(一)。靜態共享的屬性[public static (shared) properties]

activeform:返回當前的活動窗體( gets the currently active form for this application.)

(二)。對象構造器(public instance constructors)

form constructor:初始化一個新的實例( initializes a new instance of the form class.)

(三)。公用的對象(實例)屬性(public instance properties)

acceptbutton: indicates the button control on the form that when clicked, performs an action equivalent to when the user presses the enter key.

accessibilityobject: (inherited from richcontrol) [to be supplied.]

accessibledefaultactiondescription: (inherited from richcontrol) the default action description of the control

accessibledescription: (inherited from richcontrol) the accessible description of the control

accessiblename: (inherited from richcontrol) the accessible name of the control

accessiblerole: (inherited from richcontrol) the accessible role of the control

activecontrol: (inherited from containercontrol) indicates the active control on the container control.

activemdichild: gets the active multiple document interface (mdi) child window.

allowdrop: (inherited from richcontrol) the allowdrop property. if allowdrop is set to true then this control will allow drag and drop operations and events to be used.

allowtransparency: (inherited from richcontrol) [to be supplied.]

anchor: (inherited from richcontrol) the current value of the anchor property. the anchor property determines which edges of the control are anchored to the container's edges.

autoscale: gets or sets a value indicating whether the form adjusts its size and scale its control to fit the height of the font used on the form.

autoscroll: gets or sets a value indicating whether the form implements autoscrolling.

autoscrollmargin: (inherited from scrollablecontrol) gets or sets the size of the auto-scroll margin.

autoscrollminsize: (inherited from scrollablecontrol) gets or sets the mimimum size of the auto-scroll.

autoscrollposition: (inherited from scrollablecontrol) gets or sets the location of the auto-scroll position.

backcolor: the background color of this control. this is an ambient property and will always return a non-null value.
backcolor設置窗體的背景色。

backgroundimage: (inherited from richcontrol) the background image of the control.
backgroundimage設置窗體的背景圖片

bindingmanager: (inherited from richcontrol) [to be supplied.]

bindings: (inherited from richcontrol) retrieves the bindings for this control.

borderstyle: gets or sets the border style of the form.
borderstyle設置窗體的外觀(邊框,標題欄)

bottom: (inherited from control) the bottom coordinate of this control.

bounds: (inherited from control) the bounds of this control. this is the window coordinates of the control in parent client coordinates.

cancelbutton: gets or sets the button control that when clicked, performs an action equivalent to when the user presses the esc key.這個是設定哪一個button按鈕響應esc鍵

canfocus: (inherited from control) indicates whether the control can receive focus. this property is read-only. 指定控件是否可以接受焦點,read-only表示他是只讀的。不能在運行期間修改。

canselect: (inherited from control) indicates whether the control can be selected. this property is read-only.
指定控件是否可以被選定,read-only表示他是只讀的。不能在運行期間修改。

capture: (inherited from control) indicates whether the control has captured the mouse.

這個返回一個布爾值,指定是否捕獲鼠標。通常我們要移動一個無標題欄的窗體,需要在按下鼠標的時候放鼠標捕獲

如:me.capture=false. 他的作用跟vb6的api 函數---releasecapture 。不過用起來方便得多

causesvalidation: (inherited from control) indicates whether entering the control causes validation on the controls requiring validation.

clientrectangle: (inherited from control) the client rect of the control.
用戶界面屬性

clientsize: gets or sets the size of the client area of the form.
用戶界面尺寸

companyname: (inherited from richcontrol) retrieves the company name of this specific component.

containsfocus: (inherited from control) indicates whether the control or one of its children currently has the system focus. this property is read-only.

contextmenu: (inherited from richcontrol) the contextmenu associated with this control. the contextmenu will be shown when the user right clicks the mouse on the control.
指定在右鍵彈擊時彈出那一個菜單,一般可以在屬性窗口的下拉列表中選定

controlbox: gets or sets a value indicating whether a control box is displayed in the title bar of the form.

controls: (inherited from control) collection of child controls.

created: (inherited from control) indicates whether the control has been created. this property is read-only.

cursor: (inherited from richcontrol) retrieves the cursor that will be displayed when the mouse is over this
control. 自定義光標。

定義當鼠標在控件上方的光標樣式

desktopbounds: gets or sets the size and location of the form on the windows desktop.
返回或設置窗體在桌面的范圍

desktoplocation: gets or sets the location of the form on the windows desktop.
返回或設置窗體在桌面的位置

dialogresult: gets or sets the dialog result for the form.

displayrectangle: (inherited from control) returns the client rect of the display area of the control. for the base control class, this is identical to getclientrect. however, inheriting controls may want to change this if their client area differs from their display area.
窗體顯示區塊

disposed: (inherited from control) indicates whether the control has been disposed. this property is read-only.是否這個控件已被清除


disposing: (inherited from control) indicates whether the control is in the process of being disposed. this property is read-only.

dock: (inherited from richcontrol) the dock property. the dock property controls to which edge of the container this control is docked to. for example, when docked to the top of the container, the control will be displayed flush at the top of the container, extending the length of the container.

dockpadding: (inherited from scrollablecontrol) gets the dock padding settings for all edges of the control.

enabled: (inherited from control) indicates whether the control is currently enabled.

focused: (inherited from control) indicates whether the control has focus. this property is read-only.
窗體是否已失去焦點

font: (inherited from richcontrol) retrieves the current font for this control. this will be the font used by default for painting and text in the control.
字體

forecolor: (inherited from richcontrol) the foreground color of the control.
前景色(字體顏色)

handle: (inherited from control) the hwnd handle that this control is bound to. if the handle has not yet been created, this will force handle creation.

handle 返回控件的句柄

height: (inherited from control) the height of this control
窗體高度

helpbutton: gets or sets a value indicating whether a help button is displayed in the title bar of the form.

icon gets or sets the icon for the form.

imemode: (inherited from richcontrol) specifies a value that determines the ime (input method editor) status of the object when that object is selected.
指定一個控件被用戶選定時默認活動的輸入法

invokerequired: (inherited from richcontrol) [to be supplied.]

isaccessible: (inherited from richcontrol) indicates whether or not this control is an accessible control i.e. whether it should be visible to accessibility applications.

ishandlecreated: (inherited from control) whether or not this control has a handle associated with it.

ismdichild: gets a value indicating whether the form is a multiple document interface (mdi) child form.

ismdicontainer: gets or sets a value indicating whether the form is a container for multiple document interface (mdi) child forms.

keypreview: gets or sets a value indicating whether the form receives key events before the event is passed to the control that has focus.這個與vb6的樣,返回或設置一個值,指定是否在控件鍵盤事件發生前執行窗體的鍵盤事件

left: (inherited from control) the left coordinate of this control.

控件左邊的坐標距離

location: (inherited from control) the location of this control.
位置

maximizebox: gets or sets a value indicating whether the maximize button is displayed in the title bar of the form.

mdichildren: gets an array of forms that represent the multiple document interface (mdi) child forms that are parented by this form.

mdiparent: indicates the multiple document interface (mdi) parent form of this form.

menu: gets or sets the mainmenu that is displayed in the form.
設置窗體使用哪一個主菜單

mergedmenu gets the merged menu for the form.

minimizebox gets or sets a value indicating whether the minimize button is displayed in the title bar of the form.

modal gets a value indicating whether this form is displayed modally.
是否一個窗體是模態窗體。

opacity: (inherited from richcontrol) [to be supplied.]

opacity的作用不小,設置窗體的透明程度,如me.opacity=0.68

ownedforms gets an array of form objects that represents all forms that are owned by this form.

owner gets or sets the form that owns this form.

parent (inherited from control) the parent of this control.

parentform the form that is the parent of this form.

productname (inherited from richcontrol) retrieves the product name of this specific component.

productversion (inherited from richcontrol) retrieves the product version of this specific component.

recreatinghandle (inherited from control) indicates whether the control is currently recreating its handle. this property is read-only.

region (inherited from richcontrol) the region associated with this control. (defines the outline/silhouette/boundary of control)

region 是構造窗體的外觀了,這在我的文章《走近vb.net(十一)隨心所欲窗體外觀中》有具體的用法

right (inherited from control) the right coordinate of the control.
窗體右坐標

righttoleft (inherited from richcontrol) this is used for international applications where the language is written from righttoleft. when this property is true, control placement and text will be from right to left.

showfocuscues (inherited from control) indicates whether the user interface is in a state to show or hide focus rectangles. this property is read-only.

showintaskbar indicates whether a form is displayed in the windows taskbar.
設置是否顯示在windows的任務欄

showkeyboardcues (inherited from control) indicates whether the user interface is in a state to show or hide keyboard accelerators. this property is read-only.

site (inherited from marshalbyrefcomponent) gets or sets the site of the component.

size gets or sets the size of the form.

sizegripstyle gets or sets the style of sizing handle to display in the lower-right corner of the form.

startposition gets or sets the initial position of the form at run time.
返回或設置窗體啟動時的位置

tabindex (inherited from control) the tab index of this control.
tab鍵的排序

tabstop (inherited from control) indicates whether the user can give the focus to this control using the tab key. this property is read-only.
是否接受tab鍵的焦點,這也是一個只讀屬性

text (inherited from control) the current text associated with this control.
所顯示的文本內容

top (inherited from control) top coordinate of this control
頂點坐標.

toplevel gets or sets a value indicating whether to display the form as a top-level window.

toplevelcontrol (inherited from control) the top level control that contains this control. this doesn't have to be the same as the value returned from getform since forms can be parented to other controls.

topmost gets or sets a value indicating whether the form is displayed as the top-most form of your application.
topmost定義是否使一個窗體是否始終在最前面顯示

transparencykey gets or sets the color that represents transparent areas on the form.

visible gets or sets a value indicating whether the form is visible.
返回或設置一個控件是否可見。

width (inherited from control) the width of this control.
控件的寬度

windowstate gets or sets the form's window state.
返回或設置窗體當前狀態

(四)公用的對象(實例)方法(public instance methods)

activate activates the form and gives it focus.
激活窗體

activatecontrol (inherited from containercontrol) activates a specified control.
激活指定的控件

addownedform adds an owned form to this form.

begininvoke (inherited from richcontrol) overloaded. [to be supplied.]

bringtofront (inherited from control) brings this control to the front of the zorder.

callwndproc (inherited from control) dispatch the method to this window's wndproc directly.

close closes the form.
關閉這個窗體

contains (inherited from control) verifies if a control is a child of this control.

createcontrol (inherited from control) forces the creation of the control. this includes the creation of the handle, and any child controls.

creategraphics (inherited from richcontrol) overloaded. [to be supplied.]


dispose (inherited from containercontrol) disposes of the resources (other than memory) used by the containercontrol.釋放占用的資源

dodragdrop (inherited from richcontrol) begins a drag operation. the allowedeffects determine which drag operations can occur. if the drag operation needs to interop with applications in another process, data should either be a base managed class (string, bitmap, or metafile) or some object that implements system.componentmodel.ipersistable. data can also be any object that implements system.winforms.idataobject.

endinvoke (inherited from richcontrol) retrieves the return value of the asynchronous operation represented by the iasyncresult interface passed. if the async operation has not been completed, this function will block until the result is available.

equals (inherited from object) determines whether the specified object is the same instance as the current object.

findform (inherited from richcontrol) retrieves the form that this control is on. the control's parent may not be the same as the form.

focus (inherited from control) sets focus to the control. attempts to set focus to this control.

設置控件的焦點,不要告訴我知道!

getchildatpoint (inherited from control) retrieves the child control that is located at the specified client coordinates.

getcontainer (inherited from marshalbyrefcomponent) gets the container for the component.

getcontainercontrol (inherited from control) returns the closest containercontrol in the control's chain of parent controls and forms.

getdesignmode (inherited from marshalbyrefcomponent) gets a value indicating whether the component is currently in design mode.

gethashcode (inherited from object) serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

getlifetimeservice (inherited from marshalbyrefobject) this method is used return a lifetime service object that is used to control the lifetime policy to the object. for the default lifetime service this will be an object of type ilease.

getnextcontrol (inherited from control) retrieves the next control in the tab order of child controls.

getserviceobject (inherited from marshalbyrefcomponent) gets the implementer of the iserviceobjectprovider.

gettype (inherited from object) gets the type of the object.
返回一對象的類

hide (inherited from control) hides the control by setting the visible property to false;
隱藏一控件

initializelifetimeservice (inherited from marshalbyrefobject) object can provide their own lease and so control their own lifetime. they do this by overriding the initializelifetimeservice method provided on marshalbyrefobject

invalidate (inherited from control) overloaded. [to be supplied.]

invoke (inherited from richcontrol) overloaded. [to be supplied.]

layoutmdi arranges the multiple document interface (mdi) child forms of this form.

performlayout (inherited from control) overloaded. [to be supplied.]

pointtoclient gets the client coordinates for a specified location.
返回一個用戶界面的坐標

pointtoscreen gets the screen coordinates for a specified location.

返回一個屏幕坐標

preprocessmessage (inherited from control) called by the application's message loop to pre-process input messages before they are dispatched.

rectangletoclient gets the client coordinates and size of a specified rectangle.
返回一個矩形的用戶界面坐標

rectangletoscreen gets the client coordinates and size for a specified rectangle.
返回一個一個矩形的屏幕坐標

refresh (inherited from control) forces the control to invalidate and immediately repaint itself and any children. 重畫窗體

removeownedform removes a form from the list of owned forms. also sets the owner of the removed form to a null reference (in visual basic nothing).

resetbackcolor (inherited from richcontrol) resets the back color to be based on the parent's back color.

resetbindings (inherited from richcontrol) [to be supplied.]

resetcursor (inherited from richcontrol) [to be supplied.]

resetfont (inherited from richcontrol) resets the font to be based on the parent's font.

resetforecolor (inherited from richcontrol) resets the fore color to be based on the parent's fore color.

resetrighttoleft (inherited from richcontrol) resets the righttoleft to be the default.

resettext (inherited from control) resets the text to it's default value.

resumelayout (inherited from control) overloaded. resumes normal layout logic.

scale (inherited from control) overloaded. scales the control and any child controls.

select (inherited from control) activates this control.

selectnextcontrol (inherited from control) selects the next control following ctl.

sendmessage (inherited from control) overloaded. sends a win32 message to the control.

sendtoback (inherited from control) sends this control to the back of the z-order

setautoscrollmargin (inherited from scrollablecontrol) sets the size of the auto-scroll margins.

setbounds (inherited from control) overloaded. sets the bounds of the control.

setclientsize (inherited from control) sets the height and width of the client area of the control.

setdesktopbounds sets the bounds of the form in desktop coordinates.

setdesktoplocation sets the location of the form in desktop coordinates.

setlocation (inherited from control) sets the location of this control.

setnewcontrols arranges an array of controls on a form.

setsize (inherited from control) sets the size of this control.

shouldpersistautoscrollmargin (inherited from scrollablecontrol) indicates whether the autoscrollmargin property should be persisted.

shouldpersistautoscrollminsize (inherited from scrollablecontrol) indicates whether the autoscrollminsize property should be persisted.

shouldpersistautoscrollposition (inherited from scrollablecontrol) indicates whether the autoscrollposition property should be persisted.

shouldpersistbackcolor indicates whether the backcolor property should be persisted.

shouldpersistbindings (inherited from richcontrol) [to be supplied.]

shouldpersistcursor (inherited from richcontrol) returns true if the cursor should be persisted in code gen.

shouldpersistfont (inherited from richcontrol) returns true if the font should be persisted in code gen.

shouldpersistforecolor indicates whether the forecolor property should be persisted.

shouldpersisticon indicates whether the icon property should be persisted.

shouldpersistlocation (inherited from control) determines if the location property needs to be persisted.

shouldpersistrighttoleft (inherited from richcontrol) returns true if the righttoleft should be persisted in code gen.

shouldpersistsize (inherited from control) determines if the size property needs to be persisted.

shouldpersisttext (inherited from control) determines if the text property needs to be persisted.

shouldpersisttransparencykey indicates whether the transparencykey property should be persisted.

show (inherited from control) makes the control display by setting the visible property to true

showdialog overloaded. displays this form as a modal dialog box.

suspendlayout (inherited from control) suspends the layout logic for the control.

tostring (inherited from object) returns a string that represents the current object.

update (inherited from control) forces the control to paint any currently invalid areas.

validate (inherited from containercontrol) validates the last unvalidated control and it's ancestors up through, but not including, the current control.

(五)公用的對象(實例)事件(public instance events):

千萬不要跟我說不懂什么是事件(用戶操作,如單擊-click,鼠標離開mouseleave,請參考vb6 資料)

不過象mouseleave以前是沒有的,還有參數也不同,我的相關文章寫得很清楚,這一節就跳過

activated occurs when the form is activated in code or by the user.

changeuicues (inherited from control) occurs when focus or keyboard or both cues have changed.

click (inherited from control) occurs when the control is clicked.

closed occurs when the form is closed.

closing occurs when the form is closing.

controladded (inherited from control) occurs when a new control is added.

controlremoved (inherited from control) occurs when a control is removed.

deactivate occurs when the form loses focus and is not the active form.

doubleclick (inherited from control) occurs when the control is double clicked.

dragdrop (inherited from richcontrol) [to be supplied.]

dragenter (inherited from richcontrol) [to be supplied.]

dragleave (inherited from richcontrol) [to be supplied.]

dragover (inherited from richcontrol) [to be supplied.]

enter (inherited from control) occurs when the control is entered.

givefeedback (inherited from richcontrol) [to be supplied.]

gotfocus (inherited from control) occurs when the control receives focus.

handlecreated (inherited from control) occurs when a handle is created for the control.

handledestroyed (inherited from control) occurs when the control's handle is destroyed.

helprequested (inherited from richcontrol) [to be supplied.]

inputlangchange occurs after the input language of the form has changed.

inputlangchangerequest occurs when the the user attempts to change the input language for the form.

invalidated (inherited from richcontrol) [to be supplied.]

keydown (inherited from control) occurs when a key is pressed down while the control has focus.

keypress (inherited from control) occurs when a key is pressed while the control has focus.

keyup (inherited from control) occurs when a key is released while the control has focus.

layout (inherited from control) occurs when a control's layout properties have been changed.

leave (inherited from control) occurs when the control is left.

lostfocus (inherited from control) occurs when the control loses focus.

mdichildactivate occurs when a multiple document interface (mdi) child form is activated or closed within an mdi application.

menucomplete occurs when a menu in a form loses focus.

menustart occurs when a menu in a form receives focus.

mousedown (inherited from control) occurs when the mouse pointer is over the control and a mouse button is pressed.

mouseenter (inherited from control) occurs when the mouse pointer enters the control.

mousehover (inherited from control) occurs when the mouse pointer hovers over the contro.

mouseleave (inherited from control) occurs when the mouse pointer leaves the control.

mousemove (inherited from control) occurs when the mouse pointer is moved over the control.

mouseup (inherited from control) occurs when the mouse pointer is over the control and a mouse button is released.

mousewheel (inherited from control) occurs when the mouse wheel moves while the control has focus.

move (inherited from control) occurs when the control is moved.

paint (inherited from richcontrol) [to be supplied.]

propertychanged (inherited from control) occurs when a property of the control has changed.

queryaccessibilityhelp (inherited from richcontrol) [to be supplied.]

querycontinuedrag (inherited from richcontrol) [to be supplied.]

resize (inherited from control) occurs when the control is resized.

validated (inherited from control) occurs when the control is done validating.

validating (inherited from control) occurs when the control is validating.

(六)族內共享屬性(protected instance properties)

簡單的說一個大類包括兩個小類,這個大類就是一個族,小類就是成員了。

canraiseevents (inherited from richcontrol) [to be supplied.]

createparams (inherited from richcontrol) returns the createparams used to create the handle for this control. inheriting classes should call base.createparams in the manor below:

events (inherited from marshalbyrefcomponent) gets the list of event handlers that are attached to this component.

fontheight (inherited from richcontrol) [to be supplied.]

hscroll (inherited from scrollablecontrol) gets or sets a value indicating whether the horizontal scroll bar is visible.

internalhandle (inherited from control) returns the current value of the handle. this may be zero if the handle has not been created.

maximizedbounds gets the size of the form when it is maximized.

maxtracksize gets the maximum size to which the form can be resized.

mintracksize gets the minimum size the form can be resized to.

renderrighttoleft (inherited from richcontrol) [to be supplied.]

vscroll (inherited from scrollablecontrol) gets or sets a value indicating whether the vertical scroll bar is visible.

windowtext (inherited from control) indicates the current text of the window.

族內共享的對象(實例)屬性(protected instance methods)

adjustformscrollbars (inherited from scrollablecontrol) adjusts the auto-scroll bars on the container based on the current control positions and the control currently selected.

assignparent (inherited from richcontrol) assigns a new parent control. sends out the appropriate property change notifications for properties that are affected by the change of parent.

createaccessibilityinstance (inherited from richcontrol) constructs the new instance of the accessibility object for this control. subclasses should not call base.createaccessibilityobject.

createcontrolsinstance (inherited from richcontrol) constructs the new instance of the controls collection objects. subclasses should not call base.createcontrolsinstance.

createhandle (inherited from control) creates a handle for this control. this method is called by the .net framework, this should not be called. inheriting classes should always call base.createhandle when overriding this method.

defwndproc (inherited from control) sends the message to the default window proc.

destroyhandle (inherited from richcontrol) [to be supplied.]

finalize (inherited from object) allows an object to attempt to free resources and perform other cleanup operations before the object is reclaimed by the garbage collector (gc). this method may be ignored by the common language runtime; therefore, necessary cleanup operations should be done elsewhere.

getstyle (inherited from control) retrieves the current value of the specified bit in the control's style. note: this is control style, not the win32 style of the hwnd.

initlayout (inherited from richcontrol) called after the control has been added to another container.

invokegotfocus (inherited from control) raises the gotfocus event.

invokelostfocus (inherited from control) raises the lostfocus event.

invokeonclick (inherited from control) raises the click event.

invokepaint (inherited from richcontrol) [to be supplied.]

invokepaintbackground (inherited from richcontrol) [to be supplied.]

isinputchar (inherited from control) determines if charcode is an input character that the control wants.

isinputkey (inherited from control) determines if keydata is an input key that the control wants.

memberwiseclone (inherited from object) creates a shallow copy of the current object.

notifyinvalidate (inherited from richcontrol) [to be supplied.]

onactivated raises the activated event.

onchangeuicues (inherited from control) raises the changeuicues event.

onclick (inherited from control) raises the click event.

onclosed raises the closed event.

onclosing raises the closing event.

oncontroladded (inherited from control) raises the controladded event.

oncontrolremoved (inherited from control) raises the controlremoved event.

oncreatecontrol (inherited from control) called when the control is first created.

ondeactivate raises the deactivate event.

ondoubleclick (inherited from control) raises the doubleclick event.

ondragdrop (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.ondragdrop to send this event to any registered event listeners.

ondragenter (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.ondragenter to send this event to any registered event listeners.

ondragleave (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.ondragleave to send this event to any registered event listeners.

ondragover (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.ondragover to send this event to any registered event listeners.

onenter (inherited from control) raises the enter event.

ongivefeedback (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.ongivefeedback to send this event to any registered event listeners.

ongotfocus (inherited from richcontrol) [to be supplied.]

onhandlecreated (inherited from richcontrol) inheriting classes should override this method to find out when the handle has been created. call base.onhandlecreated first.

onhandledestroyed (inherited from richcontrol) inheriting classes should override this method to find out when the handle is about to be destroyed. call base.onhandledestroyed last.

onhelprequested (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.onhelp to send this event to any registered event listeners.

oninputlangchange raises the inputlangchange event.

oninputlangchangerequest raises the inputlangchangerequest event.

oninvalidated (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.oninvalidate to send this event to any registered event listeners.

onkeydown (inherited from control) raises the keydown event.

onkeypress (inherited from control) raises the keypress event.

onkeyup (inherited from control) raises the keyup event.

onlayout (inherited from richcontrol) core layout logic. inheriting controls should override this function to do any custom layout logic. it is not neccessary to call base.layoutcore, however for normal docking and anchoring functions to work, base.layoutcore must be called.

onleave (inherited from control) raises the leave event.

onlostfocus (inherited from richcontrol) [to be supplied.]

onmdichildactivate overloaded. [to be supplied.]

onmenucomplete raises the menucomplete event.

onmenustart raises the menustart event.

onmousedown (inherited from control) raises the mousedown event.

onmouseenter (inherited from control) raises the mouseenter event.

onmousehover (inherited from control) raises the mousehover event.

onmouseleave (inherited from control) raises the mouseleave event.

onmousemove (inherited from control) raises the mousemove event.

onmouseup (inherited from control) raises the mouseup event.

onmousewheel (inherited from control) raises the mousewheel event.

onmove (inherited from control) raises the move event.

onpaint (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.onpaint to send this event to any registered event listeners.

onpaintbackground (inherited from richcontrol) inheriting classes should override this method to handle the erase background request from windows. it is not necessary to call base.onpaintbackground, however if you do not want the default windows behavior you must set event.handled to true.

onparentpropertychanged (inherited from richcontrol) this method is called by the parent control when any property changes on the parent. this can be overriden by inheriting classes, however they must call base.onparentpropertychanged.

onpropertychanged (inherited from richcontrol) [to be supplied.]

onquerycontinuedrag (inherited from richcontrol) inheriting classes should override this method to handle this event. call base.onquerycontinuedrag to send this event to any registered event listeners.

onresize (inherited from control) raises the resize event.

onvalidated (inherited from control) raises the validated event.

onvalidating (inherited from control) raises the validating event.

parentchanged (inherited from control) called by the .net framework after a control's parent changes. this allows (for example) child controls to automatically hook events on their parent, giving better encapsulation.

processcmdkey (inherited from richcontrol) [to be supplied.]

processdialogchar (inherited from control) processes a dialog character.

processdialogkey (inherited from control) processes a dialog key.

processkeyeventargs (inherited from control) processes a key message.

processkeypreview (inherited from control) previews a keyboard message.

processmnemonic (inherited from control) processes a mnemonic character.

processtabkey (inherited from containercontrol) selects the next available control and makes it the active control.

raisedrageventargs (inherited from richcontrol) raises the event associated with key with the event data of e and a sender of this control.

raisekeyeventargs (inherited from control) raises the event associated with key with the event data of e and a sender of this control.

raisemouseeventargs (inherited from control) raises the event associated with key with the event data of e and a sender of this control.

raisepainteventargs (inherited from richcontrol) raises the event associated with key with the event data of e and a sender of this control.

raisepropertychangedevent (inherited from control) raises the property changed event. this creates the needed event data and then calls onpropertychanged.

recreatehandle (inherited from control) forces the recreation of the handle for this control. inheriting controls must call base.recreatehandle.

resumelayout (inherited from control) overloaded. resumes normal layout logic.

rtltranslatealignment (inherited from richcontrol) overloaded. [to be supplied.]

rtltranslatecontent (inherited from richcontrol) [to be supplied.]

rtltranslatehorizontal (inherited from richcontrol) [to be supplied.]

rtltranslateleftright (inherited from richcontrol) [to be supplied.]

scalecore (inherited from control) performs the work of scaling the entire control and any child controls.

sendmessage (inherited from control) overloaded. sends a win32 message to the control.

這是vb6中最有名的api消息函數了,我把這個api的中文幫助附錄于下,只要第一個參數不byval hwnd as long不用就是了

declare function sendmessage& lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any)


說明
調用一個窗口的窗口函數,將一條消息發給那個窗口。除非消息處理完畢,否則該函數不會返回。sendmessagebynum, sendmessagebystring是該函數的“類型安全”聲明形式
返回值
long,由具體的消息決定
參數表
參數 類型及說明
hwnd long,要接收消息的那個窗口的句柄
wmsg long,消息的標識符
wparam long,具體取決于消息
lparam any,具體取決于消息

使用如下:me.sendmessage( byval wmsg as long, byval wparam as long, lparam as any)

至如如何設定參數,就參考vb6.的一些源代碼了,下面是一個拖動無標題欄窗體的用法:

private sub form1_mousedown(byval eventsender as object, byval e as system.winforms.mouseeventargs)

'mousedown的事件中窗體中的下拉列表是找不到的,自己寫一個吧,加上(byval eventsender as object, byval e as system.winforms.mouseeventargs)即可

'下面的代碼使窗體可以拖動

me.capture() = false '釋放鼠標捕獲,等同于api的releasecapture()

me.sendmessage(&ha1s, 2, 0) '唔,這個就是哪個sendmessage的api了,只是第一個句柄參數不再用了。

end sub

我們繼續往下看:


setboundscore (inherited from richcontrol) [to be supplied.]

setclientsizecore (inherited from control) performs the work of setting the size of the client area of the control.

setstyle (inherited from control) sets the current value of the specified bit in the control's style. note: this is control style, not the win32 style of the hwnd.

updatebounds (inherited from control) overloaded. updates the bounds of the control.

updatestyles (inherited from control) forces styles to be reapplied to the handle. this function will call createparams to get the styles to apply.

updatezorder (inherited from control) updates this control in it's parent's zorder.

wndproc [to be supplied.]

wndprocexception (inherited from richcontrol) [to be supplied.]









二。system.drawing.bitmap的成員(bitmap members)

[注:
1.凡注明“to be supplied”是msdn準備在將來提供的空的文檔,所以不翻譯
2.我只能翻譯一些常用項目,不是我懶,我沒有任何中文的參考,如果弄錯了就不太好
3.凡注明“instance”的是要求對象實例,在拙作《vb.net問題集》有詳細的解釋
4.其他如共享定義,基本語法等在我的系列文章中有詳細的介紹,這是就不必要重復了
.................]

(一)。靜態共享方法

fromhicon: creates a bitmap from a windows handle to an icon.
從一個圖標的句柄構建一個bitmap對象
在vb.net中在方法中經常使用from-前綴代表從一個源得到,而使用to-前綴到一個目的對象

fromresource: [to be supplied.]

(二)對象構造器(public instance constructors)

bitmap constructor overloaded. 初始化一個新的實例(initializes a new instance of the bitmap class.)

(三)公用的對象(實例)屬性(public instance properties)

flags (inherited from image) gets attribute flags for this image.

framedimensionslist (inherited from image) gets an array of guids that represent the dimensions of frames within this image.

height (inherited from image) gets the height of this image.
返回圖片的高度

horizontalresolution (inherited from image) gets the horizontal resolution, in pixels-per-inch, of this image.

palette (inherited from image) gets or sets the color palette used for this image.

physicaldimension (inherited from image) gets the width and height of this image.

pixelformat (inherited from image) gets the pixel format for this image.

propertyidlist (inherited from image) gets an array of the property ids stored in this image.

propertyitems (inherited from image) gets an array of propertyitem objects that describe this image.

rawformat (inherited from image) gets the format of this image.

size (inherited from image) gets the width and height of this image.
返回圖片的尺寸

verticalresolution (inherited from image) gets the vertical resolution, in pixels-per-inch, of this image.

width (inherited from image) gets the width of this imaege.
返回圖片的寬度

(四)公用的對象(實例)方法

clone: (inherited from image) creates an exact copy of this image.

dispose: (inherited from image) cleans up windows resources for this image.
這個真有一點象vb6的unload,不過dispose的用處大多了,再說一篇就是清除資源占用。

equals: (inherited from object) determines whether the specified object is the same instance as the current object.

getbounds: (inherited from image) gets a bounding rectangle in the specified units for this image.

getencoderparameterlist: (inherited from image) returns information about the codecs used for this image.

getframecount: (inherited from image) returns the number of frames of the given dimension.

gethashcode: (inherited from object) serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

gethbitmap: overloaded. creates a win32 hbitmap out of the image. you are responsible for de-allocating the hbitmap with windows.deleteobject(handle). if the image uses transparency, the background will be filled with the specified background color.
得到位圖句柄,這個用起來有點麻煩,好在我的文章中有了

gethicon: returns the handle to an icon
得到圖標句柄

getlifetimeservice: (inherited from marshalbyrefobject) this method is used return a lifetime service object that is used to control the lifetime policy to the object. for the default lifetime service this will be an object of type ilease.

getpixel: gets the color of the specified pixel in this bitmap.
得到一個像素的color值,這個東東作用不小,不要輕看了他。

getpropertyitem: (inherited from image) gets the specified property item from this image.

getthumbnailimage (inherited from image) returns the thumbnail for this image.

gettype (inherited from object) gets the type of the object.
返回對象的類

initializelifetimeservice (inherited from marshalbyrefobject) object can provide their own lease and so control their own lifetime. they do this by overriding the initializelifetimeservice method provided on marshalbyrefobject

lockbits locks a bitmap into system memory.

maketransparent overloaded. makes a color transparent for this bitmap.

removepropertyitem (inherited from image) removes the specified property item from this image.

save (inherited from image) overloaded. saves this image to a file.
保存圖片到文件

saveadd (inherited from image) overloaded. adds an encoderparameters to this image.

selectactiveframe (inherited from image) selects the frame specified by the given dimension and index.

setpixel sets the color of the specified pixel in this bitmap.
設置一個像素的color值

setpropertyitem (inherited from image) sets the specified property item to the specified value.

setresolution sets the resolution for this bitmap.

tostring (inherited from object) returns a string that represents the current object.
轉到字符類

unlockbits unlocks this bitmap from system memory.

(五)族內共享的對象(實例)屬性:(protected instance methods)

finalize (inherited from image) cleans up windows resources for this image.

memberwiseclone (inherited from object) creates a shallow copy of the current object.


下面使用舉例說明如何使用:

新建一個工程,你會看到以下代碼:

imports system.componentmodel

imports system.drawing

imports system.winforms

說明:imports(引用族名) 在c#中為using, 在c++中為namespace,作用是一樣的,這僅僅是一個語法,并不是必要的調用,你完全可以不使用這個關鍵字,仍舊可以使用所有的族。

只是system.drawing,bitmap在使用了imports system.drawing以后你可以簡寫為bitmap。當然你仍舊可以寫為system.drawing.bitmap

public class form1

inherits system.winforms.form

說明:inherits 是繼承的意思,這樣你可以象使用system.winforms.form一樣使用form已有的成員

你可以這樣:me.backcolor = system.drawing.color.black

me.backcolor是system.winforms.form的成員,因為繼承,form1也得到了這個成員,但是因為他返回的值是色彩,而色彩是屬于圖形的,你應該在system.draw

中去找,結果你找到了system.drawing.color,所以me.backcolor的值的數據是system.draw.color。在color后面打點,出現提示,有你想要的色彩,與調用,修改

色彩的方法,函數。black就是黑色了,這個總比以前的十六進制要直觀得多吧。如果你想聲明一個變量保存這個值,一定要聲明為:

dim colorval as system.drawing.color 而不是 dim colorval as string,

所有的類都可以這樣聲明。至于如何調用其他的一些不能直接調用的函數的問題,可以參考我的文章《vb.net問題集》

下面是一個例子:

1. 新建一個工程,可以參考我的文章《vb.net圖解入門》

2. 添加picturebox控件在屬性欄的backgroundimage屬性中引入一幅背景圖,拖動他使他比圖片小一點點,

3. 設置窗體的標題欄borderstyle為0,窗體的大小與picturebox一樣大

4. 請在代碼開始處寫入option strict off,關閉option strict使背景圖片(system.drawing.image)可以使用system.drawing.bitmap類

5. 寫代碼如下:


protected sub picturebox1_click(byval sender as object, byval e as system.eventargs)

dim pcolor as system.drawing.color

dim strpc as string

pcolor = getpixel

strpc = pcolor.tostring

‘tostring的作用是叢system.drawing.color的數據類型轉換為string類型

system.winforms.messagebox.show("當前像素的rgb" & strpc, "我的第一個vb.net程序", messagebox.ok bitor messagebox.iconasterisk)

‘messagebox是winforms的一個子類,主對話框的調用messagebox的成員凡以icom為前綴的是圖標的調用

end sub

public function getpixel() as system.drawing.color

dim pm as system.drawing.bitmap

pm = picturebox1.backgroundimage

‘如果這里出錯是因為沒有使用option strict off

return pm.getpixel(pixx, pixy)

end function


public sub picturebox1_mousemove(byval sender as object, byval e as system.winforms.mouseeventargs) handles picturebox1.mousemove

pixx = e.x

pixy = e.y

將以上代碼粘貼到#region " windows form designer generated code "到#end region這段代碼的后面

按f5運行一下,這么一點代碼就可以捕獲圖片任何一點的色彩。

如果有時vb沒有能響應鍵盤的有些鍵,請重新啟動,這大概是beta版的bug吧。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 榆树市| 德昌县| 娄底市| 横峰县| 广饶县| 巴彦淖尔市| 南京市| 平顶山市| 墨竹工卡县| 龙游县| 遂溪县| 新营市| 六安市| 修武县| 嵊州市| 顺平县| 株洲市| 广丰县| 宁蒗| 大洼县| 恩施市| 景德镇市| 蕲春县| 东阳市| 潜江市| 连南| 威远县| 顺平县| 高碑店市| 固安县| 广元市| 特克斯县| 桃源县| 安塞县| 米林县| 石首市| 临汾市| 封开县| 抚宁县| 永修县| 搜索|