Thread: C++ Formating Tab Control

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    5

    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.

    Code:
    hwnd_tabs = CreateWindowEx(0,WC_TABCONTROL,"",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|TCS_FLATBUTTONS|TCS_BUTTONS|TCS_TABS|TCS_EX_FLATSEPARATORS,10,10,590,390,hwnd,NULL,g_hinst,NULL);
    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
    Posts
    416
    Directly from how I set up my tabs with a default font type.

    Code:
            case WM_INITDIALOG:
            {
                //LOAD TABS
    
                RECT rect;
                OptionsHwnd = hwnd;
    
                //Get the size of the initial window space to work with
                GetClientRect(hwnd, &rect);
                InitCommonControls();
    
                //Create tabbed window
                hwndTab = CreateWindow(WC_TABCONTROL,"",WS_CHILD|WS_VISIBLE,
                    0,0,rect.right,rect.bottom,hwnd,NULL,
                    (HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
    
                //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.
    Code:
    // 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