Minimize to tray feature - anyone ?

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Minimize to tray feature - anyone ?

Postby marten » Wed Feb 11, 2009 7:21 am

I would like to have the "minimize to tray" feature (under Windows). Does anyone has a solution or code for that ?

Marten
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: Minimize to tray feature - anyone ?

Postby nmongeau » Wed Feb 11, 2009 9:35 am

I've never done it in Smalltalk, but I have C++ code that handles it if you're interested.
nmongeau
[|]
 
Posts: 29
Joined: Fri Jan 12, 2007 9:37 am

Re: Minimize to tray feature - anyone ?

Postby DEBRO » Thu Feb 12, 2009 8:14 am

Hi there,
nmongeau wrote:I've never done it in Smalltalk, but I have C++ code that handles it if you're interested.

I'm interested. Can you share?
Take care,
Dennis
DEBRO
 
Posts: 21
Joined: Thu Aug 28, 2008 9:07 am

Re: Minimize to tray feature - anyone ?

Postby nmongeau » Thu Feb 12, 2009 11:41 am

actually, after looking around, some portions are in the base image.

To add an icon to the tray:

Code: Select all
| nid flags osString dwMessage res message |

nid := OSNotifyicondata new.
   
flags := (PlatformConstants at: 'NifIcon') + (PlatformConstants at: 'NifMessage') + (PlatformConstants at: 'NifTip').
dwMessage := PlatformConstants at: 'NimAdd'.
   
osString := 'Some Text For Tool Tip' copyToOSMemory.
message := (PlatformConstants at: 'WmUser') + 1997.
   
nid
   cbSize: OSNotifyicondata  fixedSize ;
   hWnd: self primaryWidget osWidget handle ;
   uID: 1234 ;
   uFlags: flags ;
   uCallbackMessage: message ;
   hIcon: (OSWidget systemIcon: (PlatformWidgetsConstants at: 'OSxICONQUESTION')) ;
   szTip: osString.

res := OSCall new shellNotifyIcon: dwMessage lpData: nid.
   


Of course it's for demonstration only, but the above is documented here: http://msdn.microsoft.com/en-us/library/bb773352(VS.85).aspx

You have to now handle the WmUser+1997 message specified above, that will be sent to your window whenever the user interacts with the icon on the toolbar. The base image is not really geared for this, you'll have to change certain things. The entry point now is OSWidget>>windowProc:with:with:, you will see that it will wake up with a message of 3021 when you interact with the tray icon.

You'll have to either change the windowProc of your main window, or register a new event in the EventTable.

In any case, here's some C++ code I have that reacts to 2 icon events, when double-clicking I show the window, and with Right-Click I display a popup menu:

Code: Select all
LONG CClipboardDlg::OnMyTrayNotify(WPARAM wParam, LPARAM lParam)
{
   switch ( lParam )
     {
        case WM_LBUTTONDBLCLK:
         // Display the application
            ShowWindow(SW_RESTORE);
            SetForegroundWindow();
            break;
        //Activate the pop up menu
        case WM_RBUTTONDOWN:
            //Create the popup menu with mini icons
            CMenu menu;

            VERIFY( menu.CreatePopupMenu() );

         if ((! IsWindowVisible()) | IsIconic())
         {
            menu.AppendMenu(MF_STRING, ID_APP_OPEN, _T("&Open"));
         }
         else
         {
            menu.AppendMenu(MF_STRING | MF_GRAYED, ID_APP_OPEN, _T("&Open"));
         };

            menu.AppendMenu(MF_STRING, ID_APP_REALLY_EXIT, _T("E&xit") );
               
            //Position and Display
            POINT pt ;
            GetCursorPos ( &pt ) ;

            SetForegroundWindow();

            int nSelection =  menu.TrackPopupMenu ( 
                TPM_RETURNCMD | TPM_LEFTALIGN | TPM_RIGHTBUTTON,
                pt.x, pt.y, AfxGetMainWnd(), NULL );

            menu.DestroyMenu();

            switch( nSelection )
            {
         case ID_APP_OPEN:
               ShowWindow(SW_RESTORE);
              break;
         case ID_APP_REALLY_EXIT:
                OnCancel();
                break;
            }
    };

     return 0;
}


Hopefully that should get you started.

Normand
nmongeau
[|]
 
Posts: 29
Joined: Fri Jan 12, 2007 9:37 am

Re: Minimize to tray feature - anyone ?

Postby koschate » Thu Feb 12, 2009 6:13 pm

Over at Totally Objects (http://www.totallyobjects.com/Tofree.htm), there's a freeware Notification Area part that works to minimize applications to the system tray. It's old, but probably still works.
koschate
[|]
 
Posts: 102
Joined: Thu Feb 01, 2007 7:24 am


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest