Skip to content

Commit 33207ed

Browse files
committed
[WLANWIZ] Update 'Connect' button outside of drawing routine
1 parent 7f69cb9 commit 33207ed

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

dll/shellext/wlanwiz/draw.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,11 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
348348
if (pdis->itemState & ODS_SELECTED)
349349
{
350350
ATL::CStringW cswExpandedText = L"";
351-
ATL::CStringW cswConnectButtonText = L"";
352351

353352
if (wlanNetwork.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
354-
{
355-
cswConnectButtonText.LoadStringW(IDS_WLANWIZ_DISCONNECT);
356353
cswExpandedText.LoadStringW(IDS_WLANWIZ_EXPAND_CONNECTED);
357-
}
358354
else
359355
{
360-
cswConnectButtonText.LoadStringW(IDS_WLANWIZ_CONNECT);
361356
if (wlanNetwork.bSecurityEnabled)
362357
{
363358
wlanNetwork.dot11DefaultAuthAlgorithm < DOT11_AUTH_ALGO_WPA
@@ -377,7 +372,6 @@ LRESULT CWlanWizard::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
377372
};
378373

379374
DrawTextW(pdis->hDC, cswExpandedText, cswExpandedText.GetLength(), &rcExpandedText, DT_WORDBREAK | DT_LEFT);
380-
GetDlgItem(IDC_WLANWIZ_MAINBUTTON).SetWindowTextW(cswConnectButtonText);
381375
}
382376

383377
SetTextColor(pdis->hDC, crItemText);

dll/shellext/wlanwiz/wlanwiz.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ LRESULT CWlanWizard::OnListBox(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
317317
{
318318
case LBN_SELCHANGE:
319319
ATL::CWindow cwLB = hWndCtl;
320+
ATL::CStringW cswConnectButtonText = L"";
321+
320322
LRESULT dwItemID = cwLB.SendMessageW(LB_GETCURSEL, 0, 0);
323+
DWORD dwConnectBtnStringID = IDS_WLANWIZ_CONNECT;
321324

322325
if (dwItemID == LB_ERR)
323326
break;
@@ -326,9 +329,16 @@ LRESULT CWlanWizard::OnListBox(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
326329
cwLB.SendMessageW(LB_SETITEMHEIGHT, dwItemID, 136);
327330

328331
this->dwSelectedItemID = static_cast<DWORD>(dwItemID);
332+
LRESULT itemRealID = cwLB.SendMessageW(LB_GETITEMDATA, dwItemID);
329333

330334
cwLB.Invalidate(FALSE);
331335
cwLB.UpdateWindow();
336+
337+
if (this->lstWlanNetworks->Network[itemRealID].dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
338+
dwConnectBtnStringID = IDS_WLANWIZ_DISCONNECT;
339+
340+
cswConnectButtonText.LoadStringW(dwConnectBtnStringID);
341+
m_ConnectButton.SetWindowTextW(cswConnectButtonText);
332342
break;
333343
}
334344

0 commit comments

Comments
 (0)