summaryrefslogtreecommitdiff
path: root/protocols/CurrencyRates/src/WinCtrlHelper.h
blob: 7cb2c0515e5e46e9397609ce1bd6ea9273fe3736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef __a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__
#define __a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__

class ICurrencyRatesProvider;

inline std::wstring get_window_text(HWND hWnd)
{
	int cBytes = ::GetWindowTextLength(hWnd);

	std::vector<wchar_t> aBuf(cBytes + 1);
	LPTSTR pBuffer = &*(aBuf.begin());
	::GetWindowText(hWnd, pBuffer, cBytes + 1);

	return std::wstring(pBuffer);
}

inline void prepare_edit_ctrl_for_error(HWND hwndEdit)
{
	::SetFocus(hwndEdit);
	::SendMessage(hwndEdit, EM_SETSEL, 0, -1);
	::SendMessage(hwndEdit, EM_SCROLLCARET, 0, 0);
}

void show_variable_list(HWND hwndParent, const ICurrencyRatesProvider *pProvider);

inline int CurrencyRates_MessageBox(HWND hWnd, LPCTSTR pszText, UINT nType = MB_OK)
{
	return ::MessageBox(hWnd, pszText, currencyrates_a2t(MIRANDANAME).c_str(), nType);
}

inline void spin_set_range(HWND hwndSpin, short nLower, short nUpper)
{
	::SendMessage(hwndSpin, UDM_SETRANGE, 0, MAKELPARAM(nUpper, nLower));
}


#endif //__a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__