Jump to content

Managing Tabs ?

- - - - -

  • Please log in to reply
No replies to this topic

#1
Moudi

Moudi

    Programmer

  • Members
  • PipPipPipPip
  • 167 posts
Well i'm making a win32 project, ( not MFC )
here's my source
#include <windows.h>
#define ID_TABCTRL 1
#include <commctrl.h>



const char g_szClassName[] = "Window";
HWND hTab;
HINSTANCE g_hinst;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LRESULT count;
    TCITEM tie;

    switch(msg)
    {
        case WM_CREATE:
        {
            CreateWindow(TEXT("STATIC"), "Student name",
            WS_CHILD | WS_VISIBLE | SS_LEFT,
            100, 30, 200, 200,
            hwnd, (HMENU) 9, NULL,NULL);

            CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE |ES_AUTOHSCROLL|ES_AUTOHSCROLL|WS_BORDER,
                100, 50,200, 25, hwnd, (HMENU) 1,
                NULL, NULL);

             hTab = CreateWindow(WC_TABCONTROL, NULL, WS_CHILD | WS_VISIBLE,
     0, 0, 1000, 590, hwnd,(HMENU) 1, g_hinst, NULL);
                       tie.mask = TCIF_TEXT;
                       tie.pszText = "Add Info";
                       count = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
                       SendMessage(hTab, TCM_INSERTITEM, count, (LPARAM) (LPTCITEM) &tie);
                       tie.mask = TCIF_TEXT;
                       tie.pszText = "Retrieve Info";
                       count = SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0);
                       SendMessage(hTab, TCM_INSERTITEM, count, (LPARAM) (LPTCITEM) &tie);


        }
        break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;


    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, "Window Registration Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }


    hwnd = CreateWindow( wc.lpszClassName, "Grade Optimiser - Mouhammed",
                WS_VISIBLE | WS_CAPTION | WS_SYSMENU,
                CW_USEDEFAULT, CW_USEDEFAULT, 1000, 600, NULL,NULL, hInstance, 0);

    if(hwnd == NULL)
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);


    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
All i'm trying to do is to make the Textbox and static text appear on only 1 tab.
It must be something with the properties of the message.
Please try to help me, and yes i've googled alot :/




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users