Announcement

Collapse
No announcement yet.

Start in the Tray

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Start in the Tray

    Using your Tray example, how would one start in the tray?

    I have tried several things and I can not seem to get the right results... The closest I have been thus far is to have it in the tray and also minimized on the task bar at the same time...

    Thanks in advance

    -------------
    Mr. Nobody aka Rick Hays
    mailto:[email protected][email protected]</A>
    http://www.nowhereville.com


    Mr. Nobody aka Rick Hays
    mailto:[email protected][email protected]</A>
    http://www.nowhereville.com

  • #2
    Starting in the tray I am not sure about, putting it in the tray immediately I can help with

    See the TRAY example in the SAMPLES folder, Meanwhile:

    Code:
    Global pMenu as long 'PopupMenu
    global mMenu as long 'Main Menu
    
    In your Dialog Procedure:
    
    Callback Function DialogProc() as long
      Static ti             As NOTIFYICONDATA
      Local wMsg            As Long
      Local wParam          As Long
      Local lParam          As Long
      wMsg = CbMsg
      lParam = CbLparam
      wparam = CbWparam
      hInst = hInstance
    
    BEGIN:
      Select Case wMsg
        Case %WM_INITDIALOG
          'Set the timer for the clock
          If IsTrue AutoCheck Then SetTimer  hDlg, %IDT_TIMER2,  2000, ByVal %NULL
    
          ' ** Add tray icon
          ti.cbSize           = SizeOf(ti)
          ti.hWnd             = hDlg
          ti.uID              = hInst
          ti.uFlags           = %NIF_ICON Or %NIF_MESSAGE Or %NIF_TIP
          ti.uCallbackMessage = %WM_TRAYICON
          ti.hIcon            = LoadIcon(hInst, ByVal %ATOM1)
          ti.szTip            = Mine
          Shell_NotifyIcon %NIM_ADD, ti
          DestroyIcon ti.hIcon
           ' ** Get Menu Handle
           pMenu = GetSubMenu(LoadMenu(hInstance, "POPUPMENU"), 0)
    
        Case %WM_COMMAND
          Select Case LoWrd(wParam)
                 Case %IDM_ACHECK
                   'Normal Menu Stuff
                 Case %IDM_OPTIONS
    
          End Select
    
    
        Case %WM_TRAYICON
    
          Select Case LoWrd(lParam)
    
            ' ** Left button press
            Case %WM_LBUTTONDOWN
              If IsWindowVisible(hDlg) = %TRUE Then SetFocus hDlg
    
    
            Case %WM_LBUTTONDBLCLK
              If IsWindowVisible(hDlg) = %FALSE Then ShowWindow hDlg, %SW_SHOW Or %SW_SHOWNORMAL Else SetFocus hDlg
    
    
            ' ** Right button press
            Case %WM_RBUTTONDOWN
                SetForegroundWindow hDlg
                GetCursorPos p
                TrackPopupMenu pMenu, 0, p.x, p.y, 0, hDlg, ByVal %NULL
                Postmessage hDlg, %WM_NULL, 0, 0
          End Select
    
    
    End Select
    
    
    Now, I have this set so that when WM_CLOSE occurs, it goes BACK to the system tray and does not close...
    
    My resource file, especially for the tray menu:
    
    POPUPMENU Menu
      BEGIN
        Popup "&Tray"
          BEGIN
            MENUITEM "&Options" IDM_OPTIONS
            MENUITEM "&Always On Top" IDM_ONTOP
            MENUITEM "&Check Time" IDM_ACHECK
            MENUITEM "&Help",   IDM_HELP
            MENUITEM "&About",  IDM_ABOUT
            MENUITEM SEPARATOR
            MENUITEM "Exit", IDM_EXIT
          End
      End
    -------------
    Scott Turchin


    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      Thanks for the reply... But maybe I did not make this clear enough as to what I am trying to accomplish. The tray example works great as is, but I want a program (AT STARTUP) to load and only display in the tray, like a service in NT, or a background task.. I do not want the Dialog to load to the screen..

      Hope this makes more since.. )

      Thanks again

      -------------
      Mr. Nobody aka Rick Hays
      mailto:[email protected][email protected]</A>
      http://www.nowhereville.com


      Mr. Nobody aka Rick Hays
      mailto:[email protected]whereville.com[email protected]</A>
      http://www.nowhereville.com

      Comment


      • #4
        Rick --

        I haven't got the Tray example in front of me so I can't be specific, but here is what you need to do… When you are creating your program's main window, do not use the WS_VISIBLE style. How you accomplish that will depend on whether you are using resource-based or API-based window, but the concept is the same. And after it has been created, do not make it visible by using (for example) the ShowWindow API function.

        If you do not "show" your main window, nothing will appear on the desktop and no Task Bar button will be displayed, but if you create a System Tray icon, it will be visible.

        Does that help? If not, I'll post something more specific tomorrow.

        -- Eric P.

        test

        -------------
        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>
        Last edited by Eric Pearson; 3 Feb 2018, 03:19 AM. Reason: still testing
        "Not my circus, not my monkeys."

        Comment


        • #5
          I am using DDT to build the form then in the callback is where I load the Tray stuff...

          I am using DDT currently cause I am not that great with direct API calls for controls yet..

          So when I create the form I set the %WS_MINIMIZE in the DIALOG NEW then I call the DIALOG SHOW and it shows in the tray and minimized like it is suppose too.. I do not know how to set the callback for the form to initialize the Tray stuff without calling the DIALOG SHOW. I think if I can do that then this won't be a problem. If it would help to see the code I can email it.. Or if you know how to get to the call back without the DIALOG SHOW...

          Thanks again for the help.

          -------------
          Mr. Nobody aka Rick Hays
          mailto:[email protected][email protected]</A>
          http://www.nowhereville.com


          Mr. Nobody aka Rick Hays
          mailto:[email protected][email protected]</A>
          http://www.nowhereville.com

          Comment


          • #6
            Rick --

            Sure, send the code to the address below.

            -- Eric

            -------------
            Perfect Sync: Perfect Sync Development Tools
            Email: mailto:[email protected][email protected]</A>

            "Not my circus, not my monkeys."

            Comment


            • #7
              Hi Scott,

              I tried just adding to my TimeSynch.rc file (application's resource file):
              POPUPMENU Menu
              BEGIN
              Popup "&Tray"
              BEGIN
              MENUITEM "&Change Time Zone" IDM_SETZONE
              MENUITEM "&Update System Time" IDM_SETTIME
              MENUITEM "&Start with Windows" IDM_AUTORUN
              MENUITEM "&About" IDM_ABOUT
              MENUITEM SEPARATOR
              MENUITEM "E&xit" IDM_EXIT
              End
              End

              Any ideas why when I try to compile my .rc file it reports:
              TIMESYNCH.RC (30): error RC2104 : undefined keyword or key name: IDM_SETZONE


              Thanks,
              Christian Blackburn

              ------------------
              Thanks,
              Christian Blackburn
              Thanks,
              Christian Blackburn

              Comment


              • #8
                Code:
                #define IDM_SETZONE    somenumericvalue
                #define IDM_SETIME     somenumericvalue
                .....
                
                POPUPMENU MENU 
                 .....

                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Hi Michael,

                  Thanks for the help. That's so simple it's disgusting .

                  Cheers,
                  Christian

                  [This message has been edited by Christian Blackburn (edited July 02, 2007).]
                  Thanks,
                  Christian Blackburn

                  Comment


                  • #10
                    Originally posted by Rick Hays View Post
                    So when I create the form I set the %WS_MINIMIZE in the DIALOG NEW then I call the DIALOG SHOW and it shows in the tray and minimized like it is suppose too.. I do not know how to set the callback for the form to initialize the Tray stuff without calling the DIALOG SHOW. I think if I can do that then this won't be a problem. If it would help to see the code I can email it.. Or if you know how to get to the call back without the DIALOG SHOW...
                    I'm running into the same issue. I want to start a program into the systray like in the tray-example without displaying any form. Is this possible or do I have to start the "main" form and minimize it?

                    Regards,
                    Jochen

                    Comment


                    • #11
                      There's a nice example posted to the Source Code forum by Don Schullian..
                      PowerBASIC and related source code. Please do not post questions or discussions, just source code.


                      (You'll need to rem the '#COMPILER PBWIN 8' line and change the variable 'Events' to 'lEvents' to compile with PBWin901).
                      Rgds, Dave

                      Comment


                      • #12
                        Originally posted by Dave Biggs View Post
                        There's a nice example posted to the Source Code forum by Don Schullian..
                        PowerBASIC and related source code. Please do not post questions or discussions, just source code.


                        (You'll need to rem the '#COMPILER PBWIN 8' line and change the variable 'Events' to 'lEvents' to compile with PBWin901).
                        Thanks Dave, that is what I was searching for.

                        Jochen

                        Comment

                        Working...
                        X