Results 1 to 5 of 5

Thread: form question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    form question

    is it possible to be able to minimize a form (so it appears in system tray), and also have it number 3 of border style (fixed size) , becasue if i have it number3 borderstyle only it causes me problems like..

    i have to minimize all other applications to view the form


    any idea on how to make it minimizable but NOT sizable at the same time?

  2. #2
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: form question

    Check this control - its probebly the easyest way to add an icon to system tray
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  3. #3
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: form question

    If you are looking for a code then try this:

    To make a right click menu just make a menu called "m"

    VB Code:
    1. 'declaration for putting the application to system tray
    2. Private Type NOTIFYICONDATA
    3.     cbSize As Long
    4.     hwnd As Long
    5.     uId As Long
    6.     uFlags As Long
    7.     uCallBackMessage As Long
    8.     hIcon As Long
    9.     szTip As String * 64
    10. End Type
    11.  
    12.     'declare constants
    13. Private Const NIM_ADD = &H0
    14. Private Const NIM_MODIFY = &H1
    15. Private Const NIM_DELETE = &H2
    16.  
    17. 'The following constant is the message sent when a mouse event occurs
    18. 'within the rectangular boundaries of the icon in the taskbar status area.
    19.  
    20. Private Const WM_MOUSEMOVE = &H200
    21.  
    22. 'The following constants are the flags that indicate the valid
    23. 'members of the NOTIFYICONDATA data type.
    24. Private Const NIF_MESSAGE = &H1
    25. Private Const NIF_ICON = &H2
    26. Private Const NIF_TIP = &H4
    27.  
    28. 'The following constants are used to determine the mouse input on the
    29. 'the icon in the taskbar status area.
    30.  
    31.     'Left-click constants.
    32. Private Const WM_LBUTTONDBLCLK = &H203   'Double-click
    33. Private Const WM_LBUTTONDOWN = &H201     'Button down
    34. Private Const WM_LBUTTONUP = &H202       'Button up
    35.  
    36.     'Right-click constants.
    37. Private Const WM_RBUTTONDBLCLK = &H206   'Double-click
    38. Private Const WM_RBUTTONDOWN = &H204     'Button down
    39. Private Const WM_RBUTTONUP = &H205       'Button up
    40.  
    41.     'Declare the API function call.
    42. Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    43.  
    44. 'Dimension a variable as the user-defined data type.
    45. Dim nid As NOTIFYICONDATA
    46. 'write the following in the form load event
    47. 'if ur application as MDI write in MDI_Load else the first form_load event
    48.  
    49. Private Sub Form_Load()
    50.     Me.Hide
    51.     nid.cbSize = Len(nid)
    52.         nid.hwnd = Me.hwnd
    53.         nid.uId = vbNull
    54.         nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    55.         nid.uCallBackMessage = WM_MOUSEMOVE
    56.         nid.hIcon = Me.Icon
    57.    'u can give a tool tip text here
    58.         nid.szTip = "My System Tray Message" & vbNullChar
    59.        'Call the Shell_NotifyIcon function to add the icon to the System Tray
    60.  
    61.         Shell_NotifyIcon NIM_ADD, nid
    62.         MsgBox "In system tray"
    63. End Sub
    64.  
    65. 'create a menu by using menu editor
    66. '   one main menu by Caption"Menu" name "M"
    67. '   one sub menu by name caption "Exit" name "Ex"
    68. 'make the Menu invisible by changing the "visibility" option in properties window
    69.  
    70. 'write the following in MouseMove event
    71. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    72. Dim msg As Long
    73. Dim sFilter As String
    74. msg = X / Screen.TwipsPerPixelX
    75.     Select Case msg
    76.         Case WM_LBUTTONDOWN
    77.         '      Me.PopupMenu M   'if u want u can call the popup menu
    78.         Case WM_LBUTTONUP
    79.         Case WM_LBUTTONDBLCLK
    80.         Case WM_RBUTTONDOWN
    81.         Case WM_RBUTTONUP
    82.             Me.PopupMenu m  'call the popup menu
    83.         Case WM_RBUTTONDBLCLK
    84.     End Select
    85. End Sub

    To unload
    VB Code:
    1. Shell_NotifyIcon NIM_DELETE, nid
    Last edited by wiz126; Dec 8th, 2005 at 06:14 PM.
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  4. #4
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: form question

    Oh way i forgat:

    to unload the system try icon:

    VB Code:
    1. Shell_NotifyIcon NIM_DELETE, nid
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  5. #5
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: form question

    remember to add the menu

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