vb简单代码画漂亮窗体Word格式.docx
《vb简单代码画漂亮窗体Word格式.docx》由会员分享,可在线阅读,更多相关《vb简单代码画漂亮窗体Word格式.docx(29页珍藏版)》请在冰点文库上搜索。
[lefttoRight]=1
EndEnum
DimCAsBoolean
PrivateDeclareFunctionSendMessage&
Lib"
user32"
Alias"
SendMessageA"
(ByValhwndAsLong,ByValwMsgAsLong,ByValwParamAsLong,lParamAsAny)
PrivateDeclareFunctionCreatePolygonRgnLib"
gdi32"
(lpPointAsPOINTAPI,ByValnCountAsLong,ByValnPolyFillModeAsLong)AsLong
PrivateDeclareFunctionCreateRectRgnLib"
(ByValx1AsLong,ByValy1AsLong,ByValx2AsLong,ByValy2AsLong)AsLong
PrivateDeclareFunctionCreateRoundRectRgnLib"
(ByValx1AsLong,ByValy1AsLong,ByValx2AsLong,ByValy2AsLong,ByValX3AsLong,ByValy3AsLong)AsLong
PrivateDeclareFunctionDeleteObjectLib"
(ByValhObjectAsLong)AsLong
PrivateDeclareFunctionCreateSolidBrushLib"
(ByValcrColorAsLong)AsLong
PrivateDeclareFunctionFrameRgnLib"
(ByValhdcAsLong,ByValhRgnAsLong,ByValhBrushAsLong,ByValnWidthAsLong,ByValnHeightAsLong)AsLong
PrivateDeclareFunctionReleaseCaptureLib"
()AsLong
PrivateDeclareFunctionSetCaptureLib"
(ByValhwndAsLong)AsLong
PrivateDeclareFunctionSetWindowRgnLib"
(ByValhwndAsLong,ByValhRgnAsLong,ByValbRedrawAsBoolean)AsLong
DimWithEventsPicture1AsPictureBox‘声明窗体
DimWithEventsPicture2AsPictureBox‘关闭按扭
DimWithEventsPicture3AsPictureBox‘最小化
DimWithEventsLoadingAsPictureBox‘登录按扭
DimWithEventsCancelAsPictureBox‘取消按扭
DimWithEventsUPAsPictureBox‘文本框边
DimWithEventsPPAsPictureBox‘文本框边
DimUserLaBelAsLabel‘标签
DimPasswordLaBelAsLabel‘标签
DimWithEventsuTextAsTextBox‘帐号文本
DimWithEventsPTextAsTextBox‘密码文本
DimStylAsBoolean
PrivateSubLoadWindow()
DimiAsLong
DimcolorAsLong
DimW,hAsLong
Fori=1To405
color=color+1
Picture1.Line(0,i)-(Picture1.ScaleWidth,i),RGB(0,255,color)‘画出窗体标题栏
Nexti
Picture1.ForeColor=vbBlue
Picture1.FontSize=10
Picture1.CurrentX=200
Picture1.CurrentY=100
Picture1.PrintMe.Caption
Fori=1To25
Picture1.Line(i,0)-(i,Picture1.ScaleHeight),RGB(0,255,color)
Fori=Picture1.ScaleWidth-55ToPicture1.ScaleWidth
Fori=Picture1.ScaleHeight-55ToPicture1.ScaleHeight
Picture1.Line(0,i)-(ScaleWidth,i),RGB(0,255,color)
DimRgnAsLong
DimBrushAsLong
W=Picture1.ScaleWidth
h=Picture1.ScaleHeight
Rgn=CreateRoundRectRgn(0,0,Picture1.ScaleX(Picture1.Width,vbTwips,vbPixels),Picture1.ScaleY(Picture1.Height+200,vbTwips,vbPixels),12,12)
SetWindowRgnPicture1.hwnd,Rgn,True‘删除窗体上面两个角
DeleteObjectRgn
Brush=CreateSolidBrush(0)
FrameRgnPicture1.hdc,Rgn,Brush,1,1
Picture1.Line(0,Picture1.ScaleHeight-10)-(Picture1.ScaleWidth,Picture1.ScaleHeight-10),0
DeleteObjectBrush
Rgn=CreateRectRgn(3,27,Picture1.ScaleWidth/15-4,Picture1.ScaleHeight/15-3)
EndSub
PrivateSubCommand1_Click()
PrivateSubForm_Load()
Me.Width=6680
Me.Height=5580
Me.BackColor=&
H808080
Me.Caption="
VB画漂亮窗体"
Styl=False
SetPicture1=Me.Controls.Add("
vb.picturebox"
"
picture1"
Me)
WithPicture1
.Width=4575
.Height=3615
.Left=800
.Top=800
.BorderStyle=0
.Visible=True
EndWith
SetPicture2=Me.Controls.Add("
picture2"
Picture1)
WithPicture2
.Width=300
.Left=Picture1.Width-400
.Height=300
.Top=80
SetPicture3=Me.Controls.Add("
picture3"
Picture3.Top=80
Picture3.Left=Picture2.Left-320
Picture3.Width=300
Picture3.Height=300
Picture3.BorderStyle=0
Picture3.Visible=True
SetUserLaBel=Me.Controls.Add("
vb.Label"
uL"
WithUserLaBel
.Top=1000
.Caption="
用户名(&
U):
"
.ForeColor=vbBlue
.Width=1000
.BackStyle=0
SetPasswordLaBel=Me.Controls.Add("
PL"
WithPasswordLaBel
.Top=1600
密码(&
P):
SetUP=Me.Controls.Add("
UP"
WithUP
.Top=930
.Left=1800
.Width=1900
.Height=330
.BackColor=vbWhite
SetuText=Me.Controls.Add("
VB.textbox"
ut"
UP)
WithuText
.Top=30
.Left=200
.Width=1500
.Height=250
SetPP=Me.Controls.Add("
PP"
WithPP
.Top=1500
SetPText=Me.Controls.Add("
Pt"
PP)
WithPText
.PasswordChar="
*"
SetLoading=Me.Controls.Add("
Loading1"
WithLoading
.Top=2500
.Width=800
.Height=350
.Appearance=0
SetCancel=Me.Controls.Add("
Cancel"
WithCancel
.Left=3000
PrivateSubForm_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
PP_Paint
PrivateSubPicture1_Paint()
LoadWindow
PrivateSubDrawcolor(ByValobjectAsObject,ByValcrColor1AsLong,crColor2AsLong,ByValFAsBoolean)
DimW,hAsLong
DimuHAsSingle,uWAsSingle
DimrInfoAsSingle,gInfoAsSingle,bInfoAsSingle
DimrStaAsLong,gStaAsLong,bStaAsLong
DimrEndAsLong,gEndAsLong,bEndAsLong
DimRAsLong,GAsLong,BAsLong,iAsLong
uH=object.ScaleHeight:
uW=object.ScaleWidth
rSta=crColor1Mod256
gSta=crColor1\256Mod256
bSta=crColor1\256\256
rEnd=crColor2Mod256
gEnd=crColor2\256Mod256
bEnd=crColor2\256\256
IfF=TrueThen
rSta=rSta*1.2:
gSta=gSta*1.2:
bSta=bSta*1.2
rEnd=rEnd*1.2:
gEnd=gEnd*1.2:
bEnd=bEnd*1.2
rInfo=(rEnd-rSta)/uH
gInfo=(gEnd-gSta)/uH
bInfo=(bEnd-bSta)/uH
Fori=0TouH-1
R=rSta+i*rInfo
G=gSta+i*gInfo
B=bSta+i*bInfo
object.Line(0,i)-(uW-1,i),RGB(R,G,B)
Else
EndIf
PrivateSubPicture1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
ReleaseCapture
SendMessagePicture1.hwnd,&
HA1,2,0&
‘移动里面的窗体
PrivateSubPicture2_Click()
Picture1.Visible=False
PrivateSubPicture2_Paint()
DrawcolorPicture2,255,vbWhite,True
W=Picture2.ScaleWidth/Screen.TwipsPerPixelX
h=Picture2.ScaleHeight/Screen.TwipsPerPixelY
Rgn=CreateRoundRectRgn(0,0,W,h,3,3)
SetWindowRgnPicture2.hwnd,Rgn,True
Brush=CreateSolidBrush(123)
FrameRgnPicture2.hdc,Rgn,Brush,1,1
Picture2.DrawWidth=2
Picture2.Line(70,70)-(230,230),&
Picture2.Line(230,70)-(70,230),&
PrivateSubPicture3_Paint()
DrawcolorPicture3,&
HFF8080,vbWhite,True
W=Picture3.ScaleWidth/Screen.TwipsPerPixelX
h=Picture3.ScaleHeight/Screen.TwipsPerPixelY
SetWindowRgnPicture3.hwnd,Rgn,True
FrameRgnPicture3.hdc,Rgn,Brush,1,1
Picture3.DrawWidth=2
Picture3.Line(70,170)-(230,170),&
PrivateSubPText_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
DimRgnAsLong
DimBrushAsLong
W=PP.ScaleWidth/Screen.TwipsPerPixelX
h=PP.ScaleHeight/Screen.TwipsPerPixelY
IfX>
=0AndX<
=PText.WidthAndY>
=0AndY<
=PText.HeightThen
Rgn=CreateRoundRectRgn(0,0,W,h,20,20)
Brush=CreateSolidBrush(vbGreen)
FrameRgnPP.hdc,Rgn,Brush,1,1
DeleteObjectRgn
DeleteObjectBrush
SetCapturePText.hwnd
Brush=CreateSolidBrush(&
H80FF80)
EndSub
PrivateSubUText_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
W=UP.