《vb代码-颜色渐变的标题栏(VB code - color gradient title bar).doc》由会员分享,可在线阅读,更多相关《vb代码-颜色渐变的标题栏(VB code - color gradient title bar).doc(18页珍藏版)》请在金锄头文库上搜索。
1、vb代码-颜色渐变的标题栏(VB code - color gradient title bar)a gradual change in the title box, in this case we can see the application skills of drawingEspecially the method of realizing gradient, it is worth us to draw lessons fromit also involves dragging the untitled windowOption ExplicitPrivate IsMaximized
2、 As BooleanPrivate IsMinimized As BooleanPrivate ButtonsCount As IntegerPrivate Sub Form_Paint ()ReSizeEndFRDrag Me.Top, Me.LeftEnd SubPrivate Sub imgCloseForm_MouseDown (Button, As, Shift, As, x, As, y, As, Single, Integer, Single, Integer)ImgCloseForm.Picture = imgCloseFormButtonDown.PictureEnd Su
3、bPrivate Sub imgCloseForm_MouseUp (Button, As, Shift, As, x, As, y, As, Single, Integer, Single, Integer)Unload All of the FormsDim frm As FormImgCloseForm.Picture = imgCloseFormButton.PictureFor Each frm In FormsUnload FRMNext FRMEndEnd SubPrivate Sub imgMaximize_MouseDown (Button, As, Shift, As, x
4、, As, y, As, Single, Integer, Single, Integer)If IsMaximized = True ThenImgMaximize.Picture = imgNormalizeButtonDown.PictureElseImgMaximize.Picture = imgMaximizeButtonDown.PictureEnd IfEnd SubPrivate Sub imgMaximize_MouseUp (Button, As, Shift, As, x, As, y, As, Single, Integer, Single, Integer)If Is
5、Maximized = False ThenMe.WindowState = 2IsMaximized = TrueForm_ResizeImgMaximize.Picture = imgNormalizeButton.PictureElseMe.WindowState = 0IsMaximized = FalseForm_ResizeImgMaximize.Picture = imgMaximizeButton.PictureEnd IfEnd SubPrivate Sub imgMinimize_MouseDown (Button, As, Shift, As, x, As, y, As,
6、 Single, Integer, Single, Integer)ImgMinimize.Picture = imgMinimizeButtonDown.PictureEnd SubPrivate Sub imgMinimize_MouseUp (Button, As, Shift, As, x, As, y, As, Single, Integer, Single, Integer)If IsMinimized = False ThenMe.WindowState = 1IsMinimized = TrueForm_ResizeImgMinimize.Picture = imgMinimi
7、zeButton.PictureElseMe.WindowState = 0IsMinimized = FalseForm_ResizeImgMinimize.Picture = imgMinimizeButton.PictureEnd IfEnd SubPrivate Sub Form_Activate ()IsMinimized = FalseEnd SubPrivate Sub Form_Load ()Dim frameHeight As LongDim frameWidth As LongMe.ScaleMode = 3compute the width of the left and
8、 right dialog frameFrameHeight = GetSystemMetrics (SM_CYDLGFRAME) * 2compute the width of the top and bottom dialog frameFrameWidth = GetSystemMetrics (SM_CXDLGFRAME) * 2me.scalemode = 1buttonscount = 0如果Me.MaxButton真的那么buttonscount = buttonscount + 1如果Me.MinButton真的那么buttonscount = buttonscount + 2
9、选择案例buttonscount案例0imgmaximize可视=假。imgminimize可视=假。案例1imgminimize可视=假。案例2imgmaximize可视=假。最后选择调整大小drawcaption我。标题imgformicon。照片=我。图标端子私有子form_resize()调整大小端子私有子pictitlebar_mousedown(按钮为整数,转变为整数,X,Y为单,单)beginfrdrag x,y端子私有子pictitlebar_mousemove(按钮为整数,转变为整数,X,Y为单,单)如果按钮= 1然后dofrdrag x,y端子私有子pictitlebar_
10、mouseup(按钮为整数,转变为整数,X,Y为单,单)endfrdrag x,y端子私有子lblformcaption_mousedown(按钮为整数,转变为整数,X,Y为单,单)beginfrdrag x,y端子私有子lblformcaption_mousemove(按钮为整数,转变为整数,X,Y为单,单)如果按钮= 1然后dofrdrag x,y端子私有子lblformcaption_mouseup(按钮为整数,转变为整数,X,Y为单,单)endfrdrag x,y端子列兵Sub BeginFRDrag(X单,Y为单)如果ismaximized =真Exit Sub如果最小化=真Exit
11、 Sub将TDC设为长昏暗的SDC长暗长“转换点进行结构X = X的观点。Y = Y的观点。“获取我的屏幕区域GetWindowRect Me.hwnd,fbox屏幕矩形我twipsperpixelx = screen.twipsperpixelxtwipsperpixely = screen.twipsperpixely“在屏幕上鼠标点坐标温度=观点ClientToScreen Me.hwnd,温SDC = GetDC(ByVal 0)drawfocusrect SDC TBoxa ReleaseDC(0,SDC)oldbox = TBox端子列兵Sub DoFRDrag(X单,Y为单)如果
12、ismaximized =真Exit Sub如果最小化=真Exit Sub将TDC设为长昏暗的SDC长暗长tpoint x = x。tpoint Y = y。ClientToScreen Me.hwnd,tpointTBox。左=(fbox.left + tpoint。X / TwipsPerPixelX)-温度。X / TwipsPerPixelXTBox。=(fbox.top + tpoint。Y / twipsperpixely)-临时Y / twipsperpixelyTBox。右=(fbox.right + tpoint。X / TwipsPerPixelX)-临时X / Twips
13、PerPixelXTBox。底=(fbox.bottom + tpoint。Y / twipsperpixely)-临时Y / twipsperpixelySDC = GetDC(ByVal 0)drawfocusrect SDC,oldboxdrawfocusrect SDC TBoxa ReleaseDC(0,SDC)oldbox = TBox端子列兵Sub EndFRDrag(X单,Y为单)如果ismaximized =真Exit Sub如果最小化=真Exit Sub将TDC设为长昏暗的SDC长暗长昏暗的newleft单纽拓普作为单一暗淡SDC = GetDC(ByVal 0)drawf
14、ocusrect SDC,oldboxa ReleaseDC(0,SDC)newleft = x + fbox。左* twipsperpixelx - X的观点。纽拓普= y + fbox。顶* twipsperpixely - Y的观点。我把newleft,纽拓普。cmddummy.setfocus端子列兵Sub DrawCaption(scaption字符串)lblformcaption。标题scaption端子私有子resize()lineborder1.bordercolor = vb3dhighlightlineborder2.bordercolor = vb3dhighlightlineborder3.bordercolor = vb3dshadowlineborder4.bordercolor = vb3dshadowlineborder1.y2高度=我。lineb