走近VB.Net(一),VB中的族,类,对象(摘录部分MSDN)

类别:.NET开发 点击:0 评论:0 推荐:

 

 走近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吧。

                           VB.Net中文站  http://vbnetcn.126.com

                          作者附注:根据太平洋网络学院编辑tntst和建议,本文作了重新整理

本文地址:http://com.8s8s.com/it/it46362.htm