WinAPI Panel Output

I am writing a C-based WinAPI program that has a tab control in the client area of ​​the main window. This tab control works fine, except there is some kind of rendering problem on the tabs. The tab headers are rendered in bold, uninstalled font and therefore spend a lot of screen real estate: Here are the tabs that look like in almost every other application:

I use this code to customize the tab control:

RECT rcClient, rcTool, rcTab;
TCHAR tabTitleTmp[256]; // Temp string buffer

HWND hTool = GetDlgItem(hWnd, IDC_MAIN_TOOL);
GetWindowRect(hTool, &rcTool);
int iToolHeight = rcTool.bottom - rcTool.top;

// Get parent client rect
GetClientRect(hWnd, &rcClient); 

// Create tab control
HWND hwndTab = CreateWindowEx(NULL, WC_TABCONTROL, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 
     0, iToolHeight, rcClient.right, rcClient.bottom - iToolHeight, hWnd, (HMENU) IDC_MAIN_TAB,
     hInst, NULL);

// Create tab items
TCITEM tie; 
tie.mask = TCIF_TEXT | TCIF_IMAGE; 
tie.iImage = -1; 
tie.pszText = tabTitleTmp; 

// Set up tabs
for(int i = 0; i < 8; i++) {
    LoadString(hInst, IDC_TAB_GENERAL + i, tabTitleTmp, sizeof(tabTitleTmp) / sizeof(tabTitleTmp[0]));
    TabCtrl_InsertItem(hwndTab, i, &tie);
}

Does anyone know a solution to this problem? I haven't found it on Google yet, and I'm starting to think that this might just be a mistake in WinAPI. Thanks for any answers!

: InitCommonControlsEx() , .

+4
1

, SendMessage() WM_SETFONT. GetStockObject(DEFAULT_GUI_FONT), GUI , SystemParametersInfo(), , , CreateFont(),

NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, NULL);
HFONT hFont = CreateFontIndirect(&ncm.lfMessageFont);
SendMessage(hwndTab, WM_SETFONT, (WPARAM)hFont, true);
+4

All Articles