-1

i would like to add tabs to my tabcontrol.

..........................................................................

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Current code:

#include <windows.h>
#include <commctrl.h>

#define TAB_CONTROL 1

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
    WNDCLASS wc{ 0 };
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hInstance = hInstance;
    wc.lpszClassName = "window";
    wc.lpfnWndProc = WndProc;

    if (RegisterClass(&wc))
    {
        CreateWindow("window", "window", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, 0, 0, 350, 350, 0, 0, 0, 0);

        MSG Msg{ 0 };

        while (GetMessage(&Msg, 0, 0, 0))
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
    }
    return 0;
}

LRESULT CALLBACK WndProc(HWND Hwnd, UINT Msg, WPARAM Wp, LPARAM Lp)
{
    switch (Msg)
    {
    case WM_CREATE:
        CreateWindow("SysTabControl32", 0, WS_CHILD | WS_VISIBLE, 0, 0, 350, 30, Hwnd, (HMENU)TAB_CONTROL, 0, 0);
        /* what here to add tabs like ("tab1", "tab2", "tab3") and switch between them */
        break;
    case WM_COMMAND:
        switch (Wp)
        {}
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(Hwnd, Msg, Wp, Lp);
    }
}
alqqu
  • 111
  • 1
  • 1
  • 8
  • 1
    Not related with tab-control, but why WndProc doesn't return any value for processed messages? It is UB. – rafix07 Jun 11 '19 at 07:54
  • 1
    Going to be a long haul for you until you discover that this control has documentation: https://learn.microsoft.com/en-us/windows/desktop/controls/tab-controls – David Heffernan Jun 11 '19 at 08:17
  • i posted some code about win32 tab controls here: https://stackoverflow.com/questions/56426662/how-to-prevent-controls-tabs-from-blinking-and-disappearing-with-windows-comm/56430730#56430730 – jwezorek Jun 11 '19 at 16:59

1 Answers1

0

Use TCM_INSERTITEM.

More info here.

Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78