如何实现vb窗体换肤?除了ActiveSkin,

解决方案 »

  1.   

    自己写Skin的代码或控件。
    我写过这方面的东东。
      

  2.   

    不是很简单的事情,你看看我的Binxtudio v100 r3,把所有的标准控件都替掉了。
    http://www.eaglestudio.net/Binkinst.rar
      

  3.   

    这是我昨天刚完成的,效果很不错:Public Sub DoDrag(TheForm As Form)(拖拽标题栏)
        ReleaseCapture
        SendMessage TheForm.hWnd, &HA1, 2, 0&
    End SubPublic Sub MakeWindow(TheForm As Form)(设置图片)
        'TheForm.BackColor = RGB(254, 255, 180)
        TheForm.Caption = TheForm!Title.Caption
        TheForm!Title.Left = 60
        TheForm!Title.Top = 6
        TheForm!Title.ForeColor = &HC0C000
        
        TheForm!imgTitleLeft.Stretch = True
        TheForm!imgTitleRight.Stretch = True
        TheForm!imgTitleMain.Stretch = True
        TheForm!imgWindowLeft.Stretch = True
        TheForm!imgWindowBottomLeft.Stretch = True
        TheForm!imgWindowBottom.Stretch = True
        TheForm!imgWindowBottomRight.Stretch = True
        TheForm!imgWindowRight.Stretch = True
        
        With TheForm!imgTitleLeft
            .Top = 0
            .Left = 0
        End With
        
        With TheForm!imgTitleRight
            .Top = 0
            .Left = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgTitleRight.Width
        End With
        
        With TheForm!imgTitleMain
            .Top = 0
            .Left = TheForm!imgTitleLeft.Width
            .Width = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgTitleRight.Width + TheForm!imgTitleLeft.Width
        End With
        
        With TheForm!imgWindowLeft
            .Top = TheForm!imgTitleLeft.Height
            .Left = 0
            .Height = (TheForm.Height / Screen.TwipsPerPixelY) - TheForm!imgTitleLeft.Height + TheForm!imgTitleRight.Height
        End With
        
        With TheForm!imgWindowBottomLeft
            .Top = (TheForm.Height / Screen.TwipsPerPixelY) - TheForm!imgWindowBottomLeft.Height
            .Left = 0
        End With
        
        With TheForm!imgWindowBottom
            .Top = (TheForm.Height / Screen.TwipsPerPixelY) - TheForm!imgWindowBottom.Height
            .Left = TheForm!imgWindowBottomLeft.Left
            .Width = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgWindowBottomLeft.Width + TheForm!imgWindowBottomRight.Width
        End With
        
        With TheForm!imgWindowBottomRight
            .Top = (TheForm.Height / Screen.TwipsPerPixelY) - TheForm!imgWindowBottomRight.Height
            .Left = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgWindowBottomRight.Width
        End With
        
        With TheForm!imgWindowRight
            .Top = TheForm!imgTitleRight.Height
            .Left = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgWindowRight.Width
            .Height = (TheForm.Width / Screen.TwipsPerPixelX) - TheForm!imgTitleRight.Height + TheForm!imgWindowBottomRight.Height
        End With
        'DoTransparency TheForm
    End Sub
    Public Sub skinWindow(TheForm As Form) '更换样式
    TheForm.Hide
    Static i As String
    i = Trim(Form4.Text1)
    TheForm!imgTitleLeft.Stretch = False
    TheForm!imgTitleRight.Stretch = False
    TheForm!imgTitleMain.Stretch = False
    TheForm!imgWindowLeft.Stretch = False
    TheForm!imgWindowBottomLeft.Stretch = False
    TheForm!imgWindowBottom.Stretch = False
    TheForm!imgWindowBottomRight.Stretch = False
    TheForm!imgWindowRight.Stretch = FalseTheForm!imgTitleLeft.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgTitleleft.bmp")
    TheForm!imgTitleRight.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgTitleRight.bmp")
    TheForm!imgTitleMain.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgTitleMain.bmp")
    TheForm!imgWindowLeft.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgWindowLeft.bmp")
    TheForm!imgWindowBottomLeft.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgWindowBottomLeft.bmp")
    TheForm!imgWindowBottom.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgWindowBottom.bmp")
    TheForm!imgWindowBottomRight.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgWindowBottomRight.bmp")
    TheForm!imgWindowRight.Picture = LoadPicture(App.Path & "\skin\" & i & "\imgWindowRight.bmp")
    MakeWindow TheForm
    Form4.Hide
    End Sub'设置边为椭圆
    'Public Sub DoTransparency(TheForm As Form)
        
        'Dim TempRegions(6) As Long
        'Dim FormWidthInPixels As Long
        'Dim FormHeightInPixels As Long
        'Dim a
        
        'FormWidthInPixels = TheForm.Width / Screen.TwipsPerPixelX
        'FormHeightInPixels = TheForm.Height / Screen.TwipsPerPixelY
        
    ' Make a rounded rectangle shaped region with the dimentions of the form
       'a = CreateRoundRectRgn(0, 0, FormWidthInPixels, FormHeightInPixels, 24, 24)
        
    ' Set this region as the shape for "TheForm"
       ' a = SetWindowRgn(TheForm.hWnd, a, True)
    'End Sub你事先得有一组图片(八部分)
    上面是模块中编写的,拿去调用就行了,调用:skinWindow me
      

  4.   

    一个很简单的办法:
    自己画图作皮肤(最好jpg教小),什么按钮之类的可见控件一起画上(还有窗口拖动条)
    然后用它作form的背景,原拖动条去掉(改form的属性,然后在那个位置加个image控件,用api使其有拖动窗口的能力),最后把控件拖到适当的位置,ok.
    尽管很笨,但非常完美,我试过不错。
      

  5.   

    回复人: intocsdn(小胖哥) ( ) 信誉:100  2003-11-4 0:49:44  得分:0 
     
     
      
    楼上的,我看了你的作品,不错,怎么弄的? 
     
    我光是SKIN的代码都好几千行:)