EDN Admin
Well-known member
Im using EnumChildWindows to set every control but for some reason it is not setting any control fonts if i initialize the TabControl. I tried setting the font without EnumChildWindows and using SendMessageW with the TabControl hwnd but it still doesnt
change its font.
<pre class="prettyprint case WM_CREATE:
{
RECT rcWnd = {0};
GetClientRect(hwnd, &rcWnd);
HWND blah = CreateWindowW(L"button", L"Click me!", WS_VISIBLE|WS_CHILD, 50, 50, 100, 20, hwnd, NULL, NULL, NULL);
cTabControl cTabCtrl;
cTabCtrl.CreateTabControlW(WS_VISIBLE|WS_CHILD, rcWnd.left, rcWnd.top, rcWnd.right + 3, rcWnd.bottom + 2, hwnd, NULL, NULL);
LPWSTR lpcwTabTitles[] = {L"Tab Title", L"Tab Title", L"Tab Title", L"Tab Title", L"Tab Title"};
cTabCtrl.Add_Tabs(lpcwTabTitles, 5, IDI_TAB_APPINFO, 5);
EnumChildWindows(hwnd, EnumChildProc, NULL);
break;
}[/code]
<br/>
<pre class="prettyprint BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
SendMessageW(hwnd, WM_SETFONT, reinterpret_cast<WPARAM>(CreateFontW(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Segoe UI")), TRUE);
return TRUE;
}[/code]
<br/>
Heres the function im using to add tabs
<pre class="prettyprint int cTabControl::Add_Tabs(LPWSTR pszText[], const short nTabCount, const short nBaseResID, const short nImgCount)
{
int nReturn;
for (short i = 0; i < nTabCount + 1; i++)
{
m_hIcon = (HICON)LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(nBaseResID + i), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
m_tcItem.mask = TCIF_TEXT;
m_tcItem.cchTextMax = wcslen(pszText) + 1;
m_tcItem.pszText = pszText;
nReturn = TabCtrl_InsertItem(m_hTabCtrl, i, &m_tcItem);
DeleteObject(m_hIcon);
}
return nReturn;
}
[/code]
<br/>
Here a preview with the tab control
<img alt="" src="http://i.minus.com/ibyauKfkBEeECn.PNG
Here it is without the tabcontrol
<img alt="" src="http://i.minus.com/i3awu1mSS6cwt.PNG
View the full article
change its font.
<pre class="prettyprint case WM_CREATE:
{
RECT rcWnd = {0};
GetClientRect(hwnd, &rcWnd);
HWND blah = CreateWindowW(L"button", L"Click me!", WS_VISIBLE|WS_CHILD, 50, 50, 100, 20, hwnd, NULL, NULL, NULL);
cTabControl cTabCtrl;
cTabCtrl.CreateTabControlW(WS_VISIBLE|WS_CHILD, rcWnd.left, rcWnd.top, rcWnd.right + 3, rcWnd.bottom + 2, hwnd, NULL, NULL);
LPWSTR lpcwTabTitles[] = {L"Tab Title", L"Tab Title", L"Tab Title", L"Tab Title", L"Tab Title"};
cTabCtrl.Add_Tabs(lpcwTabTitles, 5, IDI_TAB_APPINFO, 5);
EnumChildWindows(hwnd, EnumChildProc, NULL);
break;
}[/code]
<br/>
<pre class="prettyprint BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
SendMessageW(hwnd, WM_SETFONT, reinterpret_cast<WPARAM>(CreateFontW(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, L"Segoe UI")), TRUE);
return TRUE;
}[/code]
<br/>
Heres the function im using to add tabs
<pre class="prettyprint int cTabControl::Add_Tabs(LPWSTR pszText[], const short nTabCount, const short nBaseResID, const short nImgCount)
{
int nReturn;
for (short i = 0; i < nTabCount + 1; i++)
{
m_hIcon = (HICON)LoadImageW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(nBaseResID + i), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
m_tcItem.mask = TCIF_TEXT;
m_tcItem.cchTextMax = wcslen(pszText) + 1;
m_tcItem.pszText = pszText;
nReturn = TabCtrl_InsertItem(m_hTabCtrl, i, &m_tcItem);
DeleteObject(m_hIcon);
}
return nReturn;
}
[/code]
<br/>
Here a preview with the tab control
<img alt="" src="http://i.minus.com/ibyauKfkBEeECn.PNG
Here it is without the tabcontrol
<img alt="" src="http://i.minus.com/i3awu1mSS6cwt.PNG
View the full article