Skip to content

Commit

Permalink
[WLANWIZ] Visually distinguish ad hoc and infrastructure BSS
Browse files Browse the repository at this point in the history
  • Loading branch information
SigmaTel71 committed Sep 2, 2024
1 parent 03f12bb commit ecd186d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
33 changes: 29 additions & 4 deletions dll/shellext/wlanwiz/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
if (wlanNetwork.bSecurityEnabled)
{
DrawIconEx(pdis->hDC,
4,
52,
pdis->rcItem.top + 36,
LoadIconW(GetModuleHandleW(L"shell32.dll"), MAKEINTRESOURCEW(48)), /* lock icon */
16,
Expand All @@ -223,7 +223,7 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
}

crItemText = SetTextColor(pdis->hDC, GetSysColor(pdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
TextOutW(pdis->hDC, 4, pdis->rcItem.top + 4, cswWindowText, cswWindowText.GetLength()); /* SSID */
TextOutW(pdis->hDC, 52, pdis->rcItem.top + 4, cswWindowText, cswWindowText.GetLength()); /* SSID */
this->lfCaption.lfWeight = FW_NORMAL;

SelectObject(pdis->hDC, hOld);
Expand All @@ -232,13 +232,14 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
/* Is network password-protected? */
ATL::CStringW cswNetworkSecurity = L"";


if (wlanNetwork.dot11BssType == dot11_BSS_type_infrastructure)
cswNetworkSecurity.LoadStringW(wlanNetwork.bSecurityEnabled ? IDS_WLANWIZ_ENCRYPTED_AP : IDS_WLANWIZ_UNENCRYPTED_AP);
else if (wlanNetwork.dot11BssType == dot11_BSS_type_independent)
cswNetworkSecurity.LoadStringW(wlanNetwork.bSecurityEnabled ? IDS_WLANWIZ_ENCRYPTED_IBSS : IDS_WLANWIZ_UNENCRYPTED_IBSS);

TextOutW(pdis->hDC,
wlanNetwork.bSecurityEnabled ? 24 : 16,
wlanNetwork.bSecurityEnabled ? 72 : 64,
pdis->rcItem.top + 38,
cswNetworkSecurity, cswNetworkSecurity.GetLength());

Expand All @@ -260,16 +261,40 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
else if (uRSSI >= 96)
iRSSIResIcon = IDI_WLANICON_100;

HICON hicnRes = LoadIconW(wlanwiz_hInstance, MAKEINTRESOURCEW(iRSSIResIcon));

DrawIconEx(pdis->hDC,
pdis->rcItem.right - 36,
pdis->rcItem.top + 24,
LoadIconW(wlanwiz_hInstance, MAKEINTRESOURCEW(iRSSIResIcon)),
hicnRes,
32,
32,
NULL,
NULL,
DI_NORMAL);

DestroyIcon(hicnRes);

int iBSSIcon = IDI_BSS_INFRA;

if (wlanNetwork.dot11BssType == dot11_BSS_type_independent)
iBSSIcon = IDI_BSS_ADHOC;

/* LoadImageW refuses to load 48px icon properly */
hicnRes = static_cast<HICON>(LoadImageW(wlanwiz_hInstance, MAKEINTRESOURCEW(iBSSIcon), IMAGE_ICON, 48, 48, LR_LOADTRANSPARENT));

DrawIconEx(pdis->hDC,
pdis->rcItem.left + 2,
pdis->rcItem.top + 3,
hicnRes,
48,
48,
NULL,
NULL,
DI_NORMAL);

DestroyIcon(hicnRes);

/* Shrink focus rectangle for listbox items */
pdis->rcItem.left += 1;
pdis->rcItem.top += 1;
Expand Down
Binary file added dll/shellext/wlanwiz/res/bss_adhoc.ico
Binary file not shown.
Binary file added dll/shellext/wlanwiz/res/bss_infra.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions dll/shellext/wlanwiz/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#define IDI_AP_CONNECTING 110
#define IDI_AP_DHCP_FAILED 111

#define IDI_BSS_INFRA 112
#define IDI_BSS_ADHOC 113

/* Dialog resources */
#define IDD_WLANWIZ_DIALOG 400
#define IDD_WLANWIZ_CHOOSE_NET_TITLE 401
Expand Down
3 changes: 3 additions & 0 deletions dll/shellext/wlanwiz/wlanwiz.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ IDI_AP_UNAVAILABLE ICON "res/ap_unavail.ico"
IDI_AP_CONNECTING ICON "res/ap_conn.ico"
IDI_AP_DHCP_FAILED ICON "res/dhcp_fail.ico"

IDI_BSS_INFRA ICON "res/bss_infra.ico"
IDI_BSS_ADHOC ICON "res/bss_adhoc.ico"

IDI_WLANWIZ_SCAN_NETWORKS ICON "res/refresh.ico"
IDI_WLANWIZ_INSTALL_WLAN ICON "res/wlanwiz.ico"
IDI_WLANWIZ_PREFERRED_APS ICON "res/favorite.ico"
Expand Down

0 comments on commit ecd186d

Please sign in to comment.