NotifyIconA question...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    #1

    NotifyIconA question...

    Hello all,

    I am trying to minimize a program to the Systray. I have the code, it
    works if I create a new project and insert the code. But when I add it
    to an existing program the trouble starts.

    It will minimize to the tray fine, but I cannot recall it. I have a
    STOP statement in the MOUSEMOVE segment, but it doesn't trip when the
    program ICON is displayed in the tray. I have to stop the program to
    get out.

    Why would it hide the form and display the ICON on the tray, but not
    accept any input beyond that?

    Here is some of the code I am using...

    ---------------------------------------------------------------------
    Public Type NOTIFYICONDATA
    cbSize As Long
    hwnd As Long
    uId As Long
    uFlags As Long
    uCallBackMessag e As Long
    hIcon As Long
    szTip As String * 64
    End Type

    Public nid As NOTIFYICONDATA

    in the FORM_LOAD...
    nid.cbSize = Len(nid)
    nid.hwnd = Main.hwnd
    nid.uId = 0
    nid.uId = nid.uId + 1
    nid.uFlags = &H1 Or &H2 Or &H4
    nid.uCallBackMe ssage = &H200
    nid.hIcon = Main.Icon
    nid.szTip = "Salary Viewer" & Chr(0)

    Private Sub Form_Resize()
    If WindowState = 1 Then
    Main.Hide
    Main.Refresh
    Shell_NotifyIco n &H0, nid
    Else
    Shell_NotifyIco n &H2, nid
    End If
    End Sub


    Private Sub Form_MouseMove( Button As Integer, Shift As Integer, x As
    Single, Y As Single)
    Dim Sys As Long

    DoEvents
    stop
    Sys = x / Screen.TwipsPer PixelX
    Select Case Sys
    Case &H204
    PopupMenu mnusystray
    End Select
    End Sub
    ---------------------------------------------------------------------



    Thanks in advance,


    ---------------------------------------------------
    Brian Howe

    Information is power. Thanks to all who empower me
    ---------------------------------------------------
  • Randy Birch

    #2
    Re: NotifyIconA question...

    Don't try to use the magic number method ... there is a right way ...
    VBnet provides Intermediate and Advanced Win32 API code for VB developers. Comprehensive Code, FAQ, Developers Resources & News, alphabetical API/Type/Constant/Method Index, along with the largest Visual Basic-related links list on the net.


    --

    Randy Birch
    MVP Visual Basic

    Please respond only to the newsgroups so all can benefit.


    "Brian" <NOSPAM@This.Ad dress> wrote in message
    news:0s8d50hv9u jh1mh2n06fqgkch tkptt825s@4ax.c om...
    : Hello all,
    :
    : I am trying to minimize a program to the Systray. I have the code, it
    : works if I create a new project and insert the code. But when I add it
    : to an existing program the trouble starts.
    :
    : It will minimize to the tray fine, but I cannot recall it. I have a
    : STOP statement in the MOUSEMOVE segment, but it doesn't trip when the
    : program ICON is displayed in the tray. I have to stop the program to
    : get out.
    :
    : Why would it hide the form and display the ICON on the tray, but not
    : accept any input beyond that?
    :
    : Here is some of the code I am using...
    :
    : ---------------------------------------------------------------------
    : Public Type NOTIFYICONDATA
    : cbSize As Long
    : hwnd As Long
    : uId As Long
    : uFlags As Long
    : uCallBackMessag e As Long
    : hIcon As Long
    : szTip As String * 64
    : End Type
    :
    : Public nid As NOTIFYICONDATA
    :
    : in the FORM_LOAD...
    : nid.cbSize = Len(nid)
    : nid.hwnd = Main.hwnd
    : nid.uId = 0
    : nid.uId = nid.uId + 1
    : nid.uFlags = &H1 Or &H2 Or &H4
    : nid.uCallBackMe ssage = &H200
    : nid.hIcon = Main.Icon
    : nid.szTip = "Salary Viewer" & Chr(0)
    :
    : Private Sub Form_Resize()
    : If WindowState = 1 Then
    : Main.Hide
    : Main.Refresh
    : Shell_NotifyIco n &H0, nid
    : Else
    : Shell_NotifyIco n &H2, nid
    : End If
    : End Sub
    :
    :
    : Private Sub Form_MouseMove( Button As Integer, Shift As Integer, x As
    : Single, Y As Single)
    : Dim Sys As Long
    :
    : DoEvents
    : stop
    : Sys = x / Screen.TwipsPer PixelX
    : Select Case Sys
    : Case &H204
    : PopupMenu mnusystray
    : End Select
    : End Sub
    : ---------------------------------------------------------------------
    :
    :
    :
    : Thanks in advance,
    :
    :
    : ---------------------------------------------------
    : Brian Howe
    :
    : Information is power. Thanks to all who empower me
    : ---------------------------------------------------


    Comment

    Working...