老兄:
你的问题在于你点击任务栏的时候,焦点已转移到任务栏上了。
form1.show只是把自己显示出来
再加一个API激活就OK了我有一问:
你那句msg = X / Screen.TwipsPerPixelX
是那找来的???
蛮经典的!
可怎么理解呢?
谢谢。

解决方案 »

  1.   

    我还看到这样的写法:
    If me.scale = vbpixels then
    msg = x 
    else
    msg = X / Screen.TwipsPerPixelX
    end if
    不知道对各位有无帮助。我还是看不懂。
      

  2.   

    在Form1.Visible = True下面加上
    Form1.SetFocus
    或直接用Form1.Show也可以To:Didy
    form1.show 就把自己显示出来并激活。When you pass the mouse pointer over the icon in the taskbar status area, the form receives the message WM_MOUSEMOVE. This message maps to the form's MouseMove event. The X argument is the product of one of the mouse constants that indicates the mouse input (such as a left-click, right-click, single-click, or double-click) and the TwipsPerPixelX property of the screen. The mouse input is produced by dividing the X argument with this property. The mouse input is then used in a Select Case statement to execute a series of instructions. 
    From MSDN
      

  3.   

    to didy
    我也是抄来的,不过王国荣那本书上不是这样处理的。
      

  4.   

    .show
    .setfocus
    我试了,不行。
      

  5.   

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)Static Message As Long
    Static RR As Boolean
        
        'x is the current mouse location along the x-axis
        Message = X / Screen.TwipsPerPixelX
        
        If RR = False Then
            RR = True
            Select Case Message
                ' Left double click (This should bring up a dialog box)
                Case WM_LBUTTONDBLCLK
                    Me.Show
                ' Right button up (This should bring up a menu)
                Case WM_RBUTTONUP
                    Me.Hide 'PopupMenu mnuPopUp
            End Select
            RR = False
        End If
        
    End Sub
      

  6.   

    用setwindowpos把窗体置为topmost窗好了...
      

  7.   

    我要投降了!
    我把它设置为topmost了,
    但还是不太正常。我把showintaskbar打开,则可以观察到:
    当双击托盘图标后,窗口弹出,窗口标题栏闪动,同时任务栏也闪动(蓝,白)。
    闪几下后,窗口正常,但任务栏依然是蓝底。而原来的窗口显示依然为有
    焦点状,对应任务栏依然凹下,呈焦点壮。
    点击弹出窗口后,一切正常。
    用SYSTRAY控件则没有这些情况。
      

  8.   

    使用Form1.Show应该就可以了啊,要不可以再加上一个API函数
    SetActiveWindow来试试。
      

  9.   

    我换到NT下去运行,没有问题,
    也许是我的98或VB有问题吧。
    劳动各位大虾了
      

  10.   

    to erycrin:
    msg = X / Screen.TwipsPerPixelX
    x返回的是鼠标移动的横向位置,或是鼠标按键按下的信息,单位是twip
    而msg的单位是pixel.
    我是这样理解的。