Hi,

How to paint on a tabcontrol?
I tried to take the window handle or the tab handle but none of them works.

Code:
#include <windows.h>
#include <commctrl.h>
#include <iostream>
using namespace std;

#include <gdiplus.h>
using namespace Gdiplus;

VOID OnPaint(HDC hdc)
{
    Graphics graphics(hdc);
    Pen      pen(Color(255, 0, 0, 255));
    graphics.DrawLine(&pen, 20, 20, 150, 550);
}

char className[]="TabControl";
HWND hTab;
HINSTANCE hInst;

LRESULT CALLBACK WindowProcedure(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
{
    MSG messages;
    WNDCLASSEX wincl;
    hInst = hInstance;

    wincl.hInstance=hInstance;
    wincl.lpszClassName=className;
    wincl.lpfnWndProc=WindowProcedure;
    wincl.style=0;
    wincl.cbSize=sizeof(WNDCLASSEX);
    wincl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wincl.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
    wincl.hCursor=LoadCursor(NULL,IDC_ARROW);
    wincl.lpszMenuName=NULL;
    wincl.cbClsExtra=0;
    wincl.cbWndExtra=0;
    wincl.hbrBackground=HBRUSH(COLOR_3DFACE+1);

    if(!RegisterClassEx(&wincl))return 0;

    HWND windowHandle=CreateWindow(className,"TabControl",
                                   WS_OVERLAPPEDWINDOW,
                                   200,325,480,320,
                                   NULL,NULL,hInstance,NULL);
    ShowWindow(windowHandle,SW_SHOW);

    while(GetMessage(&messages,NULL,0,0))
    {
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    };
    return messages.wParam;
}

LRESULT CALLBACK WindowProcedure (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    switch(message)
    {
    case WM_CREATE:
        INITCOMMONCONTROLSEX icce;
        icce.dwSize=sizeof(INITCOMMONCONTROLSEX);
        icce.dwICC=ICC_TAB_CLASSES;
        InitCommonControlsEx(&icce);

        hTab=CreateWindow(WC_TABCONTROL,"",
                               WS_CHILD |WS_VISIBLE,
                               6,0,474,320,
                               hwnd,
                               NULL,hInst,NULL);
        TCITEM tab1Data;
        tab1Data.mask=TCIF_TEXT;
        tab1Data.pszText="Tab1";
        TabCtrl_InsertItem(hTab,0,&tab1Data);
        return 0;
    case WM_PAINT:
        hdc = BeginPaint(hTab, &ps);
        OnPaint(hdc);
        cout << "paint"<< endl;
        EndPaint(hTab, &ps);
        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,message,wParam,lParam);
    };
    return 0;
}