Udostępnij za pośrednictwem


Klasa CTaskDialog

Wyskakujące okno dialogowe, które działa jak okno komunikatu, ale może wyświetlać użytkownikowi dodatkowe informacje. Zawiera CTaskDialog również funkcje zbierania informacji od użytkownika.

Składnia

class CTaskDialog : public CObject

Członkowie

Konstruktory

Nazwa/nazwisko opis
CTaskDialog::CTaskDialog CTaskDialog Tworzy obiekt.

Metody

Nazwa/nazwisko opis
CTaskDialog::AddCommandControl Dodaje kontrolkę przycisku polecenia do elementu CTaskDialog.
CTaskDialog::AddRadioButton Dodaje przycisk radiowy do elementu CTaskDialog.
CTaskDialog::ClickCommandControl Klika kontrolkę przycisku polecenia lub wspólny przycisk programowo.
CTaskDialog::ClickRadioButton Programowo klika przycisk radiowy.
CTaskDialog::D oModal Wyświetla element CTaskDialog.
CTaskDialog::GetCommonButtonCount Pobiera liczbę dostępnych typowych przycisków.
CTaskDialog::GetCommonButtonFlag Konwertuje standardowy przycisk systemu Windows na wspólny typ przycisku skojarzony z klasą CTaskDialog .
CTaskDialog::GetCommonButtonId Konwertuje jeden z typowych typów przycisków skojarzonych z CTaskDialog klasą na standardowy przycisk systemu Windows.
CTaskDialog::GetOptions Zwraca flagi opcji dla tego CTaskDialogelementu .
CTaskDialog::GetSelectedCommandControlID Zwraca wybraną kontrolkę przycisku polecenia.
CTaskDialog::GetSelectedRadioButtonID Zwraca wybrany przycisk radiowy.
CTaskDialog::GetVerificationCheckboxState Pobiera stan pola wyboru weryfikacji.
CTaskDialog::IsCommandControlEnabled Określa, czy jest włączona kontrolka przycisku polecenia, czy wspólny przycisk.
CTaskDialog::IsRadioButtonEnabled Określa, czy przycisk radiowy jest włączony.
CTaskDialog::IsSupported Określa, czy komputer z uruchomioną aplikacją obsługuje program CTaskDialog.
CTaskDialog::LoadCommandControls Dodaje kontrolki przycisku polecenia przy użyciu danych z tabeli ciągów.
CTaskDialog::LoadRadioButtons Dodaje przyciski radiowe przy użyciu danych z tabeli ciągów.
CTaskDialog::NavigateTo Przenosi fokus na inny CTaskDialogelement .
CTaskDialog::OnCommandControlClick Platforma wywołuje tę metodę, gdy użytkownik kliknie kontrolkę przycisku polecenia.
CTaskDialog::OnCreate Struktura wywołuje tę metodę po utworzeniu metody CTaskDialog.
CTaskDialog::OnDestroy Struktura wywołuje tę metodę bezpośrednio przed zniszczeniem elementu CTaskDialog.
CTaskDialog::OnExpandButtonClick Platforma wywołuje tę metodę, gdy użytkownik kliknie przycisk rozszerzenia.
CTaskDialog::OnHelp Platforma wywołuje tę metodę, gdy użytkownik zażąda pomocy.
CTaskDialog::OnHyperlinkClick Struktura wywołuje tę metodę, gdy użytkownik kliknie hiperlink.
CTaskDialog::OnInit Struktura wywołuje tę metodę po CTaskDialog zainicjowaniu elementu .
CTaskDialog::OnNavigatePage Struktura wywołuje tę metodę, gdy użytkownik przenosi fokus w odniesieniu do kontrolek w obiekcie CTaskDialog.
CTaskDialog::OnRadioButtonClick Platforma wywołuje tę metodę, gdy użytkownik wybierze kontrolkę przycisku radiowego.
CTaskDialog::OnTimer Struktura wywołuje tę metodę po wygaśnięciu czasomierza.
CTaskDialog::OnVerificationCheckboxClick Struktura wywołuje tę metodę, gdy użytkownik kliknie pole wyboru weryfikacji.
CTaskDialog::RemoveAllCommandControls Usuwa wszystkie kontrolki poleceń z elementu CTaskDialog.
CTaskDialog::RemoveAllRadioButtons Usuwa wszystkie przyciski radiowe z elementu CTaskDialog.
CTaskDialog::SetCommandControlOptions Aktualizacje kontrolkę przycisku polecenia na .CTaskDialog
CTaskDialog::SetCommonButtonOptions Aktualizacje podzbiór typowych przycisków, które mają być włączone i wymagają podniesienia uprawnień kontroli dostępu użytkownika.
CTaskDialog::SetCommonButtons Dodaje typowe przyciski do elementu CTaskDialog.
CTaskDialog::SetContent Aktualizacje zawartość obiektu CTaskDialog.
CTaskDialog::SetDefaultCommandControl Określa domyślną kontrolkę przycisku polecenia.
CTaskDialog::SetDefaultRadioButton Określa domyślny przycisk radiowy.
CTaskDialog::SetDialogWidth Dostosowuje szerokość obiektu CTaskDialog.
CTaskDialog::SetExpansionArea Aktualizacje obszar rozszerzania obiektu CTaskDialog.
CTaskDialog::SetFooterIcon Aktualizacje ikonę stopki dla elementu CTaskDialog.
CTaskDialog::SetFooterText Aktualizacje tekst w stopce .CTaskDialog
CTaskDialog::SetMainIcon Aktualizacje główną ikonę .CTaskDialog
CTaskDialog::SetMainInstruction Aktualizacje głównej instrukcji .CTaskDialog
CTaskDialog::SetOptions Konfiguruje opcje dla elementu CTaskDialog.
CTaskDialog::SetProgressBarMarquee Konfiguruje pasek markizy dla elementu CTaskDialog i dodaje go do okna dialogowego.
CTaskDialog::SetProgressBarPosition Dostosowuje położenie paska postępu.
CTaskDialog::SetProgressBarRange Dostosowuje zakres paska postępu.
CTaskDialog::SetProgressBarState Ustawia stan paska postępu i wyświetla go na CTaskDialog.
CTaskDialog::SetRadioButtonOptions Włącza lub wyłącza przycisk radiowy.
CTaskDialog::SetVerificationCheckbox Ustawia sprawdzony stan pola wyboru weryfikacji.
CTaskDialog::SetVerificationCheckboxText Ustawia tekst po prawej stronie pola wyboru weryfikacji.
CTaskDialog::SetWindowTitle Ustawia tytuł .CTaskDialog
CTaskDialog::ShowDialog Tworzy i wyświetla element CTaskDialog.
CTaskDialog::TaskDialogCallback Struktura wywołuje to w odpowiedzi na różne komunikaty systemu Windows.

Składowe danych

Nazwa/nazwisko opis
m_aButtons Tablica kontrolek przycisków poleceń dla elementu CTaskDialog.
m_aRadioButtons Tablica kontrolek przycisków radiowych dla elementu CTaskDialog.
m_bVerified TRUE wskazuje pole wyboru weryfikacji jest zaznaczone; FALSE wskazuje, że nie jest.
m_footerIcon Ikona w stopce elementu CTaskDialog.
m_hWnd Dojście do okna dla elementu CTaskDialog.
m_mainIcon Główna ikona elementu CTaskDialog.
m_nButtonDisabled Maska wskazująca, które z typowych przycisków są wyłączone.
m_nButtonElevation Maska wskazująca, które z typowych przycisków wymagają podniesienia poziomu kontroli dostępu użytkownika.
m_nButtonId Identyfikator wybranego formantu przycisku polecenia.
m_nCommonButton Maska wskazująca, które typowe przyciski są wyświetlane na .CTaskDialog
m_nDefaultCommandControl Identyfikator kontrolki przycisku polecenia wybranej podczas wyświetlania CTaskDialog .
m_nDefaultRadioButton Identyfikator kontrolki przycisku radiowego wybranej podczas wyświetlania CTaskDialog .
m_nFlags Maska wskazująca opcje dla elementu CTaskDialog.
m_nProgressPos Bieżące położenie paska postępu. Ta wartość musi zawierać się między wartościami m_nProgressRangeMin i m_nProgressRangeMax.
m_nProgressRangeMax Maksymalna wartość paska postępu.
m_nProgressRangeMin Minimalna wartość paska postępu.
m_nProgressState Stan paska postępu. Aby uzyskać więcej informacji, zobacz CTaskDialog::SetProgressBarState.
m_nRadioId Identyfikator wybranego kontrolki przycisku radiowego.
m_nWidth Szerokość w pikselach CTaskDialog .
m_strCollapse Ciąg CTaskDialog wyświetlany po prawej stronie pola rozszerzenia po ukryciu rozszerzonych informacji.
m_strContent Ciąg zawartości obiektu CTaskDialog.
m_strExpand Ciąg CTaskDialog wyświetlany po prawej stronie pola rozszerzenia po wyświetleniu rozszerzonych informacji.
m_strFooter Stopka .CTaskDialog
m_strInformation Rozwinięte informacje dotyczące elementu CTaskDialog.
m_strMainInstruction Główna instrukcja obiektu CTaskDialog.
m_strTitle Tytuł .CTaskDialog
m_strVerification Ciąg wyświetlany CTaskDialog po prawej stronie pola wyboru weryfikacji.

Uwagi

Klasa CTaskDialog zastępuje standardowe pole komunikatów systemu Windows i ma dodatkowe funkcje, takie jak nowe kontrolki do zbierania informacji od użytkownika. Ta klasa znajduje się w bibliotece MFC w programie Visual Studio 2010 lub nowszym. Jest CTaskDialog dostępny począwszy od systemu Windows Vista. Wcześniejsze wersje systemu Windows nie mogą wyświetlić CTaskDialog obiektu. Służy CTaskDialog::IsSupported do określania w czasie wykonywania, czy bieżący użytkownik może wyświetlić okno dialogowe zadania. Standardowe okno komunikatów systemu Windows jest nadal obsługiwane.

Element CTaskDialog jest dostępny tylko podczas kompilowania aplikacji przy użyciu biblioteki Unicode.

Element CTaskDialog ma dwa różne konstruktory. Jeden konstruktor umożliwia określenie dwóch przycisków poleceń i maksymalnie sześciu regularnych kontrolek przycisków. Po utworzeniu polecenia CTaskDialogmożesz dodać więcej przycisków poleceń. Drugi konstruktor nie obsługuje żadnych przycisków poleceń, ale można dodać nieograniczoną liczbę zwykłych kontrolek przycisków. Aby uzyskać więcej informacji na temat konstruktorów, zobacz CTaskDialog::CTaskDialog.

Na poniższej ilustracji przedstawiono przykład CTaskDialog pokazujący lokalizację niektórych kontrolek.

Example of CTaskDialog.
Przykład CTaskDialog

Wymagania

Minimalny wymagany system operacyjny: Windows Vista

Nagłówek: afxtaskdialog.h

CTaskDialog::AddCommandControl

Dodaje nową kontrolkę przycisku polecenia do elementu CTaskDialog.

void AddCommandControl(
    int nCommandControlID,
    const CString& strCaption,
    BOOL bEnabled = TRUE,
    BOOL bRequiresElevation = FALSE);

Parametry

nCommandControlID
[in] Numer identyfikacyjny kontrolki polecenia.

strCaption
[in] Ciąg wyświetlany CTaskDialog użytkownikowi. Użyj tego ciągu, aby wyjaśnić przeznaczenie polecenia.

bEnabled
[in] Parametr logiczny wskazujący, czy nowy przycisk jest włączony, czy wyłączony.

bRequiresElevation
[in] Parametr logiczny wskazujący, czy polecenie wymaga podniesienia uprawnień.

Uwagi

Kontrolka CTaskDialog Class może wyświetlać nieograniczoną liczbę kontrolek przycisków poleceń. Jeśli CTaskDialog jednak zostanie wyświetlony dowolny przycisk polecenia, może wyświetlić maksymalnie sześć przycisków. Jeśli kontrolka CTaskDialog przycisku polecenia nie ma, może wyświetlać nieograniczoną liczbę przycisków.

Gdy użytkownik wybierze kontrolkę przycisku polecenia, zostanie zamknięta CTaskDialog . Jeśli aplikacja wyświetla okno dialogowe przy użyciu CTaskDialog::D oModal, DoModal zwraca nCommandControlID wybranego kontrolki przycisku polecenia.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::AddRadioButton

Dodaje przycisk radiowy do elementu CTaskDialog.

void CTaskDialog::AddRadioButton(
    int nRadioButtonID,
    const CString& strCaption,
    BOOL bEnabled = TRUE);

Parametry

nRadioButtonID
[in] Numer identyfikacyjny przycisku radiowego.

strCaption
[in] Ciąg CTaskDialog wyświetlany obok przycisku radiowego.

bEnabled
[in] Parametr logiczny wskazujący, czy przycisk radiowy jest włączony.

Uwagi

Przyciski radiowe klasy CTaskDialog umożliwiają zbieranie informacji od użytkownika. Użyj funkcji CTaskDialog::GetSelectedRadioButtonID , aby określić, który przycisk radiowy jest wybrany.

Parametr CTaskDialog nRadioButtonID nie jest unikatowy dla każdego przycisku radiowego. Jednak może wystąpić nieoczekiwane zachowanie, jeśli nie używasz odrębnego identyfikatora dla każdego przycisku radiowego.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::ClickCommandControl

Klika kontrolkę przycisku polecenia lub wspólny przycisk programowo.

protected:
void ClickCommandControl(int nCommandControlID) const;

Parametry

nCommandControlID
[in] Identyfikator polecenia kontrolki do kliknięcia.

Uwagi

Ta metoda generuje komunikat systemu Windows TDM_CLICK_BUTTON.

CTaskDialog::ClickRadioButton

Programowo klika przycisk radiowy.

protected:
void ClickRadioButton(int nRadioButtonID) const;

Parametry

nRadioButtonID
[in] Identyfikator przycisku radiowego do kliknięcia.

Uwagi

Ta metoda generuje komunikat systemu Windows TDM_CLICK_RADIO_BUTTON.

CTaskDialog::CTaskDialog

Tworzy wystąpienie klasy CTaskDialog.

CTaskDialog(
    const CString& strContent,
    const CString& strMainInstruction,
    const CString& strTitle,
    int nCommonButtons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON,
    int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
    const CString& strFooter = _T(""));

CTaskDialog(
    const CString& strContent,
    const CString& strMainInstruction,
    const CString& strTitle,
    int nIDCommandControlsFirst,
    int nIDCommandControlsLast,
    int nCommonButtons,
    int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
    const CString& strFooter = _T(""));

Parametry

strContent
[in] Ciąg do użycia dla zawartości elementu CTaskDialog.

strMainInstruction
[in] Główna instrukcja obiektu CTaskDialog.

strTitle
[in] Tytuł .CTaskDialog

nCommonButtons
[in] Maska typowych przycisków do dodania do elementu CTaskDialog.

nTaskDialogOptions
[in] Zestaw opcji do użycia dla elementu CTaskDialog.

strFooter
[in] Ciąg do użycia jako stopka.

nIDCommandControlsFirst
[in] Identyfikator ciągu pierwszego polecenia.

nIDCommandControlsLast
[in] Identyfikator ciągu ostatniego polecenia.

Uwagi

Istnieją dwa sposoby dodawania elementu CTaskDialog do aplikacji. Pierwszym sposobem jest użycie jednego z konstruktorów do utworzenia CTaskDialog obiektu i wyświetlenia go przy użyciu CTaskDialog::D oModal. Drugim sposobem jest użycie funkcji statycznej CTaskDialog::ShowDialog, która umożliwia wyświetlanie CTaskDialog obiektu bez jawnego tworzenia CTaskDialog obiektu.

Drugi konstruktor tworzy kontrolki przycisku polecenia przy użyciu danych z pliku zasobu aplikacji. Tabela ciągów w pliku zasobu zawiera kilka ciągów ze skojarzonymi identyfikatorami ciągów. Ta metoda dodaje kontrolkę przycisku polecenia dla każdego prawidłowego wpisu w tabeli ciągów między nIDCommandControlsFirst i nCommandControlsLast, włącznie. W przypadku tych kontrolek przycisku polecenia ciąg w tabeli ciągów jest podpis kontrolki, a identyfikator ciągu jest identyfikatorem kontrolki.

Aby uzyskać listę prawidłowych opcji, zobacz CTaskDialog::SetOptions .

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::D oModal

CTaskDialog Pokazuje element i sprawia, że jest modalny.

INT_PTR DoModal (HWND hParent = ::GetActiveWindow());

Parametry

hParent
[in] Okno nadrzędne dla elementu CTaskDialog.

Wartość zwracana

Liczba całkowita odpowiadająca zaznaczeniu dokonanemu przez użytkownika.

Uwagi

Wyświetla to wystąpienie CTaskDialog. Następnie aplikacja czeka na zamknięcie okna dialogowego przez użytkownika.

Polecenie CTaskDialog zostanie zamknięte, gdy użytkownik wybierze wspólny przycisk, kontrolkę linku polecenia lub zamknie CTaskDialogelement . Wartość zwracana jest identyfikatorem wskazującym sposób zamknięcia okna dialogowego przez użytkownika.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::GetCommonButtonCount

Pobiera liczbę typowych przycisków.

int GetCommonButtonCount() const;

Wartość zwracana

Liczba dostępnych typowych przycisków.

Uwagi

Typowe przyciski to przyciski domyślne, które udostępniasz CTaskDialog::CTaskDialog. Klasa CTaskDialog wyświetla przyciski u dołu okna dialogowego.

Wyliczona lista przycisków jest dostępna w pliku CommCtrl.h.

CTaskDialog::GetCommonButtonFlag

Konwertuje standardowy przycisk systemu Windows na wspólny typ przycisku skojarzony z klasą CTaskDialog.

int GetCommonButtonFlag(int nButtonId) const;

Parametry

nButtonId
[in] Standardowa wartość przycisku systemu Windows.

Wartość zwracana

Wartość odpowiedniego CTaskDialog wspólnego przycisku. Jeśli nie ma odpowiedniego wspólnego przycisku, ta metoda zwraca wartość 0.

CTaskDialog::GetCommonButtonId

Konwertuje jeden z typowych typów przycisków skojarzonych z klasą CTaskDialog na standardowy przycisk systemu Windows.

int GetCommonButtonId(int nFlag);

Parametry

nFlag
[in] Typ wspólnego przycisku skojarzony z klasą CTaskDialog .

Wartość zwracana

Wartość odpowiedniego standardowego przycisku systemu Windows. Jeśli nie ma odpowiedniego przycisku systemu Windows, metoda zwraca wartość 0.

CTaskDialog::GetOptions

Zwraca flagi opcji dla tego CTaskDialogelementu .

int GetOptions() const;

Wartość zwracana

Flagi dla elementu CTaskDialog.

Uwagi

Aby uzyskać więcej informacji na temat opcji dostępnych dla klasy CTaskDialog, zobacz CTaskDialog::SetOptions.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::GetSelectedCommandControlID

Zwraca wybraną kontrolkę przycisku polecenia.

int GetSelectedCommandControlID() const;

Wartość zwracana

Identyfikator kontrolki przycisku polecenia aktualnie wybranego.

Uwagi

Nie musisz używać tej metody, aby pobrać identyfikator przycisku polecenia wybranego przez użytkownika. Ten identyfikator jest zwracany przez CTaskDialog::D oModal lub CTaskDialog::ShowDialog.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::GetSelectedRadioButtonID

Zwraca wybrany przycisk radiowy.

int GetSelectedRadioButtonID() const;

Wartość zwracana

Identyfikator wybranego przycisku radiowego.

Uwagi

Tej metody można użyć po zamknięciu okna dialogowego przez użytkownika w celu pobrania wybranego przycisku radiowego.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::GetVerificationCheckboxState

Pobiera stan pola wyboru weryfikacji.

BOOL GetVerificationCheckboxState() const;

Wartość zwracana

WARTOŚĆ TRUE, jeśli pole wyboru jest zaznaczone, fałsz, jeśli tak nie jest.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add the verification checkbox and set the default state.
taskDialog.SetVerificationCheckboxText(L"Remember your selection.");
taskDialog.SetVerificationCheckbox(false);

taskDialog.DoModal();

if (taskDialog.GetVerificationCheckboxState())
{
   // TODO: Write settings of the task dialog to the registry
}

CTaskDialog::IsCommandControlEnabled

Określa, czy jest włączona kontrolka lub przycisk polecenia.

BOOL IsCommandControlEnabled(int nCommandControlID) const;

Parametry

nCommandControlID
[in] Identyfikator kontrolki lub przycisku polecenia do przetestowania.

Wartość zwracana

Wartość TRUE, jeśli kontrolka jest włączona, false, jeśli nie.

Uwagi

Tej metody można użyć do określenia dostępności kontrolek przycisków poleceń i typowych przycisków CTaskDialog klasy*.

Jeśli nCommandControlID nie jest prawidłowym identyfikatorem wspólnego CTaskDialog przycisku lub kontrolki przycisku polecenia, ta metoda zgłasza wyjątek.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::IsRadioButtonEnabled

Określa, czy przycisk radiowy jest włączony.

BOOL IsRadioButtonEnabled(int nRadioButtonID) const;

Parametry

nRadioButtonID
[in] Identyfikator przycisku radiowego do przetestowania.

Wartość zwracana

Wartość TRUE, jeśli przycisk radiowy jest włączony, WARTOŚĆ FALSE, jeśli nie.

Uwagi

Jeśli nRadioButtonID nie jest prawidłowym identyfikatorem przycisku radiowego, ta metoda zgłasza wyjątek.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::IsSupported

Określa, czy komputer z uruchomioną aplikacją obsługuje program CTaskDialog.

static BOOL IsSupported();

Wartość zwracana

Wartość TRUE, jeśli komputer obsługuje element CTaskDialog; FAŁSZ w przeciwnym razie.

Uwagi

Ta funkcja służy do określania w czasie wykonywania, czy komputer z uruchomioną aplikacją obsługuje klasę CTaskDialog . Jeśli komputer nie obsługuje CTaskDialogprogramu , należy podać inną metodę przekazywania informacji użytkownikowi. Aplikacja ulegnie awarii, jeśli spróbuje użyć CTaskDialog obiektu na komputerze, który nie obsługuje CTaskDialog klasy .

Przykład

// TODO: Replace the string below with the actual message to the user
CString message("Important information to the user");
// TODO: Replace the string below with the title of this project
CString title("Project Title");

CString emptyString;

if (CTaskDialog::IsSupported())
{
   CTaskDialog::ShowDialog(message, emptyString, title, 0, 0,
                           TDCBF_OK_BUTTON);
}
else
{
   AfxMessageBox(message);
}

CTaskDialog::LoadCommandControls

Dodaje kontrolki przycisku polecenia przy użyciu danych z tabeli ciągów.

void LoadCommandControls(
    int nIDCommandControlsFirst,
    int nIDCommandControlsLast);

Parametry

nIDCommandControlsFirst
[in] Identyfikator ciągu pierwszego polecenia.

nIDCommandControlsLast
[in] Identyfikator ciągu ostatniego polecenia.

Uwagi

Ta metoda tworzy kontrolki przycisku polecenia przy użyciu danych z pliku zasobów aplikacji. Tabela ciągów w pliku zasobu zawiera kilka ciągów ze skojarzonymi identyfikatorami ciągów. Nowe kontrolki przycisku polecenia dodane przy użyciu tej metody używają ciągu dla podpis kontrolki i identyfikatora ciągu dla identyfikatora kontrolki. Wybrany zakres ciągów jest dostarczany przez nIDCommandControlsFirst i nCommandControlsLast, włącznie. Jeśli w zakresie znajduje się pusty wpis, metoda nie dodaje kontrolki przycisku polecenia dla tego wpisu.

Domyślnie nowe kontrolki przycisku polecenia są włączone i nie wymagają podniesienia uprawnień.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::LoadRadioButtons

Dodaje kontrolki przycisku radiowego przy użyciu danych z tabeli ciągów.

void LoadRadioButtons(
    int nIDRadioButtonsFirst,
    int nIDRadioButtonsLast);

Parametry

nIDRadioButtonsFirst
[in] Identyfikator ciągu pierwszego przycisku radiowego.

nIDRadioButtonsLast
[in] Identyfikator ciągu ostatniego przycisku radiowego.

Uwagi

Ta metoda tworzy przyciski radiowe przy użyciu danych z pliku zasobów aplikacji. Tabela ciągów w pliku zasobu zawiera kilka ciągów ze skojarzonymi identyfikatorami ciągów. Nowe przyciski radiowe dodane przy użyciu tej metody używają ciągu dla podpis przycisku radiowego i identyfikatora ciągu identyfikatora przycisku radiowego. Wybrany zakres ciągów jest dostarczany przez nIDRadioButtonsFirst i nRadioButtonsLast, włącznie. Jeśli w zakresie znajduje się pusty wpis, metoda nie dodaje przycisku radiowego dla tego wpisu.

Domyślnie są włączone nowe przyciski radiowe.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

Przenosi fokus na inny CTaskDialogelement .

protected:
void NavigateTo(CTaskDialog& oTaskDialog) const;

Parametry

oTaskDialog
[in] Element CTaskDialog , który otrzymuje fokus.

Uwagi

Ta metoda ukrywa bieżącą wartość CTaskDialog , gdy wyświetla dziennik oTaskDialog. Dziennik oTaskDialog jest wyświetlany w tej samej lokalizacji co bieżący CTaskDialogelement .

CTaskDialog::OnCommandControlClick

Platforma wywołuje tę metodę, gdy użytkownik kliknie kontrolkę przycisku polecenia.

virtual HRESULT OnCommandControlClick(int nCommandControlID);

Parametry

nCommandControlID
[in] Identyfikator kontrolki przycisku polecenia wybranej przez użytkownika.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnCreate

Struktura wywołuje tę metodę po utworzeniu metody CTaskDialog.

virtual HRESULT OnCreate();

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnDestroy

Struktura wywołuje tę metodę bezpośrednio przed zniszczeniem elementu CTaskDialog.

virtual HRESULT OnDestroy();

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnExpandButtonClick

Platforma wywołuje tę metodę, gdy użytkownik kliknie przycisk rozszerzenia.

virtual HRESULT OnExpandButtonClicked(BOOL bExpanded);

Parametry

bExpanded
[in] Wartość niezerowa wskazuje, że są wyświetlane dodatkowe informacje; 0 wskazuje, że dodatkowe informacje są ukryte.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnHelp

Platforma wywołuje tę metodę, gdy użytkownik zażąda pomocy.

virtual HRESULT OnHelp();

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnHyperlinkClick

Struktura wywołuje tę metodę, gdy użytkownik kliknie hiperlink.

virtual HRESULT OnHyperlinkClick(const CString& strHref);

Parametry

strHref
[in] Ciąg reprezentujący hiperlink.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Ta metoda wywołuje metodę ShellExecute przed zwróceniem S_OK.

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnInit

Struktura wywołuje tę metodę po CTaskDialog zainicjowaniu elementu .

virtual HRESULT OnInit();

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnNavigatePage

Struktura wywołuje tę metodę w odpowiedzi na metodę CTaskDialog::NavigateTo .

virtual HRESULT OnNavigatePage();

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnRadioButtonClick

Platforma wywołuje tę metodę, gdy użytkownik wybierze kontrolkę przycisku radiowego.

virtual HRESULT OnRadioButtonClick(int nRadioButtonID);

Parametry

nRadioButtonID
[in] Identyfikator kontrolki przycisku radiowego, którą kliknął użytkownik.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnTimer

Struktura wywołuje tę metodę po wygaśnięciu czasomierza.

virtual HRESULT OnTimer(long lTime);

Parametry

lTime
[in] Czas w milisekundach od momentu utworzenia CTaskDialog lub zresetowania czasomierza.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::OnVerificationCheckboxClick

Struktura wywołuje tę metodę, gdy użytkownik kliknie pole wyboru weryfikacji.

virtual HRESULT OnVerificationCheckboxClick(BOOL bChecked);

Parametry

bChecked
[in] Wartość TRUE wskazuje, że zaznaczono pole wyboru weryfikacji; FAŁSZ wskazuje, że nie jest.

Wartość zwracana

Domyślna implementacja zwraca S_OK.

Uwagi

Zastąp tę metodę w klasie pochodnej, aby zaimplementować zachowanie niestandardowe.

CTaskDialog::RemoveAllCommandControls

Usuwa wszystkie kontrolki przycisku polecenia z elementu CTaskDialog.

void RemoveAllCommandControls();

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::RemoveAllRadioButtons

Usuwa wszystkie przyciski radiowe z elementu CTaskDialog.

void RemoveAllRadioButtons();

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::SetCommandControlOptions

Aktualizacje kontrolkę przycisku polecenia na .CTaskDialog

void SetCommandControlOptions(
    int nCommandControlID,
    BOOL bEnabled,
    BOOL bRequiresElevation = FALSE);

Parametry

nCommandControlID
[in] Identyfikator kontrolki poleceń do zaktualizowania.

bEnabled
[in] Parametr logiczny wskazujący, czy określona kontrolka przycisku polecenia jest włączona lub wyłączona.

bRequiresElevation
[in] Parametr logiczny wskazujący, czy określona kontrolka przycisku polecenia wymaga podniesienia uprawnień.

Uwagi

Użyj tej metody, aby zmienić, czy kontrolka przycisku polecenia jest włączona, czy wymaga podniesienia uprawnień po dodaniu jej do CTaskDialog klasy.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::SetCommonButtonOptions

Aktualizacje podzestaw typowych przycisków, które mają być włączone i wymagają podniesienia uprawnień kontroli dostępu użytkownika.

void SetCommonButtonOptions(
    int nDisabledButtonMask,
    int nElevationButtonMask = 0);

Parametry

nDisabledButtonMask
[in] Maska typowych przycisków do wyłączenia.

nElevationButtonMask
[in] Maska typowych przycisków wymagających podniesienia uprawnień.

Uwagi

Typowe przyciski dostępne dla wystąpienia klasy CTaskDialog można ustawić przy użyciu konstruktora CTaskDialog::CTaskDialog i metody CTaskDialog::SetCommonButtons. CTaskDialog::SetCommonButtonOptions nie obsługuje dodawania nowych typowych przycisków.

Jeśli używasz tej metody, aby wyłączyć lub podnieść poziom wspólnego przycisku, który nie jest dostępny dla tego CTaskDialogobiektu , ta metoda zgłasza wyjątek przy użyciu makra ENSURE .

Ta metoda włącza dowolny przycisk, który jest dostępny dla elementu CTaskDialog , ale nie znajduje się w nDisabledButtonMask, nawet jeśli został wcześniej wyłączony. Ta metoda traktuje podniesienie uprawnień w podobny sposób: rejestruje typowe przyciski jako niewymagające podniesienia uprawnień, jeśli wspólny przycisk jest dostępny, ale nie jest uwzględniony w elemenie nElevationButtonMask.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title);

// Create a button mask.
int buttons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
buttons |= TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;

taskDialog.SetCommonButtons(buttons);

// Disable the close button and make the retry button require
// elevation.
taskDialog.SetCommonButtonOptions(TDCBF_CLOSE_BUTTON,
                                  TDCBF_RETRY_BUTTON);

taskDialog.DoModal();

CTaskDialog::SetCommonButtons

Dodaje typowe przyciski do elementu CTaskDialog.

void SetCommonButtons(
    int nButtonMask,
    int nDisabledButtonMask = 0,
    int nElevationButtonMask = 0);

Parametry

nButtonMask
[in] Maska przycisków do dodania do elementu CTaskDialog.

nDisabledButtonMask
[in] Maska przycisków do wyłączenia.

nElevationButtonMask
[in] Maska przycisków wymagających podniesienia uprawnień.

Uwagi

Nie można wywołać tej metody po utworzeniu okna wyświetlania CTaskDialog dla tego wystąpienia klasy. Jeśli tak, ta metoda zgłasza wyjątek.

Przyciski wskazywane przez element nButtonMask zastępują wszystkie typowe przyciski dodane wcześniej do elementu CTaskDialog. Dostępne są tylko przyciski wskazane w elemecie nButtonMask .

Jeśli nDisabledButtonMask lub nElevationButtonMask zawierają przycisk, który nie znajduje się w nButtonMask, ta metoda zgłasza wyjątek przy użyciu makra ENSURE.

Domyślnie wszystkie typowe przyciski są włączone i nie wymagają podniesienia uprawnień.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title);

// Create a button mask.
int buttons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
buttons |= TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;

taskDialog.SetCommonButtons(buttons);

// Disable the close button and make the retry button require
// elevation.
taskDialog.SetCommonButtonOptions(TDCBF_CLOSE_BUTTON,
                                  TDCBF_RETRY_BUTTON);

taskDialog.DoModal();

CTaskDialog::SetContent

Aktualizacje zawartość obiektu CTaskDialog.

void SetContent(const CString& strContent);

Parametry

strContent
[in] Ciąg do wyświetlenia użytkownikowi.

Uwagi

Zawartość CTaskDialog klasy to tekst wyświetlany użytkownikowi w głównej sekcji okna dialogowego.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetDefaultCommandControl

Określa domyślną kontrolkę przycisku polecenia.

void SetDefaultCommandControl(int nCommandControlID);

Parametry

nCommandControlID
[in] Identyfikator kontrolki przycisku polecenia, która ma być wartością domyślną.

Uwagi

Domyślna kontrolka przycisku polecenia to kontrolka wybrana po CTaskDialog pierwszym wyświetleniu elementu użytkownikowi.

Ta metoda zgłasza wyjątek, jeśli nie może odnaleźć kontrolki przycisku polecenia określonej przez nCommandControlID.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title.
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddCommandControl(201, L"First command button control");
taskDialog.AddCommandControl(202, L"Second command button control");
taskDialog.AddCommandControl(203, L"Third command button control");

// Show the CTaskDialog and remember how the user closed it.
int selection = taskDialog.DoModal();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // command button control.
   break;

case 202:
   // TODO: Place processing here for the second
   // command button control.
   break;

case 203:
   // TODO: Place processing here for the third
   // command button control.
   break;

default:
   break;
}

// Remove all the command controls so that we can use the same task
// dialog with new command button controls.
taskDialog.RemoveAllCommandControls();

taskDialog.AddCommandControl(301,
                             L"New first command button control");
taskDialog.AddCommandControl(302,
                             L"New second command button control should require elevation",
                             TRUE, TRUE);
taskDialog.AddCommandControl(303,
                             L"New third command button control should be disabled");

// Change the default command button control
taskDialog.SetDefaultCommandControl(302);

// Make sure the third option is disabled.
if (taskDialog.IsCommandControlEnabled(303))
{
   taskDialog.SetCommandControlOptions(303, FALSE);
}

taskDialog.DoModal();

switch (taskDialog.GetSelectedCommandControlID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the command button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllCommandControls();
taskDialog.LoadCommandControls(1001, 1005);

CTaskDialog::SetDefaultRadioButton

Określa domyślny przycisk radiowy.

void SetDefaultRadioButton(int nRadioButtonID);

Parametry

nRadioButtonID
[in] Identyfikator przycisku radiowego, który ma być domyślny.

Uwagi

Domyślny przycisk radiowy to przycisk wybrany po CTaskDialog pierwszym wyświetleniu elementu użytkownikowi.

Ta metoda zgłasza wyjątek, jeśli nie może znaleźć przycisku radiowego określonego przez nRadioButtonID.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::SetDialogWidth

Dostosowuje szerokość obiektu CTaskDialog.

void SetDialogWidth(int nWidth = 0);

Parametry

nWidth
[in] Szerokość okna dialogowego w pikselach.

Uwagi

Parametr nWidth musi być większy lub równy 0. W przeciwnym razie ta metoda zgłasza wyjątek.

Jeśli parametr nWidth ma wartość 0, ta metoda ustawia okno dialogowe na domyślny rozmiar.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetExpansionArea

Aktualizacje obszar rozszerzania obiektu CTaskDialog.

void SetExpansionArea(
    const CString& strExpandedInformation,
    const CString& strCollapsedLabel = _T(""),
    const CString& strExpandedLabel = _T(""));

Parametry

strExpandedInformation
[in] Ciąg CTaskDialog wyświetlany w głównej treści okna dialogowego po kliknięciu przycisku rozszerzenia przez użytkownika.

strCollapsedLabel
[in] Ciąg CTaskDialog wyświetlany obok przycisku rozszerzenia po zwinięciu rozwiniętego obszaru.

strExpandedLabel
[in] Ciąg CTaskDialog wyświetlany obok przycisku rozszerzenia po wyświetleniu rozwiniętego obszaru.

Uwagi

Obszar rozszerzania CTaskDialog klasy umożliwia użytkownikowi podanie dodatkowych informacji. Obszar rozszerzania znajduje się w głównej części CTaskDialogobiektu znajdującego się bezpośrednio pod tytułem i ciągiem zawartości.

CTaskDialog Gdy element jest wyświetlany po raz pierwszy, nie wyświetla rozszerzonych informacji i umieszcza strCollapsedLabel go obok przycisku rozszerzenia. Gdy użytkownik kliknie przycisk rozszerzenia, CTaskDialog zostanie wyświetlony ciągExpandedInformation i zmieni etykietę na strExpandedLabel.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetFooterIcon

Aktualizacje ikonę stopki .CTaskDialog

void SetFooterIcon(HICON hFooterIcon);
void SetFooterIcon(LPCWSTR lpszFooterIcon);

Parametry

hFooterIcon
[in] Nowa ikona dla elementu CTaskDialog.

lpszFooterIcon
[in] Nowa ikona dla elementu CTaskDialog.

Uwagi

Ikona stopki jest wyświetlana w dolnej części klasy CTaskDialog. Może zawierać skojarzony tekst stopki. Możesz zmienić tekst stopki na CTaskDialog::SetFooterText.

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli CTaskDialog jest wyświetlany lub parametr wejściowy ma wartość NULL.

Element CTaskDialog może akceptować tylko ikonę HICON stopki lub LPCWSTR jako stopkę. Jest to konfigurowane przez ustawienie opcji TDF_USE_HICON_FOOTER w konstruktorze lub CTaskDialog::SetOptions. Domyślnie parametr CTaskDialog jest skonfigurowany do użycia LPCWSTR jako typ danych wejściowych dla ikony stopki. Ta metoda generuje wyjątek, jeśli spróbujesz ustawić ikonę przy użyciu nieodpowiedniego typu.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetFooterText

Aktualizacje tekst w stopce .CTaskDialog

void SetFooterText(const CString& strFooterText);

Parametry

strFooterText
[in] Nowy tekst stopki.

Uwagi

Ikona stopki jest wyświetlana obok tekstu stopki w dolnej części .CTaskDialog Ikonę stopki można zmienić za pomocą polecenia CTaskDialog::SetFooterIcon.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetMainIcon

Aktualizacje główną ikonę .CTaskDialog

void SetMainIcon(HICON hMainIcon);
void SetMainIcon(LPCWSTR lpszMainIcon);

Parametry

hMainIcon
[in] Nowa ikona.

lpszMainIcon
[in] Nowa ikona.

Uwagi

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli CTaskDialog jest wyświetlany lub parametr wejściowy ma wartość NULL.

Obiekt CTaskDialog może akceptować tylko ikonę HICON lub LPCWSTR jako główną. Można to skonfigurować, ustawiając opcję TDF_USE_HICON_MAIN w konstruktorze lub w metodzie CTaskDialog::SetOptions . Domyślnie parametr CTaskDialog jest skonfigurowany do użycia LPCWSTR jako typ danych wejściowych dla głównej ikony. Ta metoda generuje wyjątek, jeśli spróbujesz ustawić ikonę przy użyciu nieodpowiedniego typu.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetMainInstruction

Aktualizacje głównej instrukcji .CTaskDialog

void SetMainInstruction(const CString& strInstructions);

Parametry

strInstructions
[in] Nowa instrukcja główna.

Uwagi

Główną instrukcją CTaskDialog klasy jest tekst wyświetlany użytkownikowi w dużej czcionki pogrubionej. Znajduje się on w oknie dialogowym pod paskiem tytułu.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetOptions

Konfiguruje opcje dla elementu CTaskDialog.

void SetOptions(int nOptionFlag);

Parametry

nOptionFlag
[in] Zestaw flag do użycia dla elementu CTaskDialog.

Uwagi

Ta metoda czyści wszystkie bieżące opcje dla elementu CTaskDialog. Aby zachować bieżące opcje, musisz najpierw pobrać je z CTaskDialog::GetOptions i połączyć je z opcjami, które chcesz ustawić.

W poniższej tabeli wymieniono wszystkie prawidłowe opcje.

Nazwa/nazwisko opis
TDF_ENABLE_HYPERLINKS Włącza hiperlinki w obiekcie CTaskDialog.
TDF_USE_HICON_MAIN Konfiguruje element CTaskDialog , aby używać HICON elementu dla ikony głównej. Alternatywą jest użycie .LPCWSTR
TDF_USE_HICON_FOOTER Konfiguruje element CTaskDialog , aby używać HICON elementu dla ikony stopki. Alternatywą jest użycie .LPCWSTR
TDF_ALLOW_DIALOG_CANCELLATION Umożliwia użytkownikowi zamknięcie CTaskDialog obiektu za pomocą klawiatury lub użycie ikony w prawym górnym rogu okna dialogowego, nawet jeśli przycisk Anuluj nie jest włączony. Jeśli ta flaga nie jest ustawiona i przycisk Anuluj nie jest włączony, użytkownik nie może zamknąć okna dialogowego przy użyciu klawisza Alt+F4, klawisza Escape lub przycisku zamknięcia paska tytułu.
TDF_USE_COMMAND_LINKS Konfiguruje kontrolki CTaskDialog przycisków poleceń do używania.
TDF_USE_COMMAND_LINKS_NO_ICON Konfiguruje kontrolki CTaskDialog przycisków poleceń do używania bez wyświetlania ikony obok kontrolki. TDF_USE_COMMAND_LINKS przesłania TDF_USE_COMMAND_LINKS_NO_ICON.
TDF_EXPAND_FOOTER_AREA Wskazuje, że obszar rozszerzania jest obecnie rozszerzony.
TDF_EXPANDED_BY_DEFAULT Określa, czy obszar rozszerzania jest domyślnie rozszerzany.
TDF_VERIFICATION_FLAG_CHECKED Wskazuje, że pole wyboru weryfikacji jest obecnie zaznaczone.
TDF_SHOW_PROGRESS_BAR Konfiguruje element , CTaskDialog aby wyświetlić pasek postępu.
TDF_SHOW_MARQUEE_PROGRESS_BAR Konfiguruje pasek postępu jako pasek postępu markizy. Jeśli włączysz tę opcję, musisz ustawić TDF_SHOW_PROGRESS_BAR na oczekiwane zachowanie.
TDF_CALLBACK_TIMER Wskazuje, że CTaskDialog interwał wywołania zwrotnego jest ustawiony na około 200 milisekund.
TDF_POSITION_RELATIVE_TO_WINDOW Konfiguruje element do wyśrodkowania CTaskDialog względem okna nadrzędnego. Jeśli ta flaga nie jest włączona, CTaskDialog element jest wyśrodkowany względem monitora.
TDF_RTL_LAYOUT Konfiguruje dla CTaskDialog układu odczytu od prawej do lewej.
TDF_NO_DEFAULT_RADIO_BUTTON Wskazuje, że po wyświetleniu przycisku radiowego nie wybrano przycisku radiowego CTaskDialog .
TDF_CAN_BE_MINIMIZED Umożliwia użytkownikowi zminimalizowanie liczby .CTaskDialog Aby obsłużyć tę opcję, CTaskDialog nie może być modalny. MFC nie obsługuje tej opcji, ponieważ MFC nie obsługuje moderowania CTaskDialog.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::SetProgressBarMarquee

Konfiguruje pasek markizy dla elementu CTaskDialog i dodaje go do okna dialogowego.

void SetProgressBarMarquee(
    BOOL bEnabled = TRUE,
    int nMarqueeSpeed = 0);

Parametry

bEnabled
[in] WARTOŚĆ TRUE, aby włączyć pasek markizy; FAŁSZ, aby wyłączyć pasek markizy i usunąć go z elementu CTaskDialog.

nMarqueeSpeed
[in] Liczba całkowita wskazująca szybkość paska markizy.

Uwagi

Pasek markizy jest wyświetlany pod głównym tekstem CTaskDialog klasy.

Użyj parametru nMarqueeSpeed , aby ustawić szybkość paska markizy; większe wartości wskazują wolniejszą szybkość. Wartość 0 dla nMarqueeSpeed sprawia, że pasek markizy porusza się z domyślną prędkością dla systemu Windows.

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli nMarqueeSpeed jest mniejsza niż 0.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add a marquee progress bar.
taskDialog.SetProgressBarMarquee();

taskDialog.DoModal();

// Remove the marquee bar and replace it with a standard progress bar
taskDialog.SetProgressBarMarquee(0);
taskDialog.SetProgressBarRange(0, 100);
taskDialog.SetProgressBarPosition(75);
taskDialog.SetProgressBarState();

taskDialog.DoModal();

CTaskDialog::SetProgressBarPosition

Dostosowuje położenie paska postępu.

void SetProgressBarPosition(int nProgressPos);

Parametry

nProgressPos
[in] Pozycja paska postępu.

Uwagi

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli nProgressPos nie znajduje się w zakresie paska postępu. Zakres paska postępu można zmienić za pomocą polecenia CTaskDialog::SetProgressBarRange.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add a marquee progress bar.
taskDialog.SetProgressBarMarquee();

taskDialog.DoModal();

// Remove the marquee bar and replace it with a standard progress bar
taskDialog.SetProgressBarMarquee(0);
taskDialog.SetProgressBarRange(0, 100);
taskDialog.SetProgressBarPosition(75);
taskDialog.SetProgressBarState();

taskDialog.DoModal();

CTaskDialog::SetProgressBarRange

Dostosowuje zakres paska postępu.

void SetProgressBarRange(
    int nRangeMin,
    int nRangeMax);

Parametry

nRangeMin
[in] Dolna granica paska postępu.

nRangeMax
[in] Górna granica paska postępu.

Uwagi

Położenie paska postępu jest względem nRangeMin i nRangeMax. Jeśli na przykład nRangeMin ma wartość 50, a nRangeMax ma wartość 100, pozycja 75 jest w połowie pasa postępu. Użyj CTaskDialog::SetProgressBarPosition , aby ustawić położenie paska postępu.

Aby wyświetlić pasek postępu, opcja TDF_SHOW_PROGRESS_BAR musi być włączona i TDF_SHOW_MARQUEE_PROGRESS_BAR nie może być włączona. Ta metoda automatycznie ustawia TDF_SHOW_PROGRESS_BAR i czyści TDF_SHOW_MARQUEE_PROGRESS_BAR. Użyj CTaskDialog::SetOptions , aby ręcznie zmienić opcje dla tego wystąpienia klasy CTaskDialog.

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli nRangeMin nie jest mniejsza niż nRangeMax. Ta metoda zgłasza również wyjątek, jeśli CTaskDialog element jest już wyświetlany i ma pasek postępu markizy.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add a marquee progress bar.
taskDialog.SetProgressBarMarquee();

taskDialog.DoModal();

// Remove the marquee bar and replace it with a standard progress bar
taskDialog.SetProgressBarMarquee(0);
taskDialog.SetProgressBarRange(0, 100);
taskDialog.SetProgressBarPosition(75);
taskDialog.SetProgressBarState();

taskDialog.DoModal();

CTaskDialog::SetProgressBarState

Ustawia stan paska postępu i wyświetla go na CTaskDialog.

void SetProgressBarState(int nState = PBST_NORMAL);

Parametry

nState
[in] Stan paska postępu. Zobacz sekcję Uwagi, aby zapoznać się z możliwymi wartościami.

Uwagi

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli CTaskDialog jest już wyświetlany i ma pasek postępu markizy.

W poniższej tabeli wymieniono możliwe wartości dla nState. We wszystkich tych przypadkach pasek postępu będzie wypełniany zwykłym kolorem, dopóki nie osiągnie wyznaczonej pozycji zatrzymania. W tym momencie zmieni kolor na podstawie stanu.

Nazwa/nazwisko opis
PBST_NORMAL Po wypełnieniu CTaskDialog paska postępu kolor paska nie zmienia się. Domyślnie zwykły kolor jest zielony.
PBST_ERROR Po wypełnieniu CTaskDialog paska postępu zmienia kolor paska na kolor błędu. Domyślnie jest to czerwony.
PBST_PAUSED Po wypełnieniu CTaskDialog paska postępu zmienia kolor paska na wstrzymany kolor. Domyślnie jest to żółty.

Możesz ustawić, gdzie pasek postępu zatrzymuje się za pomocą polecenia CTaskDialog::SetProgressBarPosition.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add a marquee progress bar.
taskDialog.SetProgressBarMarquee();

taskDialog.DoModal();

// Remove the marquee bar and replace it with a standard progress bar
taskDialog.SetProgressBarMarquee(0);
taskDialog.SetProgressBarRange(0, 100);
taskDialog.SetProgressBarPosition(75);
taskDialog.SetProgressBarState();

taskDialog.DoModal();

CTaskDialog::SetRadioButtonOptions

Włącza lub wyłącza przycisk radiowy.

void SetRadioButtonOptions(
    int nRadioButtonID,
    BOOL bEnabled);

Parametry

nRadioButtonID
[in] Identyfikator kontrolki przycisku radiowego.

bEnabled
[in] WARTOŚĆ TRUE, aby włączyć przycisk radiowy; FAŁSZ, aby wyłączyć przycisk radiowy.

Uwagi

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli nRadioButtonID nie jest prawidłowym identyfikatorem przycisku radiowego.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

taskDialog.AddRadioButton(201, L"First option");
taskDialog.AddRadioButton(202, L"Second option");
taskDialog.AddRadioButton(203, L"Third option");

taskDialog.DoModal();
int selection = taskDialog.GetSelectedRadioButtonID();

switch (selection)
{
case 201:
   // TODO: Place processing here for the first
   // radio button.
   break;

case 202:
   // TODO: Place processing here for the second
   // radio button.
   break;

case 203:
   // TODO: Place processing here for the third
   // radio button.
   break;

default:
   break;
}

// Remove all the radio buttons so that we can use the same task
// dialog with new radio buttons.
taskDialog.RemoveAllRadioButtons();

taskDialog.AddRadioButton(301, L"New first option");
taskDialog.AddRadioButton(302, L"New second option");
taskDialog.AddRadioButton(303,
                          L"New third option should be disabled");

// Change the default radio button to the second option
taskDialog.SetDefaultRadioButton(302);

// Make sure the third option is disabled.
if (taskDialog.IsRadioButtonEnabled(303))
{
   taskDialog.SetRadioButtonOptions(303, FALSE);
}

taskDialog.DoModal();
selection = taskDialog.GetSelectedRadioButtonID();

switch (taskDialog.GetSelectedRadioButtonID())
{
case 301:
   // TODO: Place processing here for new first
   // command button control.
   break;

case 302:
   // TODO: Place processing here for new second
   // command button control.
   break;

case 303:
   // TODO: Place processing here for the new third
   // command button control.
   break;

default:
   break;
}

// Remove all the radio button controls and add new ones from
// the string table resource.
taskDialog.RemoveAllRadioButtons();
taskDialog.LoadRadioButtons(1001, 1005);

CTaskDialog::SetVerificationCheckbox

Ustawia sprawdzony stan pola wyboru weryfikacji.

void SetVerificationCheckbox(BOOL bChecked);

Parametry

bChecked
[in] Wartość TRUE, aby pole wyboru weryfikacji było zaznaczone po wyświetleniu CTaskDialog elementu ; FAŁSZ, aby pole wyboru weryfikacji było niezaznaczone po wyświetleniu CTaskDialog .

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add the verification checkbox and set the default state.
taskDialog.SetVerificationCheckboxText(L"Remember your selection.");
taskDialog.SetVerificationCheckbox(false);

taskDialog.DoModal();

if (taskDialog.GetVerificationCheckboxState())
{
   // TODO: Write settings of the task dialog to the registry
}

CTaskDialog::SetVerificationCheckboxText

Ustawia tekst wyświetlany po prawej stronie pola wyboru weryfikacji.

void SetVerificationCheckboxText(CString& strVerificationText);

Parametry

strVerificationText
[in] Tekst wyświetlany przez tę metodę obok pola wyboru weryfikacji.

Uwagi

Ta metoda zgłasza wyjątek z makrem ENSURE , jeśli to wystąpienie CTaskDialog klasy jest już wyświetlane.

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Add the verification checkbox and set the default state.
taskDialog.SetVerificationCheckboxText(L"Remember your selection.");
taskDialog.SetVerificationCheckbox(false);

taskDialog.DoModal();

if (taskDialog.GetVerificationCheckboxState())
{
   // TODO: Write settings of the task dialog to the registry
}

CTaskDialog::SetWindowTitle

Ustawia tytuł .CTaskDialog

void SetWindowTitle(CString& strWindowTitle);

Parametry

strWindowTitle
[in] Nowy tytuł dla elementu CTaskDialog.

Uwagi

Przykład

// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");

CTaskDialog taskDialog(message, mainInstruction, title,
                       TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);

// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);

// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);

// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
                            L"Click here for more information.",
                            L"Click here to hide the extra information.");

// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);

taskDialog.DoModal();

CTaskDialog::ShowDialog

Tworzy i wyświetla element CTaskDialog.

static INT_PTR ShowDialog(
    const CString& strContent,
    const CString& strMainInstruction,
    const CString& strTitle,
    int nIDCommandControlsFirst,
    int nIDCommandControlsLast,
    int nCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON,
    int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
    const CString& strFooter = _T(""));

Parametry

strContent
[in] Ciąg do użycia dla zawartości elementu CTaskDialog.

strMainInstruction
[in] Główna instrukcja obiektu CTaskDialog.

strTitle
[in] Tytuł .CTaskDialog

nIDCommandControlsFirst
[in] Identyfikator ciągu pierwszego polecenia.

nIDCommandControlsLast
[in] Identyfikator ciągu ostatniego polecenia.

nCommonButtons
[in] Maska przycisków do dodania do elementu CTaskDialog.

nTaskDialogOptions
[in] Zestaw opcji do użycia dla elementu CTaskDialog.

strFooter
[in] Ciąg do użycia jako stopka.

Wartość zwracana

Liczba całkowita odpowiadająca zaznaczeniu dokonanemu przez użytkownika.

Uwagi

Ta metoda statyczna umożliwia utworzenie wystąpienia CTaskDialog klasy bez jawnego utworzenia CTaskDialog obiektu w kodzie. Ponieważ nie CTaskDialog ma obiektu, nie można wywołać żadnych innych metod metody CTaskDialog , jeśli używasz tej metody, aby pokazać CTaskDialog użytkownikowi wartość .

Ta metoda tworzy kontrolki przycisku polecenia przy użyciu danych z pliku zasobów aplikacji. Tabela ciągów w pliku zasobu zawiera kilka ciągów ze skojarzonymi identyfikatorami ciągów. Ta metoda dodaje kontrolkę przycisku polecenia dla każdego prawidłowego wpisu w tabeli ciągów między nIDCommandControlsFirst i nCommandControlsLast, włącznie. W przypadku tych kontrolek przycisku polecenia ciąg w tabeli ciągów jest podpis kontrolki, a identyfikator ciągu jest identyfikatorem kontrolki.

Aby uzyskać listę prawidłowych opcji, zobacz CTaskDialog::SetOptions .

Polecenie CTaskDialog zostanie zamknięte, gdy użytkownik wybierze wspólny przycisk, kontrolkę linku polecenia lub zamknie CTaskDialogelement . Wartość zwracana jest identyfikatorem wskazującym sposób zamknięcia okna dialogowego przez użytkownika.

Przykład

// TODO: Replace the string below with the actual message to the user
CString message("Important information to the user");
// TODO: Replace the string below with the title of this project
CString title("Project Title");

CString emptyString;

if (CTaskDialog::IsSupported())
{
   CTaskDialog::ShowDialog(message, emptyString, title, 0, 0,
                           TDCBF_OK_BUTTON);
}
else
{
   AfxMessageBox(message);
}

CTaskDialog::TaskDialogCallback

Struktura wywołuje tę metodę w odpowiedzi na różne komunikaty systemu Windows.

friend:
HRESULT TaskDialogCallback(
    HWND hWnd,
    UINT uNotification,
    WPARAM wParam,
    LPARAM lParam,
    LONG_PTR dwRefData);

Parametry

Hwnd
[in] Uchwyt do m_hWnd struktury dla elementu CTaskDialog.

uNotification
[in] Kod powiadomienia określający wygenerowany komunikat.

Wparam
[in] Więcej informacji o wiadomości.

Lparam
[in] Więcej informacji o wiadomości.

dwRefData
[in] Wskaźnik do CTaskDialog obiektu, do którego ma zastosowanie komunikat wywołania zwrotnego.

Wartość zwracana

Zależy od określonego kodu powiadomienia. Zobacz sekcję Spostrzeżenia, aby uzyskać więcej informacji.

Uwagi

Domyślna implementacja TaskDialogCallback obsługuje określony komunikat, a następnie wywołuje odpowiednią metodę On klasy CTaskDialog. Na przykład w odpowiedzi na komunikat TaskDialogCallback TDN_BUTTON_CLICKED wywołuje polecenie CTaskDialog::OnCommandControlClick.

Wartości parametrów wParam i lParam zależą od określonego wygenerowanego komunikatu. Możliwe, że obie z tych wartości będą puste. W poniższej tabeli wymieniono domyślne powiadomienia, które są obsługiwane, oraz wartości funkcji wParam i lParam . Jeśli zastąpisz tę metodę w klasie pochodnej, należy zaimplementować kod wywołania zwrotnego dla każdego komunikatu w poniższej tabeli.

Wiadomość z powiadomieniem wartość wParam wartość lParam
TDN_CREATED Nie używany. Nie używany.
TDN_NAVIGATED Nie używany. Nie używany.
TDN_BUTTON_CLICKED Identyfikator kontrolki przycisku polecenia. Nie używany.
TDN_HYPERLINK_CLICKED Nie używany. Struktura LPCWSTR zawierająca łącze.
TDN_TIMER Czas w milisekundach od momentu utworzenia CTaskDialog lub zresetowania czasomierza. Nie używany.
TDN_DESTROYED Nie używany. Nie używany.
TDN_RADIO_BUTTON_CLICKED Identyfikator przycisku radiowego. Nie używany.
TDN_DIALOG_CONSTRUCTED Nie używany. Nie używany.
TDN_VERIFICATION_CLICKED 1 jeśli pole wyboru jest zaznaczone, 0, jeśli nie. Nie używany.
TDN_HELP Nie używany. Nie używany.
TDN_EXPANDO_BUTTON_CLICKED 0, jeśli obszar rozszerzania jest zwinięty; niezerowe, jeśli zostanie wyświetlony tekst rozszerzenia. Nie używany.

Zobacz też

Klasy
Klasa CObject
Wykres hierarchii
Przewodnik: dodawanie obiektu CTaskDialog do aplikacji