Make these controls visible, 2nd tab page
Return to Main

Resume:

Details ...

  1. For the initial situation, the last controls added are invisible.

    TestVC0Dlg.cpp file - the new Text Code is red.


    // TestVC0Dlg.cpp : implementation file
    //

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

    /////////////////////////////////////////////////////////////////////////////
    // CTestVC0Dlg message handlers

    BOOL CTestVC0Dlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
    pSysMenu->AppendMenu(MF_SEPARATOR);
    pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
    }

    // Set the icon for this dialog. The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon

    // *** Initialize / declaration ***
    m_pDB = new CDaoDatabase;
    m_pRS = new CDaoRecordset(m_pDB);

    TCHAR curdir[MAX_PATH]; //MAX_PATH - Maximum length of directory
    CString Databasename;

    // Get Current Directory
    GetCurrentDirectory( MAX_PATH, curdir );

    //DataBase name, KJV.mdb at Current Directory
    Databasename = (CString)curdir + _T("\\KJV.mdb");
    m_pDB->Open(Databasename);

    m_pRS->Open(dbOpenDynaset, "SELECT * from BibleTable", 0);

    //Move to first available record
    m_pRS->Move(2);
    //Display the content of record
    CalculValue();
    //Stiuation of controls
    SetButtons(TRUE);

    //Initialize the Tab Comtrol
    TC_ITEM TabCtrlItem;
    TabCtrlItem.mask = TCIF_TEXT;
    TabCtrlItem.pszText = " By word ";
    m_tab1.InsertItem( 0, &TabCtrlItem );
    TabCtrlItem.pszText = " By address ";
    m_tab1.InsertItem( 1, &TabCtrlItem );

    //Make these controls visible or invisible, in the Tab Control
    m_staticsel.ShowWindow(SW_HIDE);
    m_combobook.ShowWindow(SW_HIDE);
    m_combotitle.ShowWindow(SW_HIDE);
    m_combochapter.ShowWindow(SW_HIDE);
    m_comboverse.ShowWindow(SW_HIDE);
    m_staticbook.ShowWindow(SW_HIDE);
    m_statictitle.ShowWindow(SW_HIDE);
    m_staticchapter.ShowWindow(SW_HIDE);
    m_staticverse.ShowWindow(SW_HIDE);


    m_searchlist.ShowWindow(SW_SHOW);
    m_edwordcontrol.ShowWindow(SW_SHOW);
    m_display.ShowWindow(SW_SHOW);
    m_statictype.ShowWindow(SW_SHOW);
    m_staticfoundcontrol.ShowWindow(SW_SHOW);

    //Show the header row of List Control
    int strWidth1 = m_searchlist.GetStringWidth(_T("00000"));
    m_searchlist.InsertColumn(1, _T("Record"), LVCFMT_LEFT,2*strWidth1, 1);
    m_searchlist.InsertColumn(2, _T("Bk"), LVCFMT_LEFT, strWidth1, 1);
    m_searchlist.InsertColumn(3, _T("Title"), LVCFMT_LEFT, 4*strWidth1, 1);
    m_searchlist.InsertColumn(4, _T("Ch"), LVCFMT_LEFT, strWidth1, 1);
    m_searchlist.InsertColumn(5, _T("Verse"), LVCFMT_LEFT, 3*strWidth1/2, 1);

    // TODO: Add extra initialization here

    return TRUE; // return TRUE unless you set the focus to a control
    }
    ................................................................................................................................................
    ................................................................................................................................................
    ...


  2. When you select a tab page, part of controls appears and other part is invisible or hide.
    ClassWizard, Edit Code - (function OnSelchange).
  3. In the ClassWizard dialog box, select the Message Maps tab and in the Class Name box,
    select the class CTestVC0Dlg.
  4. In the Member Functions list, select the function name - OnSelchangeTab1:
    Choose Edit Code
    -or-
    Double-click the function name.
    The insertion point moves to the function in theTestVC0Dlg.cpp file. Edit the Text Code, examine these changes ...

    TestVC0Dlg.cpp file
    - the new Text Code is red.

    // TestVC0Dlg.cpp : implementation file
    //

    #include "stdafx.h"
    #include "TestVC0.h"
    #include "TestVC0Dlg.h"
    ...
    ...................................................................................................................................................
    ...................................................................................................................................................


    void CTestVC0Dlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
    {
    int ntab = m_tab1.GetCurSel();
    switch(ntab)
    {
    case 0: //tab label = By word
    {
    m_staticsel.ShowWindow(SW_HIDE);
    m_combobook.ShowWindow(SW_HIDE);
    m_combotitle.ShowWindow(SW_HIDE);
    m_combochapter.ShowWindow(SW_HIDE);
    m_comboverse.ShowWindow(SW_HIDE);
    m_staticbook.ShowWindow(SW_HIDE);
    m_statictitle.ShowWindow(SW_HIDE);
    m_staticchapter.ShowWindow(SW_HIDE);
    m_staticverse.ShowWindow(SW_HIDE);

    m_searchlist.ShowWindow(SW_SHOW);
    m_edwordcontrol.ShowWindow(SW_SHOW);
    m_display.ShowWindow(SW_SHOW);
    m_statictype.ShowWindow(SW_SHOW);
    m_staticfoundcontrol.ShowWindow(SW_SHOW);

    break;
    }
    case 1: //tab label = By address
    {
    m_staticsel.ShowWindow(SW_SHOW);
    m_combobook.ShowWindow(SW_SHOW);
    m_combotitle.ShowWindow(SW_SHOW);
    m_combochapter.ShowWindow(SW_SHOW);
    m_comboverse.ShowWindow(SW_SHOW);
    m_staticbook.ShowWindow(SW_SHOW);
    m_statictitle.ShowWindow(SW_SHOW);
    m_staticchapter.ShowWindow(SW_SHOW);
    m_staticverse.ShowWindow(SW_SHOW);

    m_searchlist.ShowWindow(SW_HIDE);
    m_edwordcontrol.ShowWindow(SW_HIDE);
    m_display.ShowWindow(SW_HIDE);
    m_statictype.ShowWindow(SW_HIDE);
    m_staticfoundcontrol.ShowWindow(SW_HIDE);
    break;

    }
    }
    // TODO: Add your control notification handler code here

    *pResult = 0;
    }
    ...................................................................................................................................................
    ...................................................................................................................................................
    ...
  5. Return to Main