コード例 #1
0
ファイル: TabCtrlSSL.cpp プロジェクト: githubbar/NewVision
int CTabCtrlSSL::AddPage (LPCTSTR pszTitle, int nPageID, TabDelete tabDelete) {
	// Add a page to the tab control.
	TC_ITEM item;
	item.mask = TCIF_TEXT;
	item.pszText = (LPTSTR) pszTitle;
	int nIndex = GetItemCount ();
	
	if (InsertItem (nIndex, &item) == -1)
		return -1;

    if (NULL == tabDelete.pTabPage) {
		// Fail - no point calling the function with a NULL pointer!
		DeleteItem (nIndex);
		return -1;
	}
	else {
		// Record the address of the dialog object and the page ID.
		int nArrayIndex = m_tabs.Add (tabDelete);
		ASSERT (nIndex == nArrayIndex);

		nArrayIndex = m_nPageIDs.Add (nPageID);
		ASSERT (nIndex == nArrayIndex);

		// Size and position the dialog box within the view.
        tabDelete.pTabPage->SetParent (this); // Just to be sure

		CRect rect;
		GetClientRect (&rect);

		if (rect.Width () > 0 && rect.Height () > 0)
			ResizeDialog (nIndex, rect.Width (), rect.Height ());

		// Initialize the page.
		if (OnInitPage (nIndex, nPageID)) {
			// Make sure the first control in the dialog is the one that
			// receives the input focus when the page is displayed.
			if (tabDelete.pTabPage->GetTopWindow ()) {
				HWND hwndFocus = tabDelete.pTabPage->GetTopWindow ()->m_hWnd;
				nArrayIndex = m_hFocusWnd.Add (hwndFocus);
				ASSERT (nIndex == nArrayIndex);
			}
		}
		else {
			// Make the control that currently has the input focus is the one
			// that receives the input focus when the page is displayed.
			m_hFocusWnd.Add (::GetFocus ());
		}

		// If this is the first page added to the view, make it visible.
		if (nIndex == 0)
			tabDelete.pTabPage->ShowWindow (SW_SHOW);
	}
	return nIndex;
}
コード例 #2
0
BOOL
CThirdPage::OnSetActive()
{
    CPrinterSetupWizardSheet	*	psheet;
    Printer						*	printer;
    Service						*	service;

    psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
    require_quiet( psheet, exit );

    psheet->SetWizardButtons( PSWIZB_BACK );

    printer = psheet->GetSelectedPrinter();
    require_quiet( printer, exit );

    service = printer->services.front();
    require_quiet( service, exit );

    //
    // call OnInitPage once
    //
    if (!m_initialized)
    {
        OnInitPage();
        m_initialized = true;
    }

    //
    // <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
    //
    if ( DefaultPrinterExists() )
    {
        m_defaultPrinterCtrl.SetCheck( BST_UNCHECKED );
        printer->deflt = false;
    }
    else
    {
        m_defaultPrinterCtrl.SetCheck( BST_CHECKED );
        printer->deflt = true;
    }

    //
    // update the UI with the printer name
    //
    m_printerName.SetWindowText(printer->displayName);

    //
    // populate the list controls with the manufacturers and models
    // from ntprint.inf
    //
    PopulateUI( m_manufacturers );

    //
    // and try and match the printer
    //

    if ( psheet->GetLastPage() == psheet->GetPage(0) )
    {
        MatchPrinter( m_manufacturers, printer, service, true );

        if ( ( m_manufacturerSelected != NULL ) && ( m_modelSelected != NULL  ) )
        {
            GetParent()->PostMessage(PSM_SETCURSEL, 2 );
        }
    }
    else
    {
        SelectMatch(printer, service, m_manufacturerSelected, m_modelSelected);
    }

exit:

    return CPropertyPage::OnSetActive();
}