IP地址输入框Word文档格式.docx

上传人:b****6 文档编号:17292321 上传时间:2022-11-30 格式:DOCX 页数:6 大小:16.73KB
下载 相关 举报
IP地址输入框Word文档格式.docx_第1页
第1页 / 共6页
IP地址输入框Word文档格式.docx_第2页
第2页 / 共6页
IP地址输入框Word文档格式.docx_第3页
第3页 / 共6页
IP地址输入框Word文档格式.docx_第4页
第4页 / 共6页
IP地址输入框Word文档格式.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

IP地址输入框Word文档格式.docx

《IP地址输入框Word文档格式.docx》由会员分享,可在线阅读,更多相关《IP地址输入框Word文档格式.docx(6页珍藏版)》请在冰豆网上搜索。

IP地址输入框Word文档格式.docx

IfUser32.InitCommonControlsEx(CommCtrl)Then

CtlHwnd=User32.CreateWindowEx(0,"

SysIPAddress32"

"

"

_

User32.Constants.WS_CHILDOrUser32.Constants.WS_TABSTOPOrUser32.Constants.WS_VISIBLE,0,0,132,21,_

Me.Handle,IntPtr.Zero,GetInstance,IntPtr.Zero)IfCtlHwnd.Equals(IntPtr.Zero)=FalseThen

‘将IP控件的字体设置的根窗体一样用宋体

DimhFontAsIntPtr=Me.Font.ToHfont()

User32.SendMessage(CtlHwnd,User32.WindowsMessages.WM_SETFONT,hFont,IntPtr.Zero)

EndIf

Else

EndSub‘Control重写dispose以清理组件列表。

ProtectedOverloadsOverridesSubDispose()SubDispose(ByValdisposingAsBoolean)

IfCtlHwnd.Equals(IntPtr.Zero)=FalseThenUser32.DestroyWindow(CtlHwnd)

IfdisposingThen

IfNot(componentsIsNothing)Then

components.Dispose()

MyBase.Dispose(disposing)

EndSub‘控件设计器所必需的

PrivatecomponentsAsSystem.ComponentModel.IContainer‘注意:

以下过程是组件设计器所必需的

‘可以使用组件设计器修改此过程。

不要使用

‘代码编辑器修改它。

&

lt;

System.Diagnostics.DebuggerStepThrough()&

gt;

PrivateSubInitializeComponent()SubInitializeComponent()

components=NewSystem.ComponentModel.Container

EndSub#EndRegionProtectedOverridesSubOnPaint()SubOnPaint(ByValpeAsSystem.Windows.Forms.PaintEventArgs)

MyBase.OnPaint(pe)‘在此添加自定义绘画代码

EndSubPrivateSubIPTextBox_SizeChanged()SubIPTextBox_SizeChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMyBase.SizeChanged

IfCtlHwnd.Equals(IntPtr.Zero)=FalseThenUser32.SetWindowPos(CtlHwnd,0,0,0,Me.Width,Me.Height,&

amp;

H22)

EndSubPrivateCtlHwndAsIntPtrPropertys#Region"

Propertys"

PublicOverridesPropertyText()PropertyText()AsString

Get

DimTempLngAsInteger=0

DimtmpLngAsIntPtr=System.Runtime.InteropServices.Marshal.AllocHGlobal(4)

Try

User32.SendMessage(CtlHwnd,User32.Constants.IPM_GETADDRESS,IntPtr.Zero,tmpLng)

TempLng=System.Runtime.InteropServices.Marshal.ReadInt32(tmpLng)

CatchexAsException

MsgBox(ex.Message)

EndTry

System.Runtime.InteropServices.Marshal.FreeHGlobal(tmpLng)

ReturnFIRST_IPADDRESS(TempLng)&

"

."

SECOND_IPADDRESS(TempLng)&

THIRD_IPADDRESS(TempLng)&

FOURTH_IPADDRESS(TempLng)

EndGet

Set(ByValValueAsString)

IfValue=String.EmptyThenValue="

IfValue.Split("

).Length&

&

4ThenValue="

IfValue&

ThenUser32.SendMessage(CtlHwnd,User32.Constants.IPM_SETADDRESS,IntPtr.Zero,NewIntPtr(MakeIPAddess(Value)))

EndSet

EndProperty

#EndRegionFunctions#Region"

Functions"

‘‘‘&

summary&

‘‘‘获取应用程序的进程句柄

/summary&

returns&

/returns&

remarks&

/remarks&

PrivateFunctionGetInstance()FunctionGetInstance()AsIntPtr

DimtmpTypeAsType=Me.GetType

DimtmpModuleAsSystem.Reflection.Module=tmpType.Module

ReturnSystem.Runtime.InteropServices.Marshal.GetHINSTANCE(tmpModule)

EndFunctionPrivateFunctionFIRST_IPADDRESS()FunctionFIRST_IPADDRESS(ByValxAsInt32)AsByte

FIRST_IPADDRESS=((xAnd&

H7F000000)&

H1000000)Or(((xAnd&

H80000000)&

0)And&

H80)

EndFunctionPrivateFunctionSECOND_IPADDRESS()FunctionSECOND_IPADDRESS(ByValxAsInt32)AsByte

SECOND_IPADDRESS=(xAnd&

HFF0000)&

H10000

EndFunctionPrivateFunctionTHIRD_IPADDRESS()FunctionTHIRD_IPADDRESS(ByValxAsInt32)AsByte

THIRD_IPADDRESS=(xAnd&

HFF00&

)&

H100

EndFunctionPublicFunctionFOURTH_IPADDRESS()FunctionFOURTH_IPADDRESS(ByValxAsInt32)AsByte

FOURTH_IPADDRESS=xAnd&

HFF

EndFunctionPrivateFunctionMAKEIPRANGE()FunctionMAKEIPRANGE(ByVallowAsByte,ByValhighAsByte)AsInt32

MAKEIPRANGE=high*&

H100&

Orlow

EndFunctionPrivateFunctionMakeIPAddess()FunctionMakeIPAddess(ByValb1AsByte,ByValb2AsByte,ByValb3AsByte,ByValb4AsByte)AsInt32

Return((b1And&

H7F)*&

H1000000Or(b1And&

H80)&

0And&

H80000000)Or(b2*&

H10000)Or(b3*&

)Or(b4)

EndFunctionPrivateFunctionMakeIPAddess()FunctionMakeIPAddess(ByValIPAddressAsString)AsInt32

DimipsAsString()=IPAddress.Split("

Ifips.Length&

4Thenips=NewString(){"

0"

}

DimcoutAsInt32=0

ForiAsInteger=0To3

IfNotIsNumeric(ips(i))Then

ThrowNewException("

IP地址错误!

cout=(cout&

8)Or(Val(ips(i))And&

HFF)

Next

Returncout

EndFunction#EndRegionEndClassPublicClassUser32ClassUser32&

DllImport("

user32"

EntryPoint:

="

CreateWindowExA"

CharSet:

=CharSet.Ansi,SetLastError:

=True,ExactSpelling:

=True)&

_

PublicSharedFunctionCreateWindowEx()FunctionCreateWindowEx(ByValdwExStyleAsInteger,&

MarshalAs(UnmanagedType.VBByRefStr)&

ByReflpClassNameAsString,&

ByReflpWindowNameAsString,ByValdwStyleAsInteger,ByValxAsInteger,ByValyAsInteger,ByValnWidthAsInteger,ByValnHeightAsInteger,ByValhWndParentAsIntPtr,ByValhMenuAsIntPtr,ByValhInstanceAsIntPtr,ByVallpParamAsIntPtr)AsIntPtr

EndFunction&

PublicSharedFunctionDestroyWindow()FunctionDestroyWindow(ByValhwndAsIntPtr)AsInteger

SendMessageA"

PublicSharedFunctionSendMessage()FunctionSendMessage(ByValhwndAsInteger,ByValwMsgAsInteger,ByValwParamAsInteger,ByVallParamAsInteger)AsInteger

EndFunction

PublicSharedFunctionSendMessage()FunctionSendMessage(ByValhwndAsIntPtr,ByValwMsgAsInteger,ByValwParamAsIntPtr,ByVallParamAsIntPtr)AsIntPtr

PublicSharedFunctionSetWindowPos()FunctionSetWindowPos(ByValhwndAsIntPtr,ByValhWndInsertAfterAsInteger,ByValxAsInteger,ByValyAsInteger,ByValcxAsInteger,ByValcyAsInteger,ByValwFlagsAsInteger)AsInteger

comctl32.dll"

PublicSharedFunctionInitCommonControlsEx()FunctionInitCommonControlsEx(ByRefTLPINITCOMMONCONTROLSEXAsStructures.InitCommonControls)AsInteger

EndFunction‘Fields

PublicConstMENU_CLASSAsString="

#32768"

‘NestedTypes

PublicEnumConstantsEnumConstants

ICC_INTERNET_CLASSES=2048

IPM_CLEARADDRESS=1124

IPM_GETADDRESS=1126

IPM_SETADDRESS=1125

WS_CHILD=1073741824

WS_TABSTOP=65536

WS_VISIBLE=268435456

EndEnumPublicClassStructuresClassStructures&

StructLayout(LayoutKind.Sequential)&

PublicStructureInitCommonControlsStructureInitCommonControls

‘Fields

PublicdwICCAsInteger

PublicdwSizeAsInteger

EndStructure&

PublicStructureWINDOWPOSStructureWINDOWPOS

PubliccxAsInteger

PubliccyAsInteger

PublicflagsAsInteger

PublichWndAsIntPtr

PublichWndInsertAfterAsIntPtr

PublicxAsInteger

PublicyAsInteger

EndStructure

EndClassPublicEnumWindowsMessagesEnumWindowsMessages

WM_SETFONT=48

EndEnumEndClassEndNamespace

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1