Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 2nd, 2004, 04:56 PM
IamaVBNewbie IamaVBNewbie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 IamaVBNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Help me please :((

im been trying for ages and i can't seem to be able to make a button which will send my application to the system tray . could some one give me a idiot guild in how to do this or a very basic code in which i can teach my self by (


thank you in advanced

Jamie

Reply With Quote
  #2  
Old February 2nd, 2004, 05:14 PM
minor28 minor28 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Sweden
Posts: 245 minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 6 m 11 sec
Reputation Power: 14
Well, this question was on the board a couple of days ago. Actually you are not sending the app to the systray. You just hide the window and set an icon in the tray. You can look at the thread System Tray

Reply With Quote
  #3  
Old February 2nd, 2004, 05:23 PM
IamaVBNewbie IamaVBNewbie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 IamaVBNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
not really a newbie guide

Reply With Quote
  #4  
Old February 2nd, 2004, 05:33 PM
minor28 minor28 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Sweden
Posts: 245 minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 6 m 11 sec
Reputation Power: 14
If I sed you a demo I am sure you wouldn't learn anything. But I can guide you through the process if you want but it must be you who writes the code. OK?

Reply With Quote
  #5  
Old February 2nd, 2004, 05:52 PM
IamaVBNewbie IamaVBNewbie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 IamaVBNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sure ok umm well if ya email the guide to me ill get back to you im outta time tonight ...

Address : Stvsrmat@aol.com


Thank you in adv.

Jamie

Reply With Quote
  #6  
Old February 2nd, 2004, 06:00 PM
minor28 minor28 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Sweden
Posts: 245 minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 6 m 11 sec
Reputation Power: 14
Well, my thought was you write code, post it on the board, we comment on you code.

First step: Create a project with a form and all controls you want on the form.

I suppose you are not a beginner since you want to start with this coding. Am I right?

Reply With Quote
  #7  
Old February 2nd, 2004, 07:21 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
IamaVBNewbie
The administrators are going to tell you this anyway, so I'll tell you. You need to pick more descriptive names for your posts.

Reply With Quote
  #8  
Old February 3rd, 2004, 10:37 AM
IamaVBNewbie IamaVBNewbie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 IamaVBNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by minor28
Well, my thought was you write code, post it on the board, we comment on you code.

First step: Create a project with a form and all controls you want on the form.

I suppose you are not a beginner since you want to start with this coding. Am I right?


Iv got all buttons etc. but it is more then 1 form.

so basicly i do kinda need coding .

Thank you in advanced

Jamie

Reply With Quote
  #9  
Old February 3rd, 2004, 05:17 PM
minor28 minor28 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Sweden
Posts: 245 minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 6 m 11 sec
Reputation Power: 14
OK IamaVBNewbie, I have coded a demo for you.

1. Start a standard exe project.
2. Name the form "frmSysTrayIcon"
3. Insert a commandbutton "Command1"
4. Add a module. Name it "mSysTrayIcon"
5. Past the first part to form code editor.
6. Past the rest to module code editor.

Now you can hide the form and get an icon in systray by clicking the command button or the minimize button in sysmenu.

By the way. The most elegant way is a button click sending a SendMessage to window process. But I don't know how to set the SC_MINIMIZE to high word of wParam and how to and wParam with 0FFFFh. Who knows?
Form code:
Code:
Option Explicit

Private Sub Command1_Click()
'    SendMessage frmSysTrayIcon.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0
    note.cbSize = Len(note)
    note.hwnd = frmSysTrayIcon.hwnd
    note.uID = IDI_TRAY
    note.uFlags = NIF_ICON + NIF_MESSAGE + NIF_TIP
    note.uCallbackMessage = WM_SHELLNOTIFY
    note.hIcon = LoadIcon(ByVal 0&, IDI_WINLOGO)
    note.szTip = "Test Form" & Chr$(0)
    Shell_NotifyIcon NIM_ADD, note
    frmSysTrayIcon.Hide
End Sub

Private Sub Form_Load()
    hPopupMenu = CreatePopupMenu
    AppendMenu hPopupMenu, MF_STRING, IDM_RESTORE, "&Restore"
    AppendMenu hPopupMenu, MF_STRING, IDM_EXIT, "E&xit Program"
    OldWndProc = SetWindowLong(frmSysTrayIcon.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Module code:
Code:
Option Explicit

Public Const GWL_WNDPROC = (-4)
Public Const WM_SYSCOMMAND = &H112
Public Const SC_MINIMIZE = &HF020&
Public Const SC_RESTORE = &HF120&
Public Const SC_CLOSE = &HF060&
Public Const IDI_TRAY = 0
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_USER = &H400
Public Const WM_SHELLNOTIFY = WM_USER + 5
Public Const IDI_WINLOGO = 32517
Public Const WM_COMMAND = &H111
Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_LBUTTONDBLCLK = &H203
Public Const IDM_RESTORE = 1000
Public Const IDM_EXIT = 1010
Public Const MF_STRING = &H0&
Public Const TPM_RIGHTALIGN = &H8&
Public Const TPM_RIGHTBUTTON = &H2&

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 Type POINTAPI
    x As Long
    y As Long
End Type

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
    (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Declare Function LoadIcon Lib "user32" Alias "LoadIconA" _
    (ByVal hInstance As Long, ByVal lpIconName As Long) As Long

Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" _
    (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Public Declare Function CreatePopupMenu Lib "user32" () As Long

Public Declare Function TrackPopupMenu Lib "user32" _
    (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, ByVal lprc As Any) As Long

Public Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" _
    (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long

Public Declare Function DestroyMenu Lib "user32" _
    (ByVal hMenu As Long) As Long

Public Declare Function GetCursorPos Lib "user32" _
    (lpPoint As POINTAPI) As Long

Public Declare Function SetForegroundWindow Lib "user32" _
    (ByVal hwnd As Long) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long

Public hPopupMenu As Long
Public OldWndProc As Long

Public note As NOTIFYICONDATA
Dim pt As POINTAPI

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If uMsg = WM_SYSCOMMAND Then
        If wParam = SC_MINIMIZE Then
            note.cbSize = Len(note)
            note.hwnd = frmSysTrayIcon.hwnd
            note.uID = IDI_TRAY
            note.uFlags = NIF_ICON + NIF_MESSAGE + NIF_TIP
            note.uCallbackMessage = WM_SHELLNOTIFY
            note.hIcon = LoadIcon(ByVal 0&, IDI_WINLOGO)
            note.szTip = "Test Form" & Chr$(0)
            Shell_NotifyIcon NIM_ADD, note
            frmSysTrayIcon.Hide
        ElseIf wParam = SC_CLOSE Then
            If MsgBox("Close form?", vbYesNo Or vbQuestion) = vbYes Then
                Unload frmSysTrayIcon
                DestroyMenu hPopupMenu
            End If
        Else
            WindowProc = CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam)
        End If
    ElseIf uMsg = WM_COMMAND Then
        If lParam = 0 Then
            If wParam = IDM_RESTORE Then
                frmSysTrayIcon.Show
            ElseIf wParam = IDM_EXIT Then
                Unload frmSysTrayIcon
                DestroyMenu hPopupMenu
            End If
            Shell_NotifyIcon NIM_DELETE, note
        End If
        WindowProc = CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam)
    ElseIf uMsg = WM_SHELLNOTIFY Then
        If wParam = IDI_TRAY Then
            If lParam = WM_RBUTTONDOWN Then
                GetCursorPos pt
                SetForegroundWindow hwnd
                TrackPopupMenu hPopupMenu, TPM_RIGHTALIGN + TPM_RIGHTBUTTON, _
                                    pt.x, pt.y, 0, hwnd, ByVal 0&
            ElseIf lParam = WM_LBUTTONDBLCLK Then
                frmSysTrayIcon.Show
                Shell_NotifyIcon NIM_DELETE, note
            End If
        End If
    Else
        WindowProc = CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam)
    End If
End Function


Good luck with the code.

Reply With Quote
  #10  
Old February 3rd, 2004, 05:23 PM
minor28 minor28 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Sweden
Posts: 245 minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level)minor28 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 6 m 11 sec
Reputation Power: 14
I attach the project
Attached Files
File Type: zip systrayicon.zip (3.0 KB, 252 views)

Reply With Quote
  #11  
Old February 4th, 2004, 03:00 AM
IamaVBNewbie IamaVBNewbie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 IamaVBNewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wopppy thats a bigger code then i though . ty m8 .. iv not got time to test it now ill do it @ college thank you very much

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Help me please :((


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |