diff -u httpsvr.orig/httpdoc.cpp httpsvr/httpdoc.cpp --- httpsvr.orig/httpdoc.cpp Wed Mar 25 20:48:17 1998 +++ httpsvr/httpdoc.cpp Sun Oct 14 01:24:41 2001 @@ -310,8 +310,15 @@ m_pListen = new CListenSocket( this ); if ( m_pListen ) { - if ( m_pListen->Create( m_uPort, SOCK_STREAM, FD_ACCEPT ) ) - bOk = m_pListen->Listen(); + if( ( m_nSvrName == 0 ) || ( inet_addr(m_strServer)==INADDR_NONE ) ) { + // When no explicit name is given, accept any connections + if ( m_pListen->Create( m_uPort, SOCK_STREAM, FD_ACCEPT) ) + bOk = m_pListen->Listen(); + } else { + // When an explicit name is used, limit connections to just that interface + if ( m_pListen->Create( m_uPort, SOCK_STREAM, FD_ACCEPT, m_strServer ) ) + bOk = m_pListen->Listen(); + } if ( !bOk ) { diff -u httpsvr.orig/httpsvr.cpp httpsvr/httpsvr.cpp --- httpsvr.orig/httpsvr.cpp Wed Mar 25 20:48:18 1998 +++ httpsvr/httpsvr.cpp Fri Oct 19 22:39:08 2001 @@ -116,6 +116,10 @@ // Enable drag/drop open. m_pMainWnd->DragAcceptFiles(); + // When starting minimized, hide the window so just the taskbar icon shows + if(m_pMainWnd->IsIconic()) + m_pMainWnd->ShowWindow(SW_HIDE); + return TRUE; } diff -u httpsvr.orig/httpsvr.h httpsvr/httpsvr.h --- httpsvr.orig/httpsvr.h Wed Mar 25 20:48:19 1998 +++ httpsvr/httpsvr.h Fri Oct 19 22:13:01 2001 @@ -53,4 +53,6 @@ void AddFile( CString& strPath, UINT uStr ); void AddFile( CString& strPath, const CString& strFile); +#define MYWM_NOTIFYICON (WM_USER) + ///////////////////////////////////////////////////////////////////////////// diff -u httpsvr.orig/mainfrm.cpp httpsvr/mainfrm.cpp --- httpsvr.orig/mainfrm.cpp Wed Mar 25 20:48:21 1998 +++ httpsvr/mainfrm.cpp Fri Oct 19 22:37:54 2001 @@ -30,6 +30,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) + ON_WM_SYSCOMMAND() ON_WM_CREATE() ON_WM_DESTROY() ON_WM_TIMER() @@ -38,6 +39,7 @@ #ifdef IMPL_CGI ON_MESSAGE(WSM_CGIDONE, OnCGIDone) #endif IMPL_CGI + ON_MESSAGE(MYWM_NOTIFYICON,OnTrayIcon) END_MESSAGE_MAP() static UINT indicators[] = @@ -62,6 +64,11 @@ if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; + // Give ourselves an icon in the system try + TrayMessage(NIM_ADD, MYWM_NOTIFYICON, + (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, 0), + "HTTP Server"); + if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) @@ -113,11 +120,50 @@ void CMainFrame::OnDestroy() { + /* Remove the icon from the task bar */ + TrayMessage(NIM_DELETE, MYWM_NOTIFYICON, NULL, NULL); + CFrameWnd::OnDestroy(); if ( m_uTimer ) KillTimer( m_uTimer ); } +void CMainFrame::OnTrayIcon(WPARAM wParam,LPARAM lParam) +{ + if((lParam == WM_LBUTTONDOWN) || (lParam == WM_RBUTTONDOWN)) { + // Restore the window when the tray icon is clicked + ShowWindow(SW_RESTORE); + SetForegroundWindow(); + } +} + +/* Send a message to the Shell to add/remove/change an icon on the taskbar */ +BOOL CMainFrame::TrayMessage(DWORD dwMessage, UINT uID, HICON hIcon, PSTR pszTip) +{ + BOOL res; + + NOTIFYICONDATA tnd; + + tnd.cbSize = sizeof(NOTIFYICONDATA); + tnd.hWnd = m_hWnd; + tnd.uID = uID; + + tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; + tnd.uCallbackMessage = MYWM_NOTIFYICON; + tnd.hIcon = hIcon; + if (pszTip) + lstrcpyn(tnd.szTip, pszTip, sizeof(tnd.szTip)); + else + tnd.szTip[0] = '\0'; + + res = Shell_NotifyIcon(dwMessage, &tnd); + + if (hIcon) + DestroyIcon(hIcon); + + return res; +} + void CMainFrame::OnTimer(UINT nIDEvent) { CalcUpTime(); @@ -151,3 +197,12 @@ return 0; } #endif // IMPL_CGI + +void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) +{ + if(SC_MINIMIZE == (nID & 0xFFF0)) { + ShowWindow(SW_HIDE); /* Hide the window instead of minimizing */ + } else { + CFrameWnd::OnSysCommand(nID,lParam); + } +} diff -u httpsvr.orig/stdafx.h httpsvr/stdafx.h --- httpsvr.orig/stdafx.h Wed Mar 25 20:48:24 1998 +++ httpsvr/stdafx.h Fri Oct 19 22:53:55 2001 @@ -13,7 +13,7 @@ // Microsoft Foundation Classes product. #define SEPCHAR '\\' -#define IMPL_CGI 1 +//#define IMPL_CGI 1 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers