Results 1 to 10 of 10

Thread: Icon help pls.....

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143

    Wink

    Hello,

    Okay a couple things i need help on.

    When my program in minimized I want the icon for the app to be placed in the lower right hand corner of the screen ( I dont think its called the tasbar, but anyway )so i need help on that.

    Second, I tried setting the icon to the form in code>
    frmmain.icon = app.path & "\binoculr.ico"
    But that doesnt work either.

    Thanks .


  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Question Do you mean next to the clock?

    in the "System Tray"?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143

    Wink

    Yes that is it

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Try this..

    Follow this link...this should get you going

    http://www.vbsquare.com/tips/tip178.html


    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    okay i keep getting error message on
    Code:
    PopupMenu frmMain

    here is the full code i am using.
    Code:
    Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    
    Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1
    Public Const NIM_DELETE = &H2
    Public Const NIF_MESSAGE = &H1
    Public Const NIF_ICON = &H2
    Public Const NIF_TIP = &H4
    Public Const WM_LBUTTONUP = &H202
    Public Const WM_RBUTTONUP = &H205
    Public Const WM_MOUSEMOVE = &H200
    
    
    Public Type NOTIFYICONDATA
      cbSize As Long
      hwnd As Long
      uId As Long
      uFlags As Long
      ucallbackMessage As Long
      hIcon As Long
      szTip As String * 64
    End Type
    
    Public VBGTray As NOTIFYICONDATA
    
    Private Sub GoSystemTray()
      VBGTray.cbSize = Len(VBGTray)
      VBGTray.hwnd = Me.hwnd
      VBGTray.uId = vbNull
      VBGTray.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
      VBGTray.ucallbackMessage = WM_MOUSEMOVE
      VBGTray.hIcon = Me.Icon
      'tool tip text
      VBGTray.szTip = Me.Caption & vbNullChar
      Call Shell_NotifyIcon(NIM_ADD, VBGTray)
      App.TaskVisible = False   'remove application from taskbar
      Me.Hide
    End Sub
    
    Private Sub Form_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)
      Static lngMsg As Long
      Static blnFlag As Boolean
      Dim result As Long
    lngMsg = X / Screen.TwipsPerPixelX
      If blnFlag = False Then
            blnFlag = True
            Select Case lngMsg
            'right-click
            Case WM_RBUTTONUP
              result = SetForegroundWindow(Me.hwnd)
              PopupMenu frmMain
             Case WM_LBUTTONUP
              result = SetForegroundWindow(Me.hwnd)
              c
            End Select
            blnFlag = False
     End If
    End Sub
    
    Private Sub Form_Resize()
    If Me.WindowState = 1 Then
    Call GoSystemTray
    End If
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
      VBGTray.cbSize = Len(VBGTray)
      VBGTray.hwnd = Me.hwnd
      VBGTray.uId = vbNull
      Call Shell_NotifyIcon(NIM_DELETE, VBGTray)
    End Sub
    Any help would be great.
    Thanks

    ps. I tried using PopupMenu mypopupmenu but that error'd as well.

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    and for loading your icon at runtime:

    Code:
    frmmain.icon = loadpicture(app.path & "\binoculr.ico")
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Oh sorry didn't see your reply

    Code:
    PopupMenu frmMain
    Doesn't work because frmMain is a form, and you need to pass a menu

    Make a menu with the Menu Editor (CTRL + E) and call it
    mnuPop

    then replace
    Code:
    PopupMenu frmMain
    with
    Code:
    PopupMenu mnuPop
    and all will be cool.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    okay Jop getting closer.


    Now when I click on the icon in systray it brings up a sub menu which i made.

    What code do i put in the submenu click event??
    So far i tried.
    frmmain.show
    frmmain.visible=true
    But none work.

    Help

  9. #9
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    What code do i put in the submenu click event??
    Well that depends on what you want to do

    I assume you have minimized the form and set it's visible property to false?

    try this
    Code:
    Private Sub mnuPop_Click()
        Form1.Windowstate = 0
        Form1.Visible = True
    End Sub
    did that work?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    Yes Jop that did work.
    I dont know why I didnt think about the window state.
    I got all caught up in the icon that i forgot what I was really doing which was minimizing the form.


    But thanks again Jop and everyone else.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width