Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm learning windows api, I'm familiar now with it but the last thing I want to do is to make a tab control in the main window. Most of the tutorials suggest to use dialogs with it, but I'm confused. I cannot find full working example, maybe someone can share something about it because it is something that is missing.
Also I tried MFC but still the same, all tutorials and articles doing the same, creating a dialog based application and dropping tab control. I have a to make a big project, so it is a mandatory for to have a tab control in the main window.
Hope we can contribute together in a working example for this problem.
Thanks in advance.

What I have tried:

I tried an approach, someone on youtube has an example:
Video 18 Tab Control Window Creation - YouTube[^]

For now I will go with this approach, but I have some issues when I maximize the window, it says: Failed to register the window class.
I want to know if this example is a good approach. I I cannot find a solution, I have to use Lazarus/Free pascal.
I really want to make a desktop application with C++, my idea is to make project management software like Jira.
Posted
Updated 5-Mar-22 14:32pm

I want to know if this example is a good approach.

The Youtube solution seems to be a bit cumbersome. In particular, the code for the notify message could be solved with less effort.
Basically it should look like Richard McCutchan suggested.

C++
BOOL OnNotify(HWND hwndTab, HWND* hwndDisplay, LPARAM lParam)
{
	static int actualPage = 0;

	switch (((LPNMHDR)lParam)->code)
		{
			case TCN_SELCHANGING:
				{
					// Return FALSE to allow the selection to change.
					return FALSE;
				}

			case TCN_SELCHANGE:
				{
					int iPage = TabCtrl_GetCurSel(hwndTab);
					ShowWindow(hwndDisplay[actualPage], FALSE);
					ShowWindow(hwndDisplay[iPage], TRUE);
					actualPage = iPage;
					break;
				}
		}
		return TRUE;
}
 
Share this answer
 
The documentation on MSDN has all the details: About Tab Controls - Win32 apps | Microsoft Docs[^].

Note: experience by members of this site suggests that YouTube videos rarely provide very good learning. Stick to the written word.
 
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