标题:VB6.0使用Image控件作为按钮使用,在切换图片的时候,为什么会闪一下?
取消只看楼主
小刀神
Rank: 1
等 级:新手上路
帖 子:69
专家分:5
注 册:2018-5-27
结帖率:91.67%
已结贴  问题点数:18 回复次数:1 
VB6.0使用Image控件作为按钮使用,在切换图片的时候,为什么会闪一下?
VB6.0使用Image控件作为按钮使用,在切换图片的时候,为什么会闪一下?
MouseDown事件以及MouseUp事件,这两个事件是会切换Image控件的Picture的
使用的是LoadPicture函数加载图片
每次切换图片的时候,Image控件都会闪烁一下,很难受,有大神知道解决方法的么?
部分代码如下:
程序代码:
Dim User
Dim User01
Dim User02 As String
Dim Order As String
Dim Order01
Dim UserAccount As String
Dim UserEncryption As String
Dim UserEncryption01
Dim UserAccountRandomNumber As String
Dim UserAccountRandomNumber01
Dim UserAccount01 As String
Dim 取字符 As String
Dim UserPassword As String
Dim UserPasswrodRandomNumber As String
Dim UserPasswordRandomNumber01
Dim UserPasswordEncryption As String
Dim UserPasswordEncryption01
Dim UserPassword01 As String
Dim ImagePath As String
Dim ImagePath01 As String
Public ImagePath02
Dim Image_登录_Change As Integer
Dim Image_退出_Change As Integer
Private Sub Form_Load()
Image_登录_Change = 0
Image_背景.Left = 0
Image_背景.Width = Form_登录.Width
Image_背景.Height = Form_登录.Height
Open "C:\LieMengWrite\Image\ImagePath.ini" For Input As #1 '读入图片素材路径信息
Do While Not EOF(1)
Line Input #1, ImagePath
ImagePath01 = ImagePath01 & ImagePath
Loop
Close #1
ImagePath02 = Split(ImagePath01, ";")
End Sub


Private Sub Image_背景_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ImageChange
If Image_登录_Change = 1 Then
    ImageChange = Split(ImagePath02(0), "=")
    Image_登录按钮.Picture = LoadPicture(ImageChange(1))
    Image_登录_Change = 0
End If
If Image_退出_Change = 1 Then
    ImageChange = Split(ImagePath02(3), "=")
    Image_退出.Picture = LoadPicture(ImageChange(1))
    Image_退出_Change = 0
End If
End Sub

Private Sub Image_登录按钮_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ImageChange
If Button = 1 Then
    ImageChange = Split(ImagePath02(2), "=")
    Image_登录按钮.Picture = LoadPicture(ImageChange(1))
End If
End Sub

Private Sub Image_登录按钮_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ImageChange
ImageChange = Split(ImagePath02(1), "=")
If Image_登录_Change = 0 Then
    Image_登录按钮.Picture = LoadPicture(ImageChange(1))
    Image_登录_Change = 1
End If
End Sub

Private Sub Image_登录按钮_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ImageChange
ImageChange = Split(ImagePath02(0), "=")
If Button = 1 Then
    Image_登录按钮.Picture = LoadPicture(ImageChange(1))
        计次 = 0
    Open "C:\LieMengWrite\User\UserAccount.LMW" For Input As #1 '读取用户信息文本文件
    Do While Not EOF(1)
    Line Input #1, User
    User02 = User02 & User
    Loop 'Until EOF(1)
    Close #1
    User01 = Split(User02, ";")
    Open "C:\LieMengWrite\User\Order\UserOrder.LMW" For Input As #1 '读取Order文件信息
    Do While Not EOF(1)
    Line Input #1, Order
    Order01 = Split(Order, ";")
    Loop
    Close #1
    If Order01(0) = "0" Then
        UserAccount = User01(0)
        UserPassword = User01(1)
    Else
        UserAccount = User01(1)
        UserPassword = User01(0)
    End If
    Open "C:\LieMengWrite\User\UserEncryption\User01.LMW" For Input As #1
    Do While Not EOF(1)
    Line Input #1, UserEncryption
    Loop
    Close #1
    UserEncryption01 = Split(UserEncryption, ";")
    Open "C:\LieMengWrite\User\RandomNumber\UserAccountRandomNumber.LMW" For Input As #1
    Do While Not EOF(1)
    Line Input #1, UserAccountRandomNumber
    Loop
    Close #1
    UserAccountRandomNumber01 = Split(UserAccountRandomNumber, ";")
    Open "C:\LieMengWrite\User\RandomNumber\UserPasswordRandomNumber.LMW" For Input As #1
    Do While Not EOF(1)
    Line Input #1, UserPasswordRandomNumber
    Loop
    Close #1
    UserPasswordRandomNumber01 = Split(UserPasswordRandomNumber, ";")
    Open "C:\LieMengWrite\User\UserEncryption\User02.LMW" For Input As #1
    Do While Not EOF(1)
    Line Input #1, UserPasswordEncryption
    Loop
    Close #1
    UserPasswordEncryption01 = Split(UserPasswordEncryption, ";")
If Text_账号.Text = "" Then
    'Print "账号不能为空"
    MsgBox "账号不能为空", , "警告"
Else
    If Text_密码.Text = "" Then
       
        'Print "密码不能为空"
        MsgBox "密码不能为空", , "警告"
      'a = MsgBox("密码", vbYesNo, "提示")
    Else
        取字符 = Left(Text_账号.Text, 1)
        UserAccount01 = UserEncryption01(0) & 取字符 & UserAccountRandomNumber01(0) & Text_账号.Text & UserEncryption01(1) & UserAccountRandomNumber01(1)
        If UserAccount01 = UserAccount Then
            取字符 = Left(Text_密码.Text, 1)
            UserPassword01 = UserPasswordEncryption01(0) & 取字符 & UserPasswordRandomNumber01(0) & Text_密码.Text & UserPasswordEncryption01(1) & UserPasswordRandomNumber01(1)
            If UserPassword01 = UserPassword Then
                'Print "登陆成功"
                MsgBox "登陆成功", , "警告"
                Form_登录.Hide
                Form_写作.Show
            Else
                'Print "账号或密码错误"
                MsgBox "账号或密码错误", , "警告"
            End If
            
        Else
            'Print "账号或密码错误"
            MsgBox "账号或密码错误", , "警告"
        End If
    End If
End If
End If
End Sub
搜索更多相关主题的帖子: Dim 登录 Input End If 
2018-06-23 22:56
小刀神
Rank: 1
等 级:新手上路
帖 子:69
专家分:5
注 册:2018-5-27
得分:0 
回复 2楼 风吹过b
多谢指点,让我多学到了一些东西,不过我的窗体使用的是没有标题栏的那种
主要想问问有没有什么控件或方法,在切换图像的时候,是不会闪烁的?
2018-06-24 14:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488106-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.818650 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved