Thread: C++ Formating Tab Control

  1. #1
    Registered User
    Join Date
    Apr 2010

    C++ Formating Tab Control

    Hello everybody.

    I am trying to format my tab control that I am making. I am currently using CreateWindowEX to create the tab control.

    tab_content.mask = TCIF_TEXT;
    tab_content.pszText = "Tab 0";
    TabCtrl_InsertItem(hwnd_tabs, 0, &tab_content);
    tab_content.pszText = "Tab 1";
    TabCtrl_InsertItem(hwnd_tabs, 1, &tab_content);
    Can somebody direct me on how I would go about setting the font for this?

  2. #2
    Registered User
    Join Date
    Mar 2007
    Directly from how I set up my tabs with a default font type.

            case WM_INITDIALOG:
                //LOAD TABS
                RECT rect;
                OptionsHwnd = hwnd;
                //Get the size of the initial window space to work with
                GetClientRect(hwnd, &rect);
                //Create tabbed window
                hwndTab = CreateWindow(WC_TABCONTROL,"",WS_CHILD|WS_VISIBLE,
                //Set up tabs
                tcitem.mask = TCIF_TEXT;
                tcitem.iImage = -1;
                //Create tabs
                tcitem.pszText = "Startup"; tabctrl[0] = TabCtrl_InsertItem(hwndTab, 0, &tcitem);
                tcitem.pszText = "Run Time"; tabctrl[1]= TabCtrl_InsertItem(hwndTab, 1, &tcitem);
                //Change tab font
                SendMessage (hwndTab,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
    You can use this snippet to change the font how you see fit.
    // create the font
                        LOGFONT lf;
                        lf.lfItalic = 0;
                        lf.lfStrikeOut = 0;
                        lf.lfUnderline = 0;
                        lf.lfQuality = 255;
                        int ptSize = 11; // point size
                        HDC hDC = GetDC (NULL);
                        HFONT st_hEditFont;
                        lf.lfHeight = -MulDiv(ptSize, GetDeviceCaps (hDC, LOGPIXELSY), 72);
                        ReleaseDC (NULL, hDC);
                        lstrcpy (lf.lfFaceName, "Courier New"); // font name
                        st_hEditFont = CreateFontIndirect (&lf);
                        SendDlgItemMessage (hwnd, ID_EDIT_BOX, WM_SETFONT, (WPARAM) st_hEditFont, 0);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple tab control using TCITEM?
    By EJohnsonIII in forum Windows Programming
    Replies: 1
    Last Post: 02-08-2010, 01:06 AM
  2. Help in file Manipulation
    By arunvijay19 in forum C Programming
    Replies: 5
    Last Post: 02-07-2010, 05:23 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Tab order in Tab Control
    By Halloko in forum Windows Programming
    Replies: 2
    Last Post: 05-08-2005, 11:08 PM
  5. tab control
    By tyouk in forum Windows Programming
    Replies: 6
    Last Post: 02-07-2005, 11:47 PM