找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 5426|回复: 2

[求助] 一个软键盘代码,请帮忙找下那里有问题

[复制链接]

6

主题

10

回帖

0

精华

铜牌会员

积分
98
发表于 2010-11-27 19:09:18 | 显示全部楼层 |阅读模式
代码如下,问题是点击软键两次之间的间隔有点长,还不能点着键不放连续输入,请大家帮忙看看。原码在下面 图片测试.7z (30.42 KB, 下载次数: 6330)
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "X:" & X & "Y:" & Y
Label2.Caption = "X:" & X / Screen.TwipsPerPixelX & "Y:" & Y / Screen.TwipsPerPixelY
If X < 38 * Screen.TwipsPerPixelX Then  '左侧小格段

        If Y > 2 * Screen.TwipsPerPixelY And Y < 19 * Screen.TwipsPerPixelY Then '+
                    With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
                    Text1.Text = Text1.Text & "+"
        End If
        If Y > 19 * Screen.TwipsPerPixelX And Y < 38 * Screen.TwipsPerPixelY Then '-
                    With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX + 19 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2 + 19, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
                    Text1.Text = Text1.Text & "-"
        End If
        If Y > 38 * Screen.TwipsPerPixelX And Y < 57 * Screen.TwipsPerPixelY Then '*
                     With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX + 38 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2 + 38, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
                    Text1.Text = Text1.Text & "×"
        End If
        If Y > 57 * Screen.TwipsPerPixelY And Y < 76 * Screen.TwipsPerPixelY Then '/
                    With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX + 57 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2 + 57, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
                    Text1.Text = Text1.Text & "÷"
        End If
        If Y > 76 * Screen.TwipsPerPixelX And Y < 95 * Screen.TwipsPerPixelY Then '=
                    With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX + 76 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2 + 76, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
                    Text1.Text = Text1.Text & "="
        End If
        If Y > 95 * Screen.TwipsPerPixelX And Y < 114 * Screen.TwipsPerPixelY Then '.
                    With Picture4
                    .Width = 34 * Screen.TwipsPerPixelX
                    .Height = 19 * Screen.TwipsPerPixelY
                    .Left = 2 * Screen.TwipsPerPixelY
                    .Top = 3 * Screen.TwipsPerPixelX + 95 * Screen.TwipsPerPixelX
                    End With
                    BitBlt Picture4.hDC, 0, 0, 38, 19, Picture3.hDC, 1, 2 + 95, vbSrcCopy
                    With Picture4
                    .Visible = True
                    .Refresh
                    End With
        Text1.Text = ""
        End If
Else
        If X > 40 * Screen.TwipsPerPixelX And X < 90 * Screen.TwipsPerPixelX Then '第一大格段
                If Y > 2 * Screen.TwipsPerPixelY And Y < 36 * Screen.TwipsPerPixelY Then '1
                            With Picture4
                            .Width = 50 * Screen.TwipsPerPixelX
                            .Height = 36 * Screen.TwipsPerPixelY
                            .Left = 40 * Screen.TwipsPerPixelY
                            .Top = 2 * Screen.TwipsPerPixelX
                            End With
                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 40, 2, vbSrcCopy
                            With Picture4
                            .Visible = True
                            .Refresh
                            End With
                            Text1.Text = Text1.Text & "1"
                End If
                If Y > 36 * Screen.TwipsPerPixelY And Y < 72 * Screen.TwipsPerPixelY Then '4
                            With Picture4
                            .Width = 50 * Screen.TwipsPerPixelX
                            .Height = 36 * Screen.TwipsPerPixelY
                            .Left = 40 * Screen.TwipsPerPixelY
                            .Top = 2 * Screen.TwipsPerPixelX + 40 * Screen.TwipsPerPixelX
                            End With
                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 40, 2 + 40, vbSrcCopy
                            With Picture4
                            .Visible = True
                            .Refresh
                            End With
                            Text1.Text = Text1.Text & "4"
                End If
                If Y > 72 * Screen.TwipsPerPixelY And Y < 108 * Screen.TwipsPerPixelY Then '7
                            With Picture4
                            .Width = 50 * Screen.TwipsPerPixelX
                            .Height = 36 * Screen.TwipsPerPixelY
                            .Left = 40 * Screen.TwipsPerPixelY
                            .Top = 2 * Screen.TwipsPerPixelX + 80 * Screen.TwipsPerPixelX
                            End With
                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 40, 2 + 80, vbSrcCopy
                            With Picture4
                            .Visible = True
                            .Refresh
                            End With
                            Text1.Text = Text1.Text & "7"
                End If
        Else
                If X > 90 * Screen.TwipsPerPixelX And X < 140 * Screen.TwipsPerPixelX Then '第2大格段
                        If Y > 2 * Screen.TwipsPerPixelY And Y < 36 * Screen.TwipsPerPixelY Then '2
                                    With Picture4
                                    .Width = 50 * Screen.TwipsPerPixelX
                                    .Height = 36 * Screen.TwipsPerPixelY
                                    .Left = 90 * Screen.TwipsPerPixelY
                                    .Top = 2 * Screen.TwipsPerPixelX
                                    End With
                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 90, 2, vbSrcCopy
                                    With Picture4
                                    .Visible = True
                                    .Refresh
                                    End With
                                    Text1.Text = Text1.Text & "2"
                        End If
                        If Y > 36 * Screen.TwipsPerPixelY And Y < 72 * Screen.TwipsPerPixelY Then '5
                                    With Picture4
                                    .Width = 50 * Screen.TwipsPerPixelX
                                    .Height = 36 * Screen.TwipsPerPixelY
                                    .Left = 90 * Screen.TwipsPerPixelY
                                    .Top = 2 * Screen.TwipsPerPixelX + 40 * Screen.TwipsPerPixelX
                                    End With
                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 90, 2 + 40, vbSrcCopy
                                    With Picture4
                                    .Visible = True
                                    .Refresh
                                    End With
                                    Text1.Text = Text1.Text & "5"
                        End If
                        If Y > 72 * Screen.TwipsPerPixelY And Y < 108 * Screen.TwipsPerPixelY Then '8
                                    With Picture4
                                    .Width = 50 * Screen.TwipsPerPixelX
                                    .Height = 36 * Screen.TwipsPerPixelY
                                    .Left = 90 * Screen.TwipsPerPixelY
                                    .Top = 2 * Screen.TwipsPerPixelX + 80 * Screen.TwipsPerPixelX
                                    End With
                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 90, 2 + 80, vbSrcCopy
                                    With Picture4
                                    .Visible = True
                                    .Refresh
                                    End With
                                    Text1.Text = Text1.Text & "8"
                        End If
                Else
               
                        If X > 140 * Screen.TwipsPerPixelX And X < 190 * Screen.TwipsPerPixelX Then '第3大格段
                                If Y > 2 * Screen.TwipsPerPixelY And Y < 36 * Screen.TwipsPerPixelY Then '3
                                            With Picture4
                                            .Width = 50 * Screen.TwipsPerPixelX
                                            .Height = 36 * Screen.TwipsPerPixelY
                                            .Left = 140 * Screen.TwipsPerPixelY
                                            .Top = 2 * Screen.TwipsPerPixelX
                                            End With
                                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 140, 2, vbSrcCopy
                                            With Picture4
                                            .Visible = True
                                            .Refresh
                                            End With
                                            Text1.Text = Text1.Text & "3"
                                End If
                                If Y > 36 * Screen.TwipsPerPixelY And Y < 72 * Screen.TwipsPerPixelY Then '6
                                            With Picture4
                                            .Width = 50 * Screen.TwipsPerPixelX
                                            .Height = 36 * Screen.TwipsPerPixelY
                                            .Left = 140 * Screen.TwipsPerPixelY
                                            .Top = 2 * Screen.TwipsPerPixelX + 40 * Screen.TwipsPerPixelX
                                            End With
                                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 140, 2 + 40, vbSrcCopy
                                            With Picture4
                                            .Visible = True
                                            .Refresh
                                            End With
                                            Text1.Text = Text1.Text & "6"
                                End If
                                If Y > 72 * Screen.TwipsPerPixelY And Y < 108 * Screen.TwipsPerPixelY Then '9
                                            With Picture4
                                            .Width = 50 * Screen.TwipsPerPixelX
                                            .Height = 36 * Screen.TwipsPerPixelY
                                            .Left = 140 * Screen.TwipsPerPixelY
                                            .Top = 2 * Screen.TwipsPerPixelX + 80 * Screen.TwipsPerPixelX
                                            End With
                                           BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 140, 2 + 80, vbSrcCopy
                                            With Picture4
                                            .Visible = True
                                            .Refresh
                                            End With
                                            Text1.Text = Text1.Text & "9"
                                End If
                        Else
                                If X > 190 * Screen.TwipsPerPixelX Then '第4大格段
                                        If Y > 2 * Screen.TwipsPerPixelY And Y < 36 * Screen.TwipsPerPixelY Then 'C
                                                    With Picture4
                                                    .Width = 50 * Screen.TwipsPerPixelX
                                                    .Height = 36 * Screen.TwipsPerPixelY
                                                    .Left = 190 * Screen.TwipsPerPixelY
                                                    .Top = 2 * Screen.TwipsPerPixelX
                                                    End With
                                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 190, 2, vbSrcCopy
                                                    With Picture4
                                                    .Visible = True
                                                    .Refresh
                                                    End With
                                                    If Text1.Text <> "" Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
                                        End If
                                        If Y > 36 * Screen.TwipsPerPixelY And Y < 72 * Screen.TwipsPerPixelY Then 'enter
                                                    With Picture4
                                                    .Width = 50 * Screen.TwipsPerPixelX
                                                    .Height = 36 * Screen.TwipsPerPixelY
                                                    .Left = 190 * Screen.TwipsPerPixelY
                                                    .Top = 2 * Screen.TwipsPerPixelX + 40 * Screen.TwipsPerPixelX
                                                    End With
                                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 190, 2 + 40, vbSrcCopy
                                                    With Picture4
                                                    .Visible = True
                                                    .Refresh
                                                    End With
                                        End If
                                        If Y > 72 * Screen.TwipsPerPixelY And Y < 108 * Screen.TwipsPerPixelY Then '0
                                                    With Picture4
                                                    .Width = 50 * Screen.TwipsPerPixelX
                                                    .Height = 36 * Screen.TwipsPerPixelY
                                                    .Left = 190 * Screen.TwipsPerPixelY
                                                    .Top = 2 * Screen.TwipsPerPixelX + 80 * Screen.TwipsPerPixelX
                                                    End With
                                                   BitBlt Picture4.hDC, 0, 0, 50, 36, Picture3.hDC, 190, 2 + 80, vbSrcCopy
                                                    With Picture4
                                                    .Visible = True
                                                    .Refresh
                                                    End With
                                                    Text1.Text = Text1.Text & "0"
                                        End If
                                End If
                        End If


                End If

        End If


End If

End Sub

Private Sub Form_Load()
a = 0
   With Picture2
   .AutoRedraw = True
    .Width = 2928 '240 * Screen.TwipsPerPixelX
    .Height = 1464 '120 * Screen.TwipsPerPixelY
   End With
      With Picture1
      .Enabled = False
      .Visible = False
      .AutoRedraw = True
    .Width = 2928 '240 * Screen.TwipsPerPixelX
    .Height = 2968 '120 * Screen.TwipsPerPixelY
   End With
      With Picture3
      .Enabled = False
      .Visible = False
      .AutoRedraw = True
    .Width = 2928 '240 * Screen.TwipsPerPixelX
    .Height = 1464 '120 * Screen.TwipsPerPixelY
   End With
        With Picture4
        .AutoRedraw = True
   .Visible = False
    .Width = 0
    .Height = 0
    .Enabled = False
   End With
Picture1.Picture = LoadPicture("num1.bmp")
Picture1.Refresh
Text1.Text = ""
ini
End Sub

'大格宽49,高36
'小格宽38,高19
'绿大格X122Y40,下一个X+40,Y+50.绿小格X123,Y3.下一个X+19,Y+0


Private Sub ini() '初始化界面
            BitBlt Picture2.hDC, 0, 0, 240, 120, Picture1.hDC, 0, 0, vbSrcCopy
            Picture2.Refresh
            BitBlt Picture3.hDC, 0, 0, 240, 120, Picture1.hDC, 0, 120, vbSrcCopy
            Picture3.Refresh
End Sub



Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture4.Visible = False
End Sub

6

主题

10

回帖

0

精华

铜牌会员

积分
98
 楼主| 发表于 2010-11-28 11:04:38 | 显示全部楼层
帮忙看下,急

275

主题

3017

回帖

1

精华

管理员

嗷嗷叫的老马

积分
17064

论坛牛人贡献奖关注奖最佳版主进步奖人气王疯狂作品奖精英奖赞助论坛勋章乐于助人勋章

QQ
发表于 2011-3-28 15:30:35 | 显示全部楼层
速度慢的原因是还有双击与单击事件在影响着,这个貌似没啥好办法.

至于连续按着不放也能自动出字符,需要你自己写代码实现,思路:

鼠标按下时记录数值,并启动定时器A,定时器A的时间就是判断连续按键的时间;

定时器A触发后,说明按下足够长的时间了,启动定时器B,进行连续输入字符.

鼠标抬起时,关闭定时器.
我就是嗷嗷叫的老马了......

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表