Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here's how I created the tabcontrol and the various associated tabs :


C++
RECT client_rect;
//inside WM_CREATE:

		GetClientRect(hwnd, &client_rect);

		HWND tab_handle = CreateWindowEx(NULL, WC_TABCONTROL, NULL,
	                      WS_CHILD | WS_VISIBLE,
	                      10, 10, client_rect.right - client_rect.left - 20,
	                      client_rect.bottom - client_rect.top - 20,
	                      hwnd, NULL,
	                      GetModuleHandle(NULL), NULL);

		TCITEM tab_info;
		memset(&tab_info, 0, sizeof(tab_info));
		tab_info.mask = TCIF_TEXT;
		tab_info.pszText = L"Tab #1";
		tab_info.cchTextMax = 5;
		SendMessage(tab_handle, TCM_INSERTITEM, 0, (LPARAM)&tab_info);
		tab_info.pszText = L"Tab #2";
		SendMessage(tab_handle, TCM_INSERTITEM, 1, (LPARAM)&tab_info);
		tab_info.pszText = L"Tab #3";
		SendMessage(tab_handle, TCM_INSERTITEM, 2, (LPARAM)&tab_info);
		tab_info.pszText = L"Tab #4";
		SendMessage(tab_handle, TCM_INSERTITEM, 2, (LPARAM)&tab_info);
		tab_info.pszText = L"Tab #5";
		SendMessage(tab_handle, TCM_INSERTITEM, 2, (LPARAM)&tab_info);


I'm using win7 controls (I read somewhere you really can't change it's text color property, is it true ?)

SubQuestion: why it works without having the need to call InitCommonControlsEx() ?
Posted

1 solution

Owner drawn tabs ...

http://msdn.microsoft.com/en-us/library/windows/desktop/bb760550%28v=vs.85%29.aspx[^]

Process WM_DRAWITEM messages by painting each tab onto the device context. Use SetTextColor to set the appropriate color before drawing each tab.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900