Results 1 to 7 of 7

Thread: Putting a custom icon into the form caption bar - minimize to tray

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Location
    Novosibirsk, Russia
    Posts
    170

    Putting a custom icon into the form caption bar - minimize to tray

    Hi!

    I wonder how this can be done? I've just made a very small programmer's utility for generating Property Procedure listings from a list of variables, and I wonder how I can keep this form handy at all times. A tray icon could be handy. I already have the trayicon class and it's working, but I need to hide the form from a custom command button procedure instead of by minimizing.

    Thanks in advance,
    Stas
    Stanislav Okhvat
    [email protected]
    VB, PHP

  2. #2
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Location
    Novosibirsk, Russia
    Posts
    170

    That's not exactly what I meant

    Hi!

    Thanks for the tip!

    Actually, I already have a tray icon class that does the work. However, the problem is that I have to minimize my application to the tray somehow. If I just minimize the form, I can hide it without a problem, but when I double-click the icon in the tray, I want the form to show up again, which is not possible (unless there is a method of showing the form after it has been minimized without clicking on the task bar icon).

    I figured the best way would be to add a small button next to the minimize button near the form's X button. When the user clicks it, I hide the form and show the icon in the tray. When the user double-clicks the system tray icon, I delete the icon from the systray and show the form again.

    I know this can be done with API, but I don't want to spend another day getting it done if there's a ready-made solution.

    Thanks in advance,

    Stas
    Stanislav Okhvat
    [email protected]
    VB, PHP

  4. #4
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    You can subclass the form and whenever the Shell_NotifyIcon's CallbackMessage comes up, UNHIDE and reset the windowstate property to 0 for a normal form.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Location
    Novosibirsk, Russia
    Posts
    170

    Thanks, I figured it out

    Hi!

    Thanks for the tip. I actually thought about setting WindowState to vbNormal, but I thought the property is read-only. I had to make a form-level boolean variable to know whether the form is minimized so when I double-click the systray icon and the resize event occurs, it doesn't put the app into the systray again.

    Best,
    Stas
    Stanislav Okhvat
    [email protected]
    VB, PHP

  6. #6
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    The easiest way that I know of is this: go to www.kedaman.com and download the kedatray ocx Kedaman has made. It works really good, and it's really simple to use. Then in the form_resize() sub add this code.
    Code:
    Private Sub Form_Resize()
    If Form1.WindowState = vbMinimized Then
        Form1.Hide 'if you minimize it, it hides it
    ElseIf Form1.WindowState = vbNormal Then
        Form1.Show 'shows the form when you bring it back
    End If
    End Sub
    
    Private Sub Trayicon1_MouseDblClick(Button As Variant)
    Form1.WindowState = vbNormal 'sets the window visible again
    Form1.Show 'shows the form when you double click the icon in the tray
    End Sub
    <removed by admin>

  7. #7
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Here is the kedatray.ocx file
    Attached Files Attached Files
    <removed by admin>

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