Author: janderwald
Date: Wed Sep 17 16:58:34 2008
New Revision: 36295
URL:
http://svn.reactos.org/svn/reactos?rev=36295&view=rev
Log:
- Update Status Icon when there is activity
- Also update the Taskbar Notification Icon
Modified:
trunk/reactos/dll/win32/netshell/lang/de-DE.rc
trunk/reactos/dll/win32/netshell/lanstatusui.c
trunk/reactos/dll/win32/netshell/resource.h
Modified: trunk/reactos/dll/win32/netshell/lang/de-DE.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lang/de…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lang/de-DE.rc [iso-8859-1] Wed Sep 17 16:58:34 2008
@@ -37,13 +37,10 @@
LTEXT "Übertragungsrate:", -1, 19, 48, 60, 8
GROUPBOX "Aktivität", -1, 9, 74, 182, 70, BS_GROUPBOX
RTEXT "Gesendet", -1, 26, 90, 60, 8
- ICON IDI_HORIZONTAL, -1, 90, 85, 18, 20
- ICON IDI_NETSTAT, -1, 110, 85, 18, 20
- ICON IDI_HORIZONTAL, -1, 130, 85, 18, 20
+ ICON "", IDC_NETSTAT, 110, 85, 18, 20
LTEXT "Empfangen", -1, 149, 90, 37, 8
LTEXT "Bytes:", -1, 17, 115, 32, 8
RTEXT "000.000.000", IDC_SEND, 63, 115, 44, 8
- ICON IDI_VERTICAL, -1, 110, 108, 18, 20
RTEXT "000.000.000", IDC_RECEIVED, 139, 115, 44, 8
PUSHBUTTON "E&igenschaften", IDC_STATUS_PROPERTIES, 10, 150, 50, 14
PUSHBUTTON "&Deaktivieren", IDC_ENDISABLE, 66, 150, 50, 14
Modified: trunk/reactos/dll/win32/netshell/lanstatusui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/lanstat…
==============================================================================
--- trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/lanstatusui.c [iso-8859-1] Wed Sep 17 16:58:34 2008
@@ -10,6 +10,7 @@
{
struct tagNotificationItem *pNext;
CLSID guidItem;
+ UINT uID;
HWND hwndDlg;
}NOTIFICATION_ITEM;
@@ -24,11 +25,14 @@
typedef struct
{
INetConnection *pNet;
- HWND hwndDlg;
+ HWND hwndStatusDlg; /* LanStatusDlg window */
+ HWND hwndDlg; /* status dialog window */
DWORD dwAdapterIndex;
UINT_PTR nIDEvent;
DWORD dwInOctets;
DWORD dwOutOctets;
+ UINT uID;
+ UINT Status;
}LANSTATUSUI_CONTEXT;
VOID
@@ -42,6 +46,9 @@
WCHAR Buffer[100];
WCHAR DayBuffer[30];
WCHAR LocBuffer[50];
+ HICON hIcon, hOldIcon;
+ NOTIFYICONDATAW nid;
+
#if 0
ULONGLONG Ticks;
#else
@@ -98,8 +105,6 @@
SendDlgItemMessageW(hwndDlg, IDC_SEND, WM_SETTEXT, 0, (LPARAM)szBuffer);
}
- //FIXME
- //set duration
#if 0
Ticks = GetTickCount64();
#else
@@ -135,6 +140,47 @@
SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)Buffer);
}
+ hIcon = NULL;
+ if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets
== IfEntry.dwOutOctets && pContext->Status != 0)
+ {
+ hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE));
+ pContext->Status = 0;
+ }
+ else if (pContext->dwInOctets != IfEntry.dwInOctets &&
pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
+ {
+ pContext->Status = 1;
+ hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANSREC));
+ }
+ else if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->Status
!= 2)
+ {
+ hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_REC));
+ pContext->Status = 2;
+ }
+ else if (pContext->dwOutOctets == IfEntry.dwOutOctets &&
pContext->Status != 3)
+ {
+ hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_TRANS));
+ pContext->Status = 3;
+ }
+
+ if (hIcon)
+ {
+ hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON,
(WPARAM)hIcon, 0);
+
+
+ ZeroMemory(&nid, sizeof(nid));
+ nid.cbSize = sizeof(nid);
+ nid.uID = pContext->uID;
+ nid.hWnd = pContext->hwndStatusDlg;
+ nid.uFlags = NIF_ICON;
+ nid.u.uVersion = 3;
+ nid.hIcon = CopyIcon(hIcon);
+
+ Shell_NotifyIconW(NIM_MODIFY, &nid);
+ if (hOldIcon)
+ DestroyIcon(hOldIcon);
+ }
+ pContext->dwInOctets = IfEntry.dwInOctets;
+ pContext->dwOutOctets = IfEntry.dwOutOctets;
}
@@ -202,8 +248,8 @@
pContext->dwAdapterIndex = dwAdapterIndex;
/* update adapter info */
+ pContext->Status = -1;
UpdateLanStatusUIDlg(hwndDlg, pContext);
- pContext->nIDEvent = SetTimer(hwndDlg, 0xFABC, 1000, NULL);
CoTaskMemFree(pAdapterInfo);
}
@@ -225,7 +271,7 @@
case WM_INITDIALOG:
page = (PROPSHEETPAGE*)lParam;
pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
- pContext->hwndDlg = GetParent(hwndDlg);
+ pContext->hwndDlg = hwndDlg;
InitializeLANStatusUiDlg(hwndDlg, pContext);
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
return TRUE;
@@ -251,17 +297,9 @@
if (lppsn->hdr.code == PSN_APPLY || lppsn->hdr.code == PSN_RESET)
{
pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- KillTimer(hwndDlg, pContext->nIDEvent);
SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
pContext->hwndDlg = NULL;
- return PSNRET_NOERROR;
- }
- break;
- case WM_TIMER:
- pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- if (wParam == (WPARAM)pContext->nIDEvent)
- {
- UpdateLanStatusUIDlg(hwndDlg, pContext);
+ return TRUE;
}
break;
}
@@ -276,7 +314,6 @@
HPROPSHEETPAGE hppages[2];
PROPSHEETHEADERW pinfo;
NETCON_PROPERTIES * pProperties = NULL;
- HWND hwnd;
ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
ZeroMemory(hppages, sizeof(hppages));
@@ -293,7 +330,7 @@
pinfo.dwFlags |= PSH_PROPTITLE;
}
- if (pProperties->MediaType == NCM_LAN)
+ if (pProperties->MediaType == NCM_LAN && pProperties->Status ==
NCS_CONNECTED)
{
hppages[0] = InitializePropertySheetPage(MAKEINTRESOURCEW(IDD_LAN_NETSTATUS),
LANStatusUiDlg, (LPARAM)pContext, NULL);
if (hppages[0])
@@ -301,12 +338,13 @@
if (pinfo.nPages)
{
- hwnd = (HWND)PropertySheetW(&pinfo);
- if (hwnd)
- {
- pContext->hwndDlg = hwnd;
- }
- }
+ PropertySheetW(&pinfo);
+ }
+ }
+ else if (pProperties->Status == NCS_MEDIA_DISCONNECTED ||
pProperties->Status == NCS_DISCONNECTED ||
+ pProperties->Status == NCS_HARDWARE_DISABLED)
+ {
+ ShowNetConnectionProperties(pContext->pNet, pContext->hwndDlg);
}
NcFreeNetconProperties(pProperties);
}
@@ -326,13 +364,17 @@
switch(uMsg)
{
case WM_INITDIALOG:
- pContext = (LANSTATUSUI_CONTEXT*)CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT));
- if (!pContext)
- return FALSE;
- pContext->hwndDlg = NULL;
- pContext->pNet = (INetConnection*)lParam;
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
+ pContext = (LANSTATUSUI_CONTEXT *)lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam);
+ pContext->nIDEvent = SetTimer(hwndDlg, 0xFABC, 1000, NULL);
return TRUE;
+ case WM_TIMER:
+ pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ if (wParam == (WPARAM)pContext->nIDEvent)
+ {
+ UpdateLanStatusUIDlg(pContext->hwndDlg, pContext);
+ }
+ break;
case WM_SHOWSTATUSDLG:
if (LOWORD(lParam) == WM_LBUTTONDOWN)
{
@@ -342,8 +384,8 @@
if (pContext->hwndDlg)
{
- ShowWindow(pContext->hwndDlg, SW_SHOW);
- BringWindowToTop(pContext->hwndDlg);
+ ShowWindow(GetParent(pContext->hwndDlg), SW_SHOW);
+ BringWindowToTop(GetParent(pContext->hwndDlg));
}
else
{
@@ -370,6 +412,7 @@
ULONG Count;
ULONG Index;
NOTIFICATION_ITEM * pItem, *pLast = NULL;
+ LANSTATUSUI_CONTEXT * pContext;
if (This->pHead)
return S_OK;
@@ -395,9 +438,20 @@
pItem = (NOTIFICATION_ITEM*)CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM));
if (!pItem)
break;
+
+ pContext = (LANSTATUSUI_CONTEXT*)CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT));
+ if (!pContext)
+ {
+ CoTaskMemFree(pItem);
+ break;
+ }
+
pItem->pNext = NULL;
-
- hwndDlg = CreateDialogParamW(netshell_hInstance,
MAKEINTRESOURCEW(IDD_STATUS), NULL, LANStatusDlg, (LPARAM)INetCon);
+ ZeroMemory(pContext, sizeof(LANSTATUSUI_CONTEXT));
+ pContext->uID = Index;
+ pContext->pNet = INetCon;
+
+ hwndDlg = CreateDialogParamW(netshell_hInstance,
MAKEINTRESOURCEW(IDD_STATUS), NULL, LANStatusDlg, (LPARAM)pContext);
if (hwndDlg)
{
ZeroMemory(&nid, sizeof(nid));
@@ -407,17 +461,26 @@
nid.u.uVersion = 3;
nid.uCallbackMessage = WM_SHOWSTATUSDLG;
nid.hWnd = hwndDlg;
- nid.hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE));
+
hr = INetConnection_GetProperties(INetCon, &pProps);
if (SUCCEEDED(hr))
{
CopyMemory(&pItem->guidItem, &pProps->guidId,
sizeof(GUID));
- pItem->hwndDlg = hwndDlg;
if (!(pProps->dwCharacter & NCCF_SHOW_ICON))
{
nid.dwState = NIS_HIDDEN;
}
+ if (pProps->Status == NCS_MEDIA_DISCONNECTED || pProps->Status
== NCS_DISCONNECTED || pProps->Status == NCS_HARDWARE_DISABLED)
+ nid.hIcon = LoadIcon(netshell_hInstance,
MAKEINTRESOURCE(IDI_NET_OFF));
+ else if (pProps->Status == NCS_CONNECTED)
+ nid.hIcon = LoadIcon(netshell_hInstance,
MAKEINTRESOURCE(IDI_NET_IDLE));
+
+
+ wcscpy(nid.szTip, pProps->pszwName);
+ nid.uFlags |= NIF_TIP;
}
+ pContext->hwndStatusDlg = hwndDlg;
+ pItem->hwndDlg = hwndDlg;
if (Shell_NotifyIconW(NIM_ADD, &nid))
{
Modified: trunk/reactos/dll/win32/netshell/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netshell/resourc…
==============================================================================
--- trunk/reactos/dll/win32/netshell/resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netshell/resource.h [iso-8859-1] Wed Sep 17 16:58:34 2008
@@ -36,6 +36,7 @@
#define IDC_STATUS 1104
#define IDC_DURATION 1105
#define IDC_SPEED 1106
+#define IDC_NETSTAT 1107
/* resource constants */