控件中有一个LABEL,一个PICTURE,(LABEL在PICTURE中)
我现在设置了PICTURE的CLICK事件,有效,可是为什么设置LABEL的CLICK就无效呢?
这是PICTURE的CLICK事件private sub picture1_click()
    raiseevent click
end sub这是LABEL的CLICK事件代码:
private sub label1_click()
    call picture1_click()
end sub
为什么会失效啊?

解决方案 »

  1.   

    Option Explicit'事件声明:
    Event Click()Private Sub Label1_Click()
      MsgBox "Label1_Click"
      RaiseEvent Click
    End SubPrivate Sub Picture1_Click()
      MsgBox "Picture1_Click"
      RaiseEvent Click
    End Sub
      

  2.   

    我已经声明过了啊。没用的。
    这是我的代码:Option Explicit
    '事件声明:Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    'Dim disablepicture As PictureEvent Click() 'MappingInfo=Picture1,Picture1,-1,Click
    Event DblClick() 'MappingInfo=Picture1,Picture1,-1,DblClick
    Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyDown
    Event KeyPress(KeyAscii As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyPress
    Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=Picture1,Picture1,-1,KeyUp
    Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Picture1,Picture1,-1,MouseDown
    Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Picture1,Picture1,-1,MouseMove
    Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=Picture1,Picture1,-1,MouseUp
    Event Resize() 'MappingInfo=Picture1,Picture1,-1,ResizePublic Enum BackStyleSelection
    [透明] = 0
    [不透明] = 1
    End Enum
    Private NewBS As BackStyleSelectionPrivate Sub Label1_Click()
    MsgBox "clicked"
    End SubPrivate Sub Picture1_Click()
    RaiseEvent Click
    End Sub
      

  3.   

    你是不是需要添加两个Click,将你的想法告诉我,我帮你看看。
      

  4.   

    我在做一个类似于office xp的按钮,现在效果出来了。
    也就是可以实现按钮的over和out事件,但是按钮的CAPTION是用的一个LABEL来实现的,我用的是PICTURE控件来检测OVER和OUT事件的,现在PICTURE可以使用,可是当鼠标移到LABEL上的时候,CLICK事件失效,我就想到当LABEL有CLICK事件的时候,调用PICTURE的CLICK事件,但是不成功,单独加上CLICK也不能执行,不知道为什么。
      

  5.   

    哦,可以通过Api的Setcapture给控件戴上鼠标跟踪器,就可以检测鼠标的移动了,Caption可以使用函数DrawText来实现。
      

  6.   

    老兄你的代码我试过了没有问题啊
    另外你的label是放在picturebox中吧
      

  7.   

    是啊,但是在我这里却有问题啊。
    另外,我发现我再在PICTUREBOX中放一个LABEL的话,这个新的LABEL却能检测到CLICK事件,出鬼了。APPLE200228:能告诉如何使用DRAWTEXT吗?可否给个范例,谢谢。
      

  8.   

    帮帮忙啊关于DRAWTEXT,我在MSN中没有发现啊。
      

  9.   

    Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Const CLR_INVALID = -1
    Private Const COLOR_HIGHLIGHT = 13
    Private Const COLOR_BTNFACE = 15
    Private Const COLOR_BTNSHADOW = 16
    Private Const COLOR_BTNTEXT = 18
    Private Const COLOR_BTNHIGHLIGHT = 20
    Private Const COLOR_BTNDKSHADOW = 21
    Private Const COLOR_BTNLIGHT = 22
    Private Type POINTAPI
        x As Long
        y As Long
    End TypePublic Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    Public Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
    Public Sub DrawTheText(DestDC As Long, sText As String, iTextLength As Long, rc As RECT, DTF As Long)
        'DrawText DestDC, sText,  LenB(StrConv(sText, vbFromUnicode)) iTextLength, rc, DTF
        DrawText DestDC, sText, LenB(StrConv(sText, vbFromUnicode)), rc, DTF
    End SubPublic Sub SetTheTextColor(DestDC As Long, oColor As OLE_COLOR)
        SetTextColor DestDC, oColor
    End Sub
      

  10.   

    调用方法;
        在PictureBox  picTop上写字
        DrawTheText picTop.hdc, "这是一个测试", 1, rc, 0