ReactOS  0.4.13-dev-66-gc714b7f
lanstatusui.cpp File Reference
#include "precomp.h"
#include <winsock.h>
Include dependency graph for lanstatusui.cpp:

Go to the source code of this file.

Functions

VOID UpdateLanStatusUiDlg (HWND hwndDlg, MIB_IFROW *IfEntry, LANSTATUSUI_CONTEXT *pContext)
 
VOID UpdateLanStatus (HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
 
VOID InitializeLANStatusUiDlg (HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
 
static VOID InsertColumnToListView (HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
 
static VOID AddIPAddressToListView (HWND hDlgCtrl, PIP_ADDR_STRING pAddr, INT Index)
 
static INT InsertItemToListView (HWND hDlgCtrl, UINT ResId)
 
INT_PTR CALLBACK LANStatusUiDetailsDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK LANStatusUiAdvancedDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID DisableNetworkAdapter (INetConnection *pNet, LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
 
INT_PTR CALLBACK LANStatusUiDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID InitializePropertyDialog (LANSTATUSUI_CONTEXT *pContext, NETCON_PROPERTIES *pProperties)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
VOID ShowStatusPropertyDialog (LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
 
INT_PTR CALLBACK LANStatusDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ AddIPAddressToListView()

static VOID AddIPAddressToListView ( HWND  hDlgCtrl,
PIP_ADDR_STRING  pAddr,
INT  Index 
)
static

Definition at line 297 of file lanstatusui.cpp.

301 {
302  LVITEMW li;
303  PIP_ADDR_STRING pCur;
304  WCHAR szBuffer[100];
305  UINT SubIndex;
306 
307  ZeroMemory(&li, sizeof(LVITEMW));
308  li.mask = LVIF_TEXT;
309  li.iItem = Index;
310  pCur = pAddr;
311  SubIndex = 0;
312 
313  do
314  {
315  if (SubIndex)
316  {
317  ZeroMemory(&li, sizeof(LVITEMW));
318  li.mask = LVIF_TEXT;
319  li.iItem = Index;
320  li.iSubItem = 0;
321  li.pszText = (LPWSTR)L"";
322  li.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
323  }
324 
325  if (MultiByteToWideChar(CP_ACP, 0, pCur->IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
326  {
327  li.pszText = szBuffer;
328  li.iSubItem = 1;
329  li.iItem = Index++;
330  SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
331  }
332  SubIndex++;
333  pCur = pCur->Next;
334  } while (pCur && pCur->IpAddress.String[0]);
335 }
#define CP_ACP
Definition: compat.h:99
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
char String[4 *4]
Definition: iptypes.h:42
#define ZeroMemory
Definition: winbase.h:1635
#define LVIF_TEXT
Definition: commctrl.h:2281
int iSubItem
Definition: commctrl.h:2334
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR pszText
Definition: commctrl.h:2337
static const UCHAR Index[8]
Definition: usbohci.c:18
UINT mask
Definition: commctrl.h:2332
static const WCHAR L[]
Definition: oid.c:1250
#define LVM_INSERTITEMW
Definition: commctrl.h:2376
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define MultiByteToWideChar
Definition: compat.h:100
#define LVM_SETITEMW
Definition: commctrl.h:2369
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LANStatusUiDetailsDlg().

◆ DisableNetworkAdapter()

VOID DisableNetworkAdapter ( INetConnection pNet,
LANSTATUSUI_CONTEXT pContext,
HWND  hwndDlg 
)

Definition at line 548 of file lanstatusui.cpp.

549 {
550  HRESULT hr = pNet->Disconnect();
551  if (FAILED_UNEXPECTEDLY(hr))
552  return;
553 
555 
557  ZeroMemory(&nid, sizeof(nid));
558  nid.cbSize = sizeof(nid);
559  nid.uID = pContext->uID;
560  nid.hWnd = pContext->hwndDlg;
561  nid.uFlags = NIF_STATE;
562  nid.dwState = NIS_HIDDEN;
563  nid.dwStateMask = NIS_HIDDEN;
564 
566 }
HRESULT hr
Definition: shlfolder.c:183
NOTIFYICONDATA nid
Definition: magnifier.c:45
HRESULT Disconnect()
#define ZeroMemory
Definition: winbase.h:1635
DWORD dwStateMask
Definition: shellapi.h:237
#define PSBTN_CANCEL
Definition: prsht.h:151
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
HWND WINAPI GetParent(_In_ HWND)
#define PropSheet_PressButton(d, i)
Definition: prsht.h:330
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
Definition: systray.cpp:128
#define NIM_MODIFY
Definition: shellapi.h:92

Referenced by LANStatusUiDlg().

◆ InitializeLANStatusUiDlg()

VOID InitializeLANStatusUiDlg ( HWND  hwndDlg,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 242 of file lanstatusui.cpp.

243 {
244  WCHAR szBuffer[MAX_PATH] = {0};
245  NETCON_PROPERTIES * pProperties;
246 
247  if (pContext->pNet->GetProperties(&pProperties) != S_OK)
248  return;
249 
250  if (pProperties->Status == NCS_DISCONNECTED)
252  else if (pProperties->Status == NCS_MEDIA_DISCONNECTED)
254  else if (pProperties->Status == NCS_CONNECTING)
256  else if (pProperties->Status == NCS_CONNECTED)
258 
259  SendDlgItemMessageW(hwndDlg, IDC_STATUS, WM_SETTEXT, 0, (LPARAM)szBuffer);
260 
261  pContext->dwInOctets = 0;
262  pContext->dwOutOctets = 0;
263 
264  /* update adapter info */
265  pContext->Status = -1;
266  UpdateLanStatus(hwndDlg, pContext);
267  NcFreeNetconProperties(pProperties);
268 }
#define IDS_STATUS_UNREACHABLE
Definition: resource.h:82
INetConnection * pNet
Definition: lanstatusui.h:19
#define IDS_STATUS_DISCONNECTED
Definition: resource.h:83
#define IDS_STATUS_CONNECTED
Definition: resource.h:85
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
VOID UpdateLanStatus(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SETTEXT
Definition: winuser.h:1599
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define IDS_STATUS_CONNECTING
Definition: resource.h:84
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_STATUS
Definition: resource.h:41
#define S_OK
Definition: intsafe.h:59
NETCON_STATUS Status
Definition: netcon.h:86

Referenced by LANStatusUiDlg().

◆ InitializePropertyDialog()

VOID InitializePropertyDialog ( LANSTATUSUI_CONTEXT pContext,
NETCON_PROPERTIES pProperties 
)

Definition at line 621 of file lanstatusui.cpp.

624 {
625  DWORD dwSize, dwAdapterIndex, dwResult;
626  LPOLESTR pStr;
627  IP_ADAPTER_INFO *pAdapterInfo, *pCurAdapter;
628 
629  if (FAILED(StringFromCLSID((CLSID)pProperties->guidId, &pStr)))
630  {
631  return;
632  }
633 
634  /* get the IfTable */
635  dwSize = 0;
636  dwResult = GetAdaptersInfo(NULL, &dwSize);
637  if (dwResult!= ERROR_BUFFER_OVERFLOW)
638  {
639  CoTaskMemFree(pStr);
640  return;
641  }
642 
643  pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
644  if (!pAdapterInfo)
645  {
646  CoTaskMemFree(pAdapterInfo);
647  CoTaskMemFree(pStr);
648  return;
649  }
650 
651  if (GetAdaptersInfo(pAdapterInfo, &dwSize) != NO_ERROR)
652  {
653  CoTaskMemFree(pAdapterInfo);
654  CoTaskMemFree(pStr);
655  return;
656  }
657 
658  if (!GetAdapterIndexFromNetCfgInstanceId(pAdapterInfo, pStr, &dwAdapterIndex))
659  {
660  CoTaskMemFree(pAdapterInfo);
661  CoTaskMemFree(pStr);
662  return;
663  }
664 
665  pCurAdapter = pAdapterInfo;
666  while (pCurAdapter->Index != dwAdapterIndex)
667  pCurAdapter = pCurAdapter->Next;
668 
669 
670  pContext->IpAddress = inet_addr(pCurAdapter->IpAddressList.IpAddress.String);
671  pContext->SubnetMask = inet_addr(pCurAdapter->IpAddressList.IpMask.String);
672  pContext->Gateway = inet_addr(pCurAdapter->GatewayList.IpAddress.String);
673  pContext->DHCPEnabled = pCurAdapter->DhcpEnabled;
674  CoTaskMemFree(pStr);
675  CoTaskMemFree(pAdapterInfo);
676  pContext->dwAdapterIndex = dwAdapterIndex;
677 }
BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg, PDWORD pIndex)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
#define inet_addr(cp)
Definition: inet.h:98
UINT DhcpEnabled
Definition: iptypes.h:61
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
char String[4 *4]
Definition: iptypes.h:42
static LPOLESTR
Definition: stg_prop.c:27
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
IP_MASK_STRING IpMask
Definition: iptypes.h:48
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2321

Referenced by ShowStatusPropertyDialog().

◆ InsertColumnToListView()

static VOID InsertColumnToListView ( HWND  hDlgCtrl,
UINT  ResId,
UINT  SubItem,
UINT  Size 
)
static

Definition at line 272 of file lanstatusui.cpp.

277 {
278  WCHAR szBuffer[200];
279  LVCOLUMNW lc;
280 
281  if (!LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
282  return;
283 
284  memset(&lc, 0, sizeof(LV_COLUMN) );
286  lc.iSubItem = SubItem;
287  lc.fmt = LVCFMT_FIXED_WIDTH;
288  lc.cx = Size;
289  lc.cchTextMax = wcslen(szBuffer);
290  lc.pszText = szBuffer;
291 
292  (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, SubItem, (LPARAM)&lc);
293 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2559
#define LVCF_TEXT
Definition: commctrl.h:2560
#define LV_COLUMN
Definition: commctrl.h:2519
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
#define LVCF_SUBITEM
Definition: commctrl.h:2561
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2604
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR pszText
Definition: commctrl.h:2539
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
int cchTextMax
Definition: commctrl.h:2540
#define LVCF_FMT
Definition: commctrl.h:2558
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define memset(x, y, z)
Definition: compat.h:39
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by LANStatusUiDetailsDlg().

◆ InsertItemToListView()

static INT InsertItemToListView ( HWND  hDlgCtrl,
UINT  ResId 
)
static

Definition at line 339 of file lanstatusui.cpp.

342 {
343  LVITEMW li;
344  WCHAR szBuffer[100];
345 
346  ZeroMemory(&li, sizeof(LVITEMW));
347  li.mask = LVIF_TEXT;
348  li.iItem = ListView_GetItemCount(hDlgCtrl);
349  if (LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
350  {
351  li.pszText = szBuffer;
352  return (INT)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
353  }
354  return -1;
355 }
#define ZeroMemory
Definition: winbase.h:1635
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
int32_t INT
Definition: typedefs.h:56
#define LVIF_TEXT
Definition: commctrl.h:2281
LONG_PTR LPARAM
Definition: windef.h:208
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2279
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR pszText
Definition: commctrl.h:2337
UINT mask
Definition: commctrl.h:2332
#define LVM_INSERTITEMW
Definition: commctrl.h:2376
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by LANStatusUiDetailsDlg().

◆ LANStatusDlg()

INT_PTR CALLBACK LANStatusDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 751 of file lanstatusui.cpp.

756 {
757  LANSTATUSUI_CONTEXT * pContext;
758 
759  switch (uMsg)
760  {
761  case WM_INITDIALOG:
762  pContext = (LANSTATUSUI_CONTEXT *)lParam;
764  pContext->nIDEvent = SetTimer(hwndDlg, 0xFABC, 1000, NULL);
765  return TRUE;
766  case WM_TIMER:
767  pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
768  if (wParam == (WPARAM)pContext->nIDEvent)
769  {
770  UpdateLanStatus(pContext->hwndDlg, pContext);
771  }
772  break;
773  case WM_SHOWSTATUSDLG:
774  if (LOWORD(lParam) == WM_LBUTTONDOWN)
775  {
776  pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
777  if (!pContext)
778  break;
779 
780  if (pContext->hwndDlg)
781  {
782  ShowWindow(GetParent(pContext->hwndDlg), SW_SHOW);
783  BringWindowToTop(GetParent(pContext->hwndDlg));
784  }
785  else
786  {
787  ShowStatusPropertyDialog(pContext, hwndDlg);
788  }
789  break;
790  }
791  break;
792  }
793  return FALSE;
794 }
#define WM_SHOWSTATUSDLG
Definition: lanstatusui.h:6
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
VOID UpdateLanStatus(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
BOOL WINAPI BringWindowToTop(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1718
#define DWLP_USER
Definition: winuser.h:866
VOID ShowStatusPropertyDialog(LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
HWND WINAPI GetParent(_In_ HWND)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CLanStatus::InitializeNetTaskbarNotifications().

◆ LANStatusUiAdvancedDlg()

INT_PTR CALLBACK LANStatusUiAdvancedDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 485 of file lanstatusui.cpp.

490 {
491  WCHAR szBuffer[100] = {0};
493  LANSTATUSUI_CONTEXT * pContext;
494  DWORD dwIpAddr;
495 
496 
497  switch (uMsg)
498  {
499  case WM_INITDIALOG:
501  pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
502  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
503  if (pContext->DHCPEnabled)
504  LoadStringW(netshell_hInstance, IDS_ASSIGNED_DHCP, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
505  else
506  LoadStringW(netshell_hInstance, IDS_ASSIGNED_MANUAL, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
507 
508  szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
509  SendDlgItemMessageW(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)szBuffer);
510 
511 
512  dwIpAddr = ntohl(pContext->IpAddress);
513  swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
514  THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
515  SendDlgItemMessageW(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)szBuffer);
516 
517  dwIpAddr = ntohl(pContext->SubnetMask);
518  swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
519  THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
520  SendDlgItemMessageW(hwndDlg, IDC_DETAILSSUBNET, WM_SETTEXT, 0, (LPARAM)szBuffer);
521 
522  dwIpAddr = ntohl(pContext->Gateway);
523  if (dwIpAddr)
524  {
525  swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
526  THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
527  SendDlgItemMessageW(hwndDlg, IDC_DETAILSGATEWAY, WM_SETTEXT, 0, (LPARAM)szBuffer);
528  }
529  return TRUE;
530  case WM_COMMAND:
531  if (LOWORD(wParam) == IDC_DETAILS)
532  {
533  pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
534  if (pContext)
535  {
537  LANStatusUiDetailsDlg, (LPARAM)pContext);
538  }
539  }
540  break;
541  default:
542  break;
543  }
544  return FALSE;
545 }
#define TRUE
Definition: types.h:120
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define FIRST_IPADDRESS(x)
Definition: commctrl.h:4460
#define FOURTH_IPADDRESS(x)
Definition: commctrl.h:4463
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define SECOND_IPADDRESS(x)
Definition: commctrl.h:4461
#define THIRD_IPADDRESS(x)
Definition: commctrl.h:4462
LONG_PTR LPARAM
Definition: windef.h:208
Definition: module.h:566
#define WM_SETTEXT
Definition: winuser.h:1599
#define IDD_LAN_NETSTATUSDETAILS
Definition: resource.h:24
#define IDC_DETAILSIP
Definition: resource.h:47
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_DETAILS
Definition: resource.h:50
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_DETAILSSUBNET
Definition: resource.h:48
#define IDS_ASSIGNED_DHCP
Definition: resource.h:103
HWND WINAPI GetParent(_In_ HWND)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_DETAILSTYPE
Definition: resource.h:46
#define IDC_DETAILSGATEWAY
Definition: resource.h:49
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
INT_PTR CALLBACK LANStatusUiDetailsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define IDS_ASSIGNED_MANUAL
Definition: resource.h:104
#define PROPSHEETPAGE
Definition: prsht.h:371
#define ntohl(x)
Definition: module.h:203

Referenced by ShowStatusPropertyDialog().

◆ LANStatusUiDetailsDlg()

INT_PTR CALLBACK LANStatusUiDetailsDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 360 of file lanstatusui.cpp.

366 {
367  LANSTATUSUI_CONTEXT * pContext;
368  LVITEMW li;
369  WCHAR szBuffer[100];
370  PIP_ADAPTER_INFO pAdapterInfo, pCurAdapter;
371  PIP_PER_ADAPTER_INFO pPerAdapter;
372  DWORD dwSize;
373  HWND hDlgCtrl;
374  RECT rect;
375 
376  switch (uMsg)
377  {
378  case WM_INITDIALOG:
379  pContext = (LANSTATUSUI_CONTEXT*)lParam;
380 
381  hDlgCtrl = GetDlgItem(hwndDlg, IDC_DETAILS);
382 
383  /* get client rect */
384  GetClientRect(hDlgCtrl, &rect);
385 
386  /* calculate column width */
387  dwSize = rect.right / 2;
388 
390  InsertColumnToListView(hDlgCtrl, IDS_VALUE, 1, dwSize);
391 
392  dwSize = 0;
393  pCurAdapter = NULL;
394  pAdapterInfo = NULL;
396  {
397  pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
398  if (pAdapterInfo)
399  {
400  if (GetAdaptersInfo(pAdapterInfo, &dwSize) == NO_ERROR)
401  {
402  pCurAdapter = pAdapterInfo;
403  while (pCurAdapter && pCurAdapter->Index != pContext->dwAdapterIndex)
404  pCurAdapter = pCurAdapter->Next;
405 
406  if (pCurAdapter->Index != pContext->dwAdapterIndex)
407  pCurAdapter = NULL;
408  }
409  }
410  }
411 
412  ZeroMemory(&li, sizeof(LVITEMW));
413  li.mask = LVIF_TEXT;
414  li.iSubItem = 1;
415  li.pszText = szBuffer;
416 
417  if (pCurAdapter)
418  {
420  if (li.iItem >= 0)
421  {
422  swprintf(szBuffer, L"%02x-%02x-%02x-%02x-%02x-%02x",pCurAdapter->Address[0], pCurAdapter->Address[1],
423  pCurAdapter->Address[2], pCurAdapter->Address[3], pCurAdapter->Address[4], pCurAdapter->Address[5]);
424  SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
425  }
426  li.iItem = InsertItemToListView(hDlgCtrl, IDS_IP_ADDRESS);
427  if (li.iItem >= 0)
428  if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
429  SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
430 
432  if (li.iItem >= 0)
433  if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpMask.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
434  SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
435 
437  if (li.iItem >= 0 && pCurAdapter->GatewayList.IpAddress.String[0] != '0')
438  {
439  if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->GatewayList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
440  SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
441  }
442 #if 0
445 #endif
446  }
447 
448  dwSize = 0;
450  {
451  pPerAdapter = static_cast<PIP_PER_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
452  if (pPerAdapter)
453  {
454  if (GetPerAdapterInfo(pContext->dwAdapterIndex, pPerAdapter, &dwSize) == ERROR_SUCCESS)
455  {
457  if (li.iItem >= 0)
458  AddIPAddressToListView(hDlgCtrl, &pPerAdapter->DnsServerList, li.iItem);
459  }
460  CoTaskMemFree(pPerAdapter);
461  }
462  }
463 #if 0
464  if (pCurAdapter)
465  {
467  AddIPAddressToListView(hDlgCtrl, &pCurAdapter->PrimaryWinsServer, li.iItem);
468  AddIPAddressToListView(hDlgCtrl, &pCurAdapter->SecondaryWinsServer, li.iItem+1);
469  }
470 #endif
471  CoTaskMemFree(pAdapterInfo);
472  break;
473  case WM_COMMAND:
474  if (LOWORD(wParam) == IDC_CLOSE)
475  {
476  EndDialog(hwndDlg, FALSE);
477  break;
478  }
479  }
480  return FALSE;
481 }
static VOID AddIPAddressToListView(HWND hDlgCtrl, PIP_ADDR_STRING pAddr, INT Index)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define IDS_DEF_GATEWAY
Definition: resource.h:109
#define CP_ACP
Definition: compat.h:99
#define IDS_WINS_SERVERS
Definition: resource.h:114
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:68
char String[4 *4]
Definition: iptypes.h:42
#define ZeroMemory
Definition: winbase.h:1635
#define NO_ERROR
Definition: dderror.h:5
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDS_DNS_SERVERS
Definition: resource.h:113
#define IDS_PROPERTY
Definition: resource.h:115
#define LVIF_TEXT
Definition: commctrl.h:2281
#define IDS_SUBNET_MASK
Definition: resource.h:108
#define IDS_PHYSICAL_ADDRESS
Definition: resource.h:106
int iSubItem
Definition: commctrl.h:2334
#define IDC_CLOSE
Definition: resource.h:52
static VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:58
#define IDS_LEASE_EXPIRES
Definition: resource.h:112
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
LPWSTR pszText
Definition: commctrl.h:2337
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_DETAILS
Definition: resource.h:50
UINT mask
Definition: commctrl.h:2332
#define IDS_VALUE
Definition: resource.h:25
static const WCHAR L[]
Definition: oid.c:1250
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:77
#define WM_COMMAND
Definition: winuser.h:1716
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static INT InsertItemToListView(HWND hDlgCtrl, UINT ResId)
#define IDS_IP_ADDRESS
Definition: resource.h:107
#define IDS_LEASE_OBTAINED
Definition: resource.h:111
IP_MASK_STRING IpMask
Definition: iptypes.h:48
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MultiByteToWideChar
Definition: compat.h:100
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:67
#define LVM_SETITEMW
Definition: commctrl.h:2369
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
#define WM_INITDIALOG
Definition: winuser.h:1715
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63

Referenced by LANStatusUiAdvancedDlg().

◆ LANStatusUiDlg()

INT_PTR CALLBACK LANStatusUiDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 571 of file lanstatusui.cpp.

576 {
578  LANSTATUSUI_CONTEXT * pContext;
579  LPPSHNOTIFY lppsn;
580 
581  switch (uMsg)
582  {
583  case WM_INITDIALOG:
585  pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
586  pContext->hwndDlg = hwndDlg;
587  InitializeLANStatusUiDlg(hwndDlg, pContext);
588  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
589  return TRUE;
590  case WM_COMMAND:
591  pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
593  {
594  if (pContext)
595  {
596  ShowNetConnectionProperties(pContext->pNet, GetParent(pContext->hwndDlg));
597  BringWindowToTop(GetParent(pContext->hwndDlg));
598  }
599  break;
600  }
601  else if (LOWORD(wParam) == IDC_ENDISABLE)
602  {
603  DisableNetworkAdapter(pContext->pNet, pContext, hwndDlg);
604  break;
605  }
606  case WM_NOTIFY:
607  lppsn = (LPPSHNOTIFY) lParam;
608  if (lppsn->hdr.code == PSN_APPLY || lppsn->hdr.code == PSN_RESET)
609  {
610  pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
612  pContext->hwndDlg = NULL;
613  return TRUE;
614  }
615  break;
616  }
617  return FALSE;
618 }
#define TRUE
Definition: types.h:120
INetConnection * pNet
Definition: lanstatusui.h:19
struct _PSHNOTIFY * LPPSHNOTIFY
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define DWLP_MSGRESULT
Definition: winuser.h:864
UINT code
Definition: winuser.h:3112
NMHDR hdr
Definition: prsht.h:312
BOOL WINAPI BringWindowToTop(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
Definition: module.h:566
VOID DisableNetworkAdapter(INetConnection *pNet, LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
#define PSNRET_NOERROR
Definition: prsht.h:129
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
HWND WINAPI GetParent(_In_ HWND)
#define PSN_RESET
Definition: prsht.h:118
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_ENDISABLE
Definition: resource.h:40
#define IDC_STATUS_PROPERTIES
Definition: resource.h:39
#define GetWindowLongPtr
Definition: treelist.c:73
VOID InitializeLANStatusUiDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define PROPSHEETPAGE
Definition: prsht.h:371
#define WM_NOTIFY
Definition: richedit.h:61
HRESULT ShowNetConnectionProperties(INetConnection *pNetConnect, HWND hwnd)

Referenced by ShowStatusPropertyDialog().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 680 of file lanstatusui.cpp.

681 {
682  // NOTE: This callback is needed to set large icon correctly.
683  HICON hIcon;
684  switch (uMsg)
685  {
686  case PSCB_INITIALIZED:
687  {
689  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
690  break;
691  }
692  }
693  return 0;
694 }
static HICON
Definition: imagelist.c:84
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
LONG_PTR LPARAM
Definition: windef.h:208
#define IDI_NET_IDLE
Definition: resource.h:10
#define PSCB_INITIALIZED
Definition: prsht.h:75
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by ShowStatusPropertyDialog().

◆ ShowStatusPropertyDialog()

VOID ShowStatusPropertyDialog ( LANSTATUSUI_CONTEXT pContext,
HWND  hwndDlg 
)

Definition at line 697 of file lanstatusui.cpp.

700 {
701  HPROPSHEETPAGE hppages[2];
702  PROPSHEETHEADERW pinfo;
703  NETCON_PROPERTIES * pProperties = NULL;
704 
705  ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
706  ZeroMemory(hppages, sizeof(hppages));
707  pinfo.dwSize = sizeof(PROPSHEETHEADERW);
708  pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW |
710  pinfo.phpage = hppages;
711  pinfo.hwndParent = hwndDlg;
714  pinfo.pfnCallback = PropSheetProc;
715 
716  if (pContext->pNet->GetProperties(&pProperties) == S_OK)
717  {
718  if (pProperties->pszwName)
719  {
720  pinfo.pszCaption = pProperties->pszwName;
721  pinfo.dwFlags |= PSH_PROPTITLE;
722  }
723  InitializePropertyDialog(pContext, pProperties);
724  if (pProperties->MediaType == NCM_LAN && pProperties->Status == NCS_CONNECTED)
725  {
727  if (hppages[0])
728  pinfo.nPages++;
729 
731  if (hppages[pinfo.nPages])
732  pinfo.nPages++;
733 
734  if (pinfo.nPages)
735  {
736  PropertySheetW(&pinfo);
737  }
738  }
739  else if (pProperties->Status == NCS_MEDIA_DISCONNECTED || pProperties->Status == NCS_DISCONNECTED ||
740  pProperties->Status == NCS_HARDWARE_DISABLED)
741  {
742  ShowNetConnectionProperties(pContext->pNet, pContext->hwndDlg);
743  }
744 
745  NcFreeNetconProperties(pProperties);
746  }
747 }
HWND hwndParent
Definition: prsht.h:277
INetConnection * pNet
Definition: lanstatusui.h:19
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
INT_PTR CALLBACK LANStatusUiDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
#define ZeroMemory
Definition: winbase.h:1635
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PSH_USECALLBACK
Definition: prsht.h:48
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
#define PSH_USEICONID
Definition: prsht.h:42
LPCWSTR pszCaption
Definition: prsht.h:283
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
PFNPROPSHEETCALLBACK pfnCallback
Definition: prsht.h:293
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
HPROPSHEETPAGE InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
Definition: netshell.cpp:29
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2896
INT_PTR CALLBACK LANStatusUiAdvancedDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define PSH_PROPTITLE
Definition: prsht.h:40
HINSTANCE hInstance
Definition: prsht.h:278
#define IDI_NET_IDLE
Definition: resource.h:10
LPCWSTR pszIcon
Definition: prsht.h:281
Definition: netcon.h:71
DWORD dwSize
Definition: prsht.h:275
DWORD dwFlags
Definition: prsht.h:276
HPROPSHEETPAGE * phpage
Definition: prsht.h:291
#define IDD_LAN_NETSTATUSADVANCED
Definition: resource.h:23
#define S_OK
Definition: intsafe.h:59
#define IDD_LAN_NETSTATUS
Definition: resource.h:21
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87
NETCON_STATUS Status
Definition: netcon.h:86
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID InitializePropertyDialog(LANSTATUSUI_CONTEXT *pContext, NETCON_PROPERTIES *pProperties)
HRESULT ShowNetConnectionProperties(INetConnection *pNetConnect, HWND hwnd)

Referenced by LANStatusDlg().

◆ UpdateLanStatus()

VOID UpdateLanStatus ( HWND  hwndDlg,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 119 of file lanstatusui.cpp.

120 {
121  MIB_IFROW IfEntry;
122  HICON hIcon, hOldIcon = NULL;
124  NETCON_PROPERTIES * pProperties = NULL;
125 
126  ZeroMemory(&IfEntry, sizeof(IfEntry));
127  IfEntry.dwIndex = pContext->dwAdapterIndex;
128  if (GetIfEntry(&IfEntry) != NO_ERROR)
129  {
130  return;
131  }
132 
133  hIcon = NULL;
135  {
136  if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
137  {
139  pContext->Status = 0;
140  }
141  else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
142  {
144  pContext->Status = 1;
145  }
146  else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->Status != 2)
147  {
149  pContext->Status = 2;
150  }
151  else if (pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 3)
152  {
154  pContext->Status = 3;
155  }
156  }
158  {
159  if (pContext->Status != 4)
160  {
162  pContext->Status = 4;
163  }
164  }
166  {
167  if (pContext->Status != 5)
168  {
170  pContext->Status = 5;
171  }
172  }
173 
174  if (hwndDlg && hIcon)
175  {
176  hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON, (WPARAM)hIcon, 0);
177  if (hOldIcon)
178  DestroyIcon(hOldIcon);
179  }
180 
181  ZeroMemory(&nid, sizeof(nid));
182  nid.cbSize = sizeof(nid);
183  nid.uID = pContext->uID;
184  nid.hWnd = pContext->hwndStatusDlg;
185  nid.uVersion = NOTIFYICON_VERSION;
186 
187  if (pContext->pNet->GetProperties(&pProperties) == S_OK)
188  {
189  if (pProperties->dwCharacter & NCCF_SHOW_ICON)
190  {
191  if (hwndDlg)
193  else
194  nid.hIcon = hIcon;
195 
196  if (nid.hIcon)
197  nid.uFlags |= NIF_ICON;
198 
199  nid.uFlags |= NIF_STATE;
200  nid.dwState = 0;
201  nid.dwStateMask = NIS_HIDDEN;
202 
203  if (pProperties->pszwName)
204  {
205  if (wcslen(pProperties->pszwName) * sizeof(WCHAR) < sizeof(nid.szTip))
206  {
207  nid.uFlags |= NIF_TIP;
208  wcscpy(nid.szTip, pProperties->pszwName);
209  }
210  else
211  {
212  CopyMemory(nid.szTip, pProperties->pszwName, sizeof(nid.szTip) - sizeof(WCHAR));
213  nid.szTip[(sizeof(nid.szTip)/sizeof(WCHAR))-1] = L'\0';
214  nid.uFlags |= NIF_TIP;
215  }
216  }
217  }
218  else
219  {
220  nid.uFlags |= NIF_STATE;
221  nid.dwState = NIS_HIDDEN;
222  nid.dwStateMask = NIS_HIDDEN;
223 
224  }
225  NcFreeNetconProperties(pProperties);
226  }
227 
229 
230  if (nid.uFlags & NIF_ICON)
232 
233  pContext->dwInOctets = IfEntry.dwInOctets;
234  pContext->dwOutOctets = IfEntry.dwOutOctets;
235 
236  if (hwndDlg)
237  UpdateLanStatusUiDlg(hwndDlg, &IfEntry, pContext);
238 }
DWORD dwInOctets
Definition: ifmib.h:47
#define STM_SETICON
Definition: winuser.h:2053
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
INetConnection * pNet
Definition: lanstatusui.h:19
#define IDI_NET_REC
Definition: resource.h:12
NOTIFYICONDATA nid
Definition: magnifier.c:45
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
#define IDI_NET_OFF
Definition: resource.h:11
#define ZeroMemory
Definition: winbase.h:1635
UINT_PTR WPARAM
Definition: windef.h:207
#define NO_ERROR
Definition: dderror.h:5
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
#define MIB_IF_OPER_STATUS_NON_OPERATIONAL
Definition: ipifcons.h:246
DWORD dwStateMask
Definition: shellapi.h:237
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
CHAR szTip[128]
Definition: shellapi.h:235
#define NIF_TIP
Definition: shellapi.h:104
smooth NULL
Definition: ftsmooth.c:416
#define NIF_ICON
Definition: shellapi.h:103
#define IDI_NET_TRANSREC
Definition: resource.h:14
#define MIB_IF_OPER_STATUS_UNREACHABLE
Definition: ipifcons.h:247
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDI_NET_IDLE
Definition: resource.h:10
#define CopyMemory
Definition: winbase.h:1633
VOID UpdateLanStatusUiDlg(HWND hwndDlg, MIB_IFROW *IfEntry, LANSTATUSUI_CONTEXT *pContext)
Definition: lanstatusui.cpp:19
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define IDI_NET_TRANS
Definition: resource.h:13
#define S_OK
Definition: intsafe.h:59
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
DWORD dwOutOctets
Definition: ifmib.h:53
HICON hIcon
Definition: msconfig.c:44
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
#define LoadImage
Definition: winuser.h:5681
DWORD dwIndex
Definition: ifmib.h:38
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDC_NETSTAT
Definition: resource.h:44
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
Definition: systray.cpp:128
#define NIM_MODIFY
Definition: shellapi.h:92

Referenced by InitializeLANStatusUiDlg(), and LANStatusDlg().

◆ UpdateLanStatusUiDlg()

VOID UpdateLanStatusUiDlg ( HWND  hwndDlg,
MIB_IFROW IfEntry,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 19 of file lanstatusui.cpp.

23 {
24  WCHAR szFormat[MAX_PATH] = {0};
25  WCHAR szBuffer[MAX_PATH] = {0};
26  SYSTEMTIME TimeConnected;
27  DWORD DurationSeconds;
28  WCHAR Buffer[100];
29  WCHAR DayBuffer[30];
30  WCHAR LocBuffer[50];
31 
32 #if 0
33  ULONGLONG Ticks;
34 #else
35  DWORD Ticks;
36 #endif
37 
38  if (IfEntry->dwSpeed < 1000)
39  {
40  if (LoadStringW(netshell_hInstance, IDS_FORMAT_BIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
41  {
42  swprintf(szBuffer, szFormat, IfEntry->dwSpeed);
43  SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
44  }
45  }
46  else if (IfEntry->dwSpeed < 1000000)
47  {
48  if (LoadStringW(netshell_hInstance, IDS_FORMAT_KBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
49  {
50  swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000);
51  SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
52  }
53  }
54  else if (IfEntry->dwSpeed < 1000000000)
55  {
56  if (LoadStringW(netshell_hInstance, IDS_FORMAT_MBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
57  {
58  swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000);
59  SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
60  }
61  }
62  else
63  {
64  if (LoadStringW(netshell_hInstance, IDS_FORMAT_GBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
65  {
66  swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000000);
67  SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
68  }
69  }
70 
71  if (StrFormatByteSizeW(IfEntry->dwInOctets, szBuffer, sizeof(szFormat)/sizeof(WCHAR)))
72  {
73  SendDlgItemMessageW(hwndDlg, IDC_RECEIVED, WM_SETTEXT, 0, (LPARAM)szBuffer);
74  }
75 
76  if (StrFormatByteSizeW(IfEntry->dwOutOctets, szBuffer, sizeof(szFormat)/sizeof(WCHAR)))
77  {
78  SendDlgItemMessageW(hwndDlg, IDC_SEND, WM_SETTEXT, 0, (LPARAM)szBuffer);
79  }
80 
81 #if 0
82  Ticks = GetTickCount64();
83 #else
84  Ticks = GetTickCount();
85 #endif
86 
87  DurationSeconds = Ticks / 1000;
88  TimeConnected.wSecond = (DurationSeconds % 60);
89  TimeConnected.wMinute = (DurationSeconds / 60) % 60;
90  TimeConnected.wHour = (DurationSeconds / (60 * 60)) % 24;
91  TimeConnected.wDay = DurationSeconds / (60 * 60 * 24);
92 
93  if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &TimeConnected, L"HH':'mm':'ss", LocBuffer, sizeof(LocBuffer) / sizeof(LocBuffer[0])))
94  return;
95 
96  if (!TimeConnected.wDay)
97  {
98  SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)LocBuffer);
99  }
100  else
101  {
102  if (TimeConnected.wDay == 1)
103  {
104  if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAY, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
105  DayBuffer[0] = L'\0';
106  }
107  else
108  {
109  if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAYS, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
110  DayBuffer[0] = L'\0';
111  }
112  swprintf(Buffer, DayBuffer, TimeConnected.wDay, LocBuffer);
114  }
115 
116 }
#define IDC_RECEIVED
Definition: resource.h:38
DWORD dwInOctets
Definition: ifmib.h:47
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
#define LOCALE_USER_DEFAULT
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define IDS_FORMAT_KBIT
Definition: resource.h:99
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
DWORD dwSpeed
Definition: ifmib.h:41
#define IDS_DURATION_DAYS
Definition: resource.h:102
#define IDS_DURATION_DAY
Definition: resource.h:101
WORD wMinute
Definition: winbase.h:875
LONG_PTR LPARAM
Definition: windef.h:208
Definition: bufpool.h:45
#define IDC_DURATION
Definition: resource.h:42
#define WM_SETTEXT
Definition: winuser.h:1599
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDC_SEND
Definition: resource.h:37
uint64_t ULONGLONG
Definition: typedefs.h:65
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define IDC_SPEED
Definition: resource.h:43
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WORD wSecond
Definition: winbase.h:876
static const WCHAR L[]
Definition: oid.c:1250
#define IDS_FORMAT_BIT
Definition: resource.h:97
#define IDS_FORMAT_MBIT
Definition: resource.h:98
WORD wDay
Definition: winbase.h:873
DWORD dwOutOctets
Definition: ifmib.h:53
WORD wHour
Definition: winbase.h:874
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079
#define IDS_FORMAT_GBIT
Definition: resource.h:100

Referenced by UpdateLanStatus().