CODE:#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <iostream>
//#pragma comment(lib, "Comctl32.lib")
BOOL RegClass(WNDPROC, LPCTSTR, UINT);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE hInstance;
char szClassName[] = "Class";
char szTitle[] = "¬кладки";
int __stdcall _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
//InitCommonControls();
MSG msg;
HWND hwnd;
hInstance = hInstance;
if (!RegClass(WndProc, szClassName, COLOR_WINDOW))
return FALSE;
if (!(hwnd = CreateWindow(szClassName,
szTitle,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100,
50,
640,
480,
0,
0,
hInstance,
NULL)))
return FALSE;
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
BOOL RegClass(WNDPROC Proc, LPCTSTR szName, UINT brBackground)
{
WNDCLASS wc;
wc.style = wc.cbClsExtra = wc.cbWndExtra = 0;
wc.lpfnWndProc = Proc;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(brBackground + 1);
wc.lpszMenuName = (LPCTSTR)NULL;
wc.lpszClassName = szName;
return (RegisterClass(&wc) != 0);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int wmId;
TC_ITEM tabitem;
//static HWND d;
static HWND tab[3][3] = { 0 };
static HWND hButton1, hButton2, hTControl1, hTControl2;
switch (msg)
{
case WM_CREATE:
{
hTControl1 = CreateWindow(WC_TABCONTROL, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 240, 268, hwnd, NULL, hInstance, NULL);
tabitem.mask = TCIF_TEXT;
tabitem.iImage = 0;
tabitem.pszText = "1st tab";
SendMessage(hTControl1, TCM_INSERTITEM, 1, LPARAM(&tabitem));
tabitem.pszText = "2nd tab";
tabitem.iImage = 1;
SendMessage(hTControl1, TCM_INSERTITEM, 1, LPARAM(&tabitem));
tabitem.pszText = "3d tab";
tabitem.iImage = 2;
SendMessage(hTControl1, TCM_INSERTITEM, 1, LPARAM(&tabitem));
tab[0][0] = CreateWindow("button", "kn1", WS_CHILD | WS_VISIBLE, 30, 30, 40, 68, hTControl1, NULL, hInstance, NULL);
tab[2][1] = CreateWindowEx(0, "EDIT", "Hello1", WS_CHILD | WS_VISIBLE, 100, 100, 50, 50, hwnd, NULL, hInstance, NULL);
//tab[1][1] = CreateWindowEx(0, "EDIT", "Hello2", WS_CHILD | WS_VISIBLE, 100, 150, 50, 50, hwnd, NULL, hInstance, NULL);
tab[1][0] = CreateWindow("button", "kn2", WS_CHILD, 30, 30, 40, 68, hTControl1, NULL, hInstance, NULL);
tab[2][0] = CreateWindow("button", "kn3", WS_CHILD, 30, 30, 40, 68, hTControl1, NULL, hInstance, NULL);
return 0;
}
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == TCN_SELCHANGE)
{
wmId = SendMessage(hTControl1, TCM_GETCURSEL, 0, 0);
for (int j = 0; j < 3; j++)
{
for (int i = 0; i<3; i++) if (tab[i][j]) ShowWindow(tab[i][j], SW_HIDE);
ShowWindow(tab[wmId][j], SW_SHOW);
}
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}