CTaskDialog-Klasse

Ein Popupdialogfeld, das wie ein Meldungsfeld funktioniert, aber zusätzliche Informationen für den Benutzer anzeigen kann. CTaskDialog enthält auch Funktionen zum Erfassen von Informationen des Benutzers.

Syntax

class CTaskDialog : public CObject

Member

Konstruktoren

Name Beschreibung
CTaskDialog::CTaskDialog Erstellt ein CTaskDialog-Objekt.

Methoden

Name Beschreibung
CTaskDialog::AddCommandControl Fügt der CTaskDialogBefehlsschaltfläche ein Steuerelement hinzu.
CTaskDialog::AddRadioButton Fügt der CTaskDialogSchaltfläche ein Optionsfeld hinzu.
CTaskDialog::ClickCommandControl Klickt programmgesteuert auf ein Befehlsschaltflächen-Steuerelement oder eine allgemeine Schaltfläche.
CTaskDialog::ClickRadioButton Klickt programmgesteuert auf ein Optionsfeld.
CTaskDialog::D oModal Zeigt das CTaskDialog an.
CTaskDialog::GetCommonButtonCount Ruft die Anzahl der verfügbaren allgemeinen Schaltflächen ab.
CTaskDialog::GetCommonButtonFlag Konvertiert eine Windows-Standardschaltfläche in den allgemeinen Schaltflächentyp, der der CTaskDialog Klasse zugeordnet ist.
CTaskDialog::GetCommonButtonId Konvertiert einen der allgemeinen Schaltflächentypen, die der CTaskDialog Klasse zugeordnet sind, in eine Windows-Standardschaltfläche.
CTaskDialog::GetOptions Gibt die Optionskennzeichnungen für diesen CTaskDialogWert zurück.
CTaskDialog::GetSelectedCommandControlID Gibt das ausgewählte Befehlsschaltflächen-Steuerelement zurück.
CTaskDialog::GetSelectedRadioButtonID Gibt das ausgewählte Optionsfeld zurück.
CTaskDialog::GetVerificationCheckboxState Ruft den Status des Überprüfungskontrollkästchens ab.
CTaskDialog::IsCommandControlEnabled Bestimmt, ob ein Befehlsschaltflächen-Steuerelement oder eine allgemeine Schaltfläche aktiviert ist.
CTaskDialog::IsRadioButtonEnabled Bestimmt, ob ein Optionsfeld aktiviert ist.
CTaskDialog::IsSupported Bestimmt, ob der Computer, auf dem die Anwendung ausgeführt wird, die CTaskDialog.
CTaskDialog::LoadCommandControls Fügt Befehlsschaltflächensteuerelemente mithilfe von Daten aus der Zeichenfolgentabelle hinzu.
CTaskDialog::LoadRadioButtons Fügt Optionsfelder mithilfe von Daten aus der Zeichenfolgentabelle hinzu.
CTaskDialog::NavigateTo Überträgt den Fokus auf eine andere CTaskDialog.
CTaskDialog::OnCommandControlClick Das Framework ruft diese Methode auf, wenn der Benutzer auf ein Befehlsschaltflächen-Steuerelement klickt.
CTaskDialog::OnCreate Das Framework ruft diese Methode auf, nachdem sie die CTaskDialog.
CTaskDialog::OnDestroy Das Framework ruft diese Methode unmittelbar auf, bevor sie die CTaskDialog.
CTaskDialog::OnExpandButtonClick Das Framework ruft diese Methode auf, wenn der Benutzer auf die Erweiterungsschaltfläche klickt.
CTaskDialog::OnHelp Das Framework ruft diese Methode auf, wenn der Benutzer Hilfe anfordert.
CTaskDialog::OnHyperlinkClick Das Framework ruft diese Methode auf, wenn der Benutzer auf einen Link klickt.
CTaskDialog::OnInit Das Framework ruft diese Methode beim Initialisieren auf CTaskDialog .
CTaskDialog::OnNavigatePage Das Framework ruft diese Methode auf, wenn der Benutzer den Fokus in Bezug auf Steuerelemente auf dem CTaskDialog.
CTaskDialog::OnRadioButtonClick Das Framework ruft diese Methode auf, wenn der Benutzer ein Optionsfeld-Steuerelement auswählt.
CTaskDialog::OnTimer Das Framework ruft diese Methode auf, wenn der Timer abläuft.
CTaskDialog::OnVerificationCheckboxClick Das Framework ruft diese Methode auf, wenn der Benutzer auf das Überprüfungskontrollkästchen klickt.
CTaskDialog::RemoveAllCommandControls Entfernt alle Befehlssteuerelemente aus dem CTaskDialog.
CTaskDialog::RemoveAllRadioButtons Entfernt alle Optionsfelder aus dem CTaskDialog.
CTaskDialog::SetCommandControlOptions Aktualisiert ein Befehlsschaltflächen-Steuerelement auf der CTaskDialog.
CTaskDialog::SetCommonButtonOptions Aktualisiert eine Teilmenge allgemeiner Schaltflächen, die aktiviert werden sollen, und erfordert UAC-Rechteerweiterungen.
CTaskDialog::SetCommonButtons Fügt allgemeine Schaltflächen zu der CTaskDialog.
CTaskDialog::SetContent Aktualisiert den Inhalt der CTaskDialog.
CTaskDialog::SetDefaultCommandControl Gibt das Standardmäßige Befehlsschaltflächen-Steuerelement an.
CTaskDialog::SetDefaultRadioButton Gibt das Standard-Optionsfeld an.
CTaskDialog::SetDialogWidth Passt die Breite der CTaskDialog.
CTaskDialog::SetExpansionArea Aktualisiert den Erweiterungsbereich der CTaskDialog.
CTaskDialog::SetFooterIcon Aktualisiert das Fußzeilensymbol für das CTaskDialog.
CTaskDialog::SetFooterText Aktualisiert den Text auf der Fußzeile der CTaskDialog.
CTaskDialog::SetMainIcon Aktualisiert das symbol Standard des .CTaskDialog
CTaskDialog::SetMainInstruction Aktualisiert die Standard Anweisung der CTaskDialog.
CTaskDialog::SetOptions Konfiguriert die Optionen für die CTaskDialog.
CTaskDialog::SetProgressBarMarquee Konfiguriert eine Balkenleiste für das CTaskDialog Dialogfeld und fügt sie dem Dialogfeld hinzu.
CTaskDialog::SetProgressBarPosition Passt die Position der Statusanzeige an.
CTaskDialog::SetProgressBarRange Passt den Bereich der Statusanzeige an.
CTaskDialog::SetProgressBarState Legt den Status der Statusanzeige fest und zeigt ihn auf der CTaskDialog.
CTaskDialog::SetRadioButtonOptions Aktiviert oder deaktiviert ein Optionsfeld.
CTaskDialog::SetVerificationCheckbox Legt den aktivierten Status des Überprüfungskontrollkästchens fest.
CTaskDialog::SetVerificationCheckboxText Legt den Text auf der rechten Seite des Überprüfungskontrollkästchens fest.
CTaskDialog::SetWindowTitle Legt den Titel des CTaskDialog.
CTaskDialog::ShowDialog Erstellt und zeigt eine CTaskDialog.
CTaskDialog::TaskDialogCallback Das Framework ruft dies als Reaktion auf verschiedene Windows-Nachrichten auf.

Datenelemente

Name Beschreibung
m_aButtons Das Array der Befehlsschaltflächen-Steuerelemente für die CTaskDialog.
m_aRadioButtons Das Array von Optionsfeld-Steuerelementen für die CTaskDialog.
m_bVerified TRUE gibt an, dass das Überprüfungskontrollkästchen aktiviert ist; FALSE gibt an, dass es nicht ist.
m_footerIcon Das Symbol in der Fußzeile der CTaskDialog.
m_hWnd Ein Ziehpunkt für das Fenster für das CTaskDialog.
m_mainIcon Das symbol Standard des .CTaskDialog
m_nButtonDisabled Eine Maske, die angibt, welche der allgemeinen Schaltflächen deaktiviert sind.
m_nButtonElevation Eine Maske, die angibt, welche der allgemeinen Schaltflächen UAC-Rechteerweiterung erfordern.
m_nButtonId Die ID des ausgewählten Befehlsschaltflächen-Steuerelements.
m_nCommonButton Eine Maske, die angibt, welche allgemeinen Schaltflächen auf der CTaskDialogSchaltfläche angezeigt werden.
m_nDefaultCommandControl Die ID des Befehlsschaltflächen-Steuerelements, das beim CTaskDialog Anzeigen ausgewählt wird.
m_nDefaultRadioButton Die ID des Optionsfeld-Steuerelements, das beim CTaskDialog Anzeigen ausgewählt wird.
m_nFlags Eine Maske, die die Optionen für die CTaskDialog.
m_nProgressPos Die aktuelle Position für die Statusanzeige. Dabei muss es sich um einen Wert zwischen m_nProgressRangeMin und m_nProgressRangeMax handeln.
m_nProgressRangeMax Der Maximalwert für die Statusanzeige.
m_nProgressRangeMin Der Mindestwert für die Statusanzeige.
m_nProgressState Der Zustand der Statusanzeige. Weitere Informationen finden Sie unter "CTaskDialog::SetProgressBarState".
m_nRadioId Die ID des ausgewählten Optionsfeld-Steuerelements.
m_nWidth Die Breite der CTaskDialog Pixel.
m_strCollapse Die Zeichenfolge, CTaskDialog die rechts neben dem Erweiterungsfeld angezeigt wird, wenn die erweiterten Informationen ausgeblendet sind.
m_strContent Die Inhaltszeichenfolge der CTaskDialog.
m_strExpand Die Zeichenfolge, CTaskDialog die rechts neben dem Erweiterungsfeld angezeigt wird, wenn die erweiterten Informationen angezeigt werden.
m_strFooter Die Fußzeile der CTaskDialog.
m_strInformation Die erweiterten Informationen für die CTaskDialog.
m_strMainInstruction Die Standard Anweisung der CTaskDialog.
m_strTitle Der Titel des CTaskDialog.
m_strVerification Die Zeichenfolge, CTaskDialog die rechts neben dem Überprüfungskontrollkästchen angezeigt wird.

Hinweise

Die CTaskDialog Klasse ersetzt das Standardmäßige Windows-Meldungsfeld und verfügt über zusätzliche Funktionen wie neue Steuerelemente, um Informationen vom Benutzer zu sammeln. Diese Klasse befindet sich in der MFC-Bibliothek in Visual Studio 2010 und höher. Das CTaskDialog ist ab Windows Vista verfügbar. Frühere Versionen von Windows können das CTaskDialog Objekt nicht anzeigen. Hiermit bestimmen Sie CTaskDialog::IsSupported zur Laufzeit, ob der aktuelle Benutzer das Aufgabendialogfeld anzeigen kann. Das Standardmäßige Windows-Meldungsfeld wird weiterhin unterstützt.

Dies CTaskDialog ist nur verfügbar, wenn Sie Ihre Anwendung mithilfe der Unicode-Bibliothek erstellen.

Dies CTaskDialog hat zwei verschiedene Konstruktoren. Mit einem Konstruktor können Sie zwei Befehlsschaltflächen und maximal sechs reguläre Schaltflächensteuerelemente angeben. Sie können nach dem Erstellen der CTaskDialogSchaltflächen weitere Befehlsschaltflächen hinzufügen. Der zweite Konstruktor unterstützt keine Befehlsschaltflächen, Sie können jedoch eine unbegrenzte Anzahl regulärer Schaltflächensteuerelemente hinzufügen. Weitere Informationen zu den Konstruktoren finden Sie unter "CTaskDialog::CTaskDialog".

Die folgende Abbildung zeigt ein Beispiel CTaskDialog , um die Position einiger Steuerelemente zu veranschaulichen.

Example of CTaskDialog.
CTaskDialog-Beispiel

Anforderungen

Mindestens erforderliches Betriebssystem: Windows Vista

Kopfzeile: afxtaskdialog.h

CTaskDialog::AddCommandControl

Fügt der Schaltfläche ein neues Befehlsschaltflächen-Steuerelement hinzu CTaskDialog.

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

Parameter

nCommandControlID
[in] Die Identifikationsnummer des Befehlssteuerelements.

strCaption
[in] Die Zeichenfolge, die CTaskDialog dem Benutzer angezeigt wird. Verwenden Sie diese Zeichenfolge, um den Zweck des Befehls zu erläutern.

bEnabled
[in] Ein boolescher Parameter, der angibt, ob die neue Schaltfläche aktiviert oder deaktiviert ist.

bRequiresElevation
[in] Ein boolescher Parameter, der angibt, ob ein Befehl eine Rechteerweiterung erfordert.

Hinweise

Dies CTaskDialog Class kann eine unbegrenzte Anzahl von Befehlsschaltflächensteuerelementen anzeigen. Wenn ein CTaskDialog Befehlsschaltflächen-Steuerelement angezeigt wird, kann es jedoch maximal sechs Schaltflächen anzeigen. Wenn keine CTaskDialog Befehlsschaltflächensteuerelemente vorhanden sind, kann eine unbegrenzte Anzahl von Schaltflächen angezeigt werden.

Wenn der Benutzer ein Befehlsschaltflächen-Steuerelement auswählt, wird der CTaskDialog Befehl geschlossen. Wenn ihre Anwendung das Dialogfeld mithilfe von CTaskDialog::D oModal anzeigt, DoModal wird die nCommandControlID des ausgewählten Befehlsschaltflächen-Steuerelements zurückgegeben.

Beispiel

// 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

Fügt der CTaskDialogSchaltfläche ein Optionsfeld hinzu.

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

Parameter

nRadioButtonID
[in] Die Identifikationsnummer des Optionsfelds.

strCaption
[in] Die Zeichenfolge, die CTaskDialog neben dem Optionsfeld angezeigt wird.

bEnabled
[in] Ein boolescher Parameter, der angibt, ob das Optionsfeld aktiviert ist.

Hinweise

Mit den Optionsfeldern für die CTaskDialog-Klasse können Sie Informationen vom Benutzer sammeln. Verwenden Sie die Funktion CTaskDialog::GetSelectedRadioButtonID , um zu bestimmen, welches Optionsfeld ausgewählt ist.

Dies CTaskDialog erfordert nicht, dass die nRadioButtonID-Parameter für jedes Optionsfeld eindeutig sind. Es kann jedoch zu unerwartetem Verhalten führen, wenn Sie für jedes Optionsfeld keinen eindeutigen Bezeichner verwenden.

Beispiel

// 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

Klickt programmgesteuert auf ein Befehlsschaltflächen-Steuerelement oder eine allgemeine Schaltfläche.

protected:
void ClickCommandControl(int nCommandControlID) const;

Parameter

nCommandControlID
[in] Die Befehls-ID des zu klickenden Steuerelements.

Hinweise

Diese Methode generiert die Windows-Meldung TDM_CLICK_BUTTON.

CTaskDialog::ClickRadioButton

Klickt programmgesteuert auf ein Optionsfeld.

protected:
void ClickRadioButton(int nRadioButtonID) const;

Parameter

nRadioButtonID
[in] Die ID des zu klickenden Optionsfelds.

Hinweise

Diese Methode generiert die Windows-Meldung TDM_CLICK_RADIO_BUTTON.

CTaskDialog::CTaskDialog

Erstellt eine Instanz der CTaskDialog-Klasse.

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(""));

Parameter

strContent
[in] Die für den Inhalt der CTaskDialogZeichenfolge zu verwendende Zeichenfolge.

strMainInstruction
[in] Die Standard Anweisung der CTaskDialog.

strTitle
[in] Der Titel des CTaskDialog.

nCommonButtons
[in] Eine Maske der allgemeinen Schaltflächen, die CTaskDialogdem Steuerelement hinzugefügt werden sollen.

nTaskDialogOptions
[in] Die Gruppe der optionen, die für die CTaskDialog.

strFooter
[in] Die Zeichenfolge, die als Fußzeile verwendet werden soll.

nIDCommandControlsFirst
[in] Die Zeichenfolgen-ID des ersten Befehls.

nIDCommandControlsLast
[in] Die Zeichenfolgen-ID des letzten Befehls.

Hinweise

Es gibt zwei Möglichkeiten, eine Anwendung hinzuzufügen CTaskDialog . Die erste Möglichkeit besteht darin, einen der Konstruktoren zum Erstellen CTaskDialog und Anzeigen mit CTaskDialog::D oModal zu verwenden. Die zweite Möglichkeit besteht darin, die statische Funktion CTaskDialog::ShowDialog zu verwenden, mit der Sie ein CTaskDialog Objekt ohne explizites Erstellen eines CTaskDialog Objekts anzeigen können.

Der zweite Konstruktor erstellt Befehlsschaltflächensteuerelemente mithilfe von Daten aus der Ressourcendatei Ihrer Anwendung. Die Zeichenfolgentabelle in der Ressourcendatei enthält mehrere Zeichenfolgen mit zugeordneten Zeichenfolgen-IDs. Diese Methode fügt ein Befehlsschaltflächen-Steuerelement für jeden gültigen Eintrag in der Zeichenfolgentabelle zwischen nIDCommandControlsFirst und nCommandControlsLast (einschließlich) hinzu. Bei diesen Befehlsschaltflächensteuerelementen ist die Zeichenfolge in der Zeichenfolgentabelle die Untertitel des Steuerelements, und die Zeichenfolgen-ID ist die ID des Steuerelements.

Eine Liste gültiger Optionen finden Sie unter "CTaskDialog::SetOptions ".

Beispiel

// 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

Zeigt das CTaskDialog Element an und macht es modal.

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

Parameter

hParent
[in] Das übergeordnete Fenster für das CTaskDialog.

Rückgabewert

Eine ganze Zahl, die der vom Benutzer getroffenen Auswahl entspricht.

Hinweise

Zeigt diese Instanz des CTaskDialog an. Die Anwendung wartet dann, bis der Benutzer das Dialogfeld schließt.

Wird CTaskDialog geschlossen, wenn der Benutzer eine allgemeine Schaltfläche, ein Befehlslink-Steuerelement oder das Schließt auswählt CTaskDialog. Der Rückgabewert ist der Bezeichner, der angibt, wie der Benutzer das Dialogfeld geschlossen hat.

Beispiel

// 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

Ruft die Anzahl der allgemeinen Schaltflächen ab.

int GetCommonButtonCount() const;

Rückgabewert

Die Anzahl der verfügbaren allgemeinen Schaltflächen.

Hinweise

Die allgemeinen Schaltflächen sind die Standardschaltflächen, die Sie für CTaskDialog::CTaskDialog bereitstellen. Die CTaskDialog-Klasse zeigt die Schaltflächen am unteren Rand des Dialogfelds an.

Die aufgezählte Liste der Schaltflächen wird in CommCtrl.h bereitgestellt.

CTaskDialog::GetCommonButtonFlag

Konvertiert eine Windows-Standardschaltfläche in den allgemeinen Schaltflächentyp, der der CTaskDialog-Klasse zugeordnet ist.

int GetCommonButtonFlag(int nButtonId) const;

Parameter

nButtonId
[in] Der Standardmäßige Windows-Schaltflächenwert.

Rückgabewert

Der Wert der entsprechenden CTaskDialog allgemeinen Schaltfläche. Wenn keine entsprechende allgemeine Schaltfläche vorhanden ist, gibt diese Methode 0 zurück.

CTaskDialog::GetCommonButtonId

Konvertiert einen der allgemeinen Schaltflächentypen, die der CTaskDialog-Klasse zugeordnet sind, in eine Windows-Standardschaltfläche.

int GetCommonButtonId(int nFlag);

Parameter

nFlag
[in] Der allgemeine Schaltflächentyp, der der CTaskDialog Klasse zugeordnet ist.

Rückgabewert

Der Wert der entsprechenden Windows-Standardschaltfläche. Wenn keine entsprechende Windows-Schaltfläche vorhanden ist, gibt die Methode "0" zurück.

CTaskDialog::GetOptions

Gibt die Optionskennzeichnungen für diesen CTaskDialogWert zurück.

int GetOptions() const;

Rückgabewert

Die Kennzeichnungen für die CTaskDialog.

Hinweise

Weitere Informationen zu den optionen, die für die CTaskDialog-Klasse verfügbar sind, finden Sie unter "CTaskDialog::SetOptions".

Beispiel

// 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

Gibt das ausgewählte Befehlsschaltflächen-Steuerelement zurück.

int GetSelectedCommandControlID() const;

Rückgabewert

Die ID des aktuell ausgewählten Befehlsschaltflächen-Steuerelements.

Hinweise

Sie müssen diese Methode nicht verwenden, um die ID der Befehlsschaltfläche abzurufen, die der Benutzer ausgewählt hat. Diese ID wird entweder von CTaskDialog::D oModal oder CTaskDialog::ShowDialog zurückgegeben.

Beispiel

// 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

Gibt das ausgewählte Optionsfeld zurück.

int GetSelectedRadioButtonID() const;

Rückgabewert

Die ID des ausgewählten Optionsfelds.

Hinweise

Sie können diese Methode verwenden, nachdem der Benutzer das Dialogfeld geschlossen hat, um das ausgewählte Optionsfeld abzurufen.

Beispiel

// 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

Ruft den Status des Überprüfungskontrollkästchens ab.

BOOL GetVerificationCheckboxState() const;

Rückgabewert

TRUE, wenn das Kontrollkästchen aktiviert ist, FALSE, wenn das nicht der Fall ist.

Beispiel

// 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

Bestimmt, ob ein Befehlsschaltflächen-Steuerelement oder eine Befehlsschaltfläche aktiviert ist.

BOOL IsCommandControlEnabled(int nCommandControlID) const;

Parameter

nCommandControlID
[in] Die ID des zu testenden Befehlsschaltflächen-Steuerelements oder der Befehlsschaltfläche.

Rückgabewert

TRUE, wenn das Steuerelement aktiviert ist, FALSE, wenn es nicht der Fall ist.

Hinweise

Mit dieser Methode können Sie die Verfügbarkeit von Befehlsschaltflächensteuerelementen und den allgemeinen Schaltflächen der CTaskDialog Klasse* ermitteln.

Wenn nCommandControlID kein gültiger Bezeichner für eine allgemeine CTaskDialog Schaltfläche oder ein Befehlsschaltflächen-Steuerelement ist, löst diese Methode eine Ausnahme aus.

Beispiel

// 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

Bestimmt, ob ein Optionsfeld aktiviert ist.

BOOL IsRadioButtonEnabled(int nRadioButtonID) const;

Parameter

nRadioButtonID
[in] Die ID des zu testenden Optionsfelds.

Rückgabewert

TRUE, wenn das Optionsfeld aktiviert ist, FALSE, wenn dies nicht der Fall ist.

Hinweise

Wenn nRadioButtonID kein gültiger Bezeichner für ein Optionsfeld ist, löst diese Methode eine Ausnahme aus.

Beispiel

// 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

Bestimmt, ob der Computer, auf dem die Anwendung ausgeführt wird, die CTaskDialog.

static BOOL IsSupported();

Rückgabewert

TRUE, wenn der Computer die CTaskDialog; Andernfalls FALSE.

Hinweise

Verwenden Sie diese Funktion, um zur Laufzeit zu ermitteln, ob der Computer, auf dem Ihre Anwendung ausgeführt wird, die CTaskDialog Klasse unterstützt. Wenn der Computer das CTaskDialogNicht unterstützt, sollten Sie eine andere Methode für die Kommunikation von Informationen an den Benutzer bereitstellen. Ihre Anwendung stürzt ab, wenn versucht wird, einen CTaskDialog Computer zu verwenden, der die CTaskDialog Klasse nicht unterstützt.

Beispiel

// 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

Fügt Befehlsschaltflächensteuerelemente mithilfe von Daten aus der Zeichenfolgentabelle hinzu.

void LoadCommandControls(
    int nIDCommandControlsFirst,
    int nIDCommandControlsLast);

Parameter

nIDCommandControlsFirst
[in] Die Zeichenfolgen-ID des ersten Befehls.

nIDCommandControlsLast
[in] Die Zeichenfolgen-ID des letzten Befehls.

Hinweise

Diese Methode erstellt Befehlsschaltflächensteuerelemente mithilfe von Daten aus der Ressourcendatei Ihrer Anwendung. Die Zeichenfolgentabelle in der Ressourcendatei enthält mehrere Zeichenfolgen mit zugeordneten Zeichenfolgen-IDs. Neue Befehlsschaltflächensteuerelemente, die mithilfe dieser Methode hinzugefügt werden, verwenden die Zeichenfolge für die Untertitel des Steuerelements und die Zeichenfolgen-ID für die ID des Steuerelements. Der ausgewählte Zeichenfolgenbereich wird von nIDCommandControlsFirst und nCommandControlsLast (einschließlich) bereitgestellt. Wenn im Bereich ein leerer Eintrag vorhanden ist, fügt die Methode kein Befehlsschaltflächen-Steuerelement für diesen Eintrag hinzu.

Standardmäßig sind neue Befehlsschaltflächen-Steuerelemente aktiviert und erfordern keine Erhöhung.

Beispiel

// 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

Fügt Optionsfeld-Steuerelemente mithilfe von Daten aus der Zeichenfolgentabelle hinzu.

void LoadRadioButtons(
    int nIDRadioButtonsFirst,
    int nIDRadioButtonsLast);

Parameter

nIDRadioButtonsFirst
[in] Die Zeichenfolgen-ID des ersten Optionsfelds.

nIDRadioButtonsLast
[in] Die Zeichenfolgen-ID des letzten Optionsfelds.

Hinweise

Diese Methode erstellt Optionsfelder mithilfe von Daten aus der Ressourcendatei Ihrer Anwendung. Die Zeichenfolgentabelle in der Ressourcendatei enthält mehrere Zeichenfolgen mit zugeordneten Zeichenfolgen-IDs. Neue Optionsfelder, die mithilfe dieser Methode hinzugefügt werden, verwenden die Zeichenfolge für die Untertitel des Optionsfelds und die Zeichenfolgen-ID für die ID des Optionsfelds. Der ausgewählte Zeichenfolgenbereich wird von nIDRadioButtonsFirst und nRadioButtonsLast (einschließlich) bereitgestellt. Wenn im Bereich ein leerer Eintrag vorhanden ist, fügt die Methode kein Optionsfeld für diesen Eintrag hinzu.

Standardmäßig sind neue Optionsfelder aktiviert.

Beispiel

// 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);

Überträgt den Fokus auf eine andere CTaskDialog.

protected:
void NavigateTo(CTaskDialog& oTaskDialog) const;

Parameter

oTaskDialog
[in] Das CTaskDialog , das den Fokus erhält.

Hinweise

Diese Methode blendet den aktuellen CTaskDialog Aus, wenn er den oTaskDialog anzeigt. Der oTaskDialog wird an derselben Position wie der aktuelle CTaskDialogangezeigt.

CTaskDialog::OnCommandControlClick

Das Framework ruft diese Methode auf, wenn der Benutzer auf ein Befehlsschaltflächen-Steuerelement klickt.

virtual HRESULT OnCommandControlClick(int nCommandControlID);

Parameter

nCommandControlID
[in] Die ID des Befehlsschaltflächen-Steuerelements, das der Benutzer ausgewählt hat.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnCreate

Das Framework ruft diese Methode auf, nachdem sie die CTaskDialog.

virtual HRESULT OnCreate();

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnDestroy

Das Framework ruft diese Methode unmittelbar auf, bevor sie die CTaskDialog.

virtual HRESULT OnDestroy();

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnExpandButtonClick

Das Framework ruft diese Methode auf, wenn der Benutzer auf die Erweiterungsschaltfläche klickt.

virtual HRESULT OnExpandButtonClicked(BOOL bExpanded);

Parameter

bExpanded
[in] Ein Wert ungleich Null gibt an, dass die zusätzlichen Informationen angezeigt werden; 0 gibt an, dass die zusätzlichen Informationen ausgeblendet sind.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnHelp

Das Framework ruft diese Methode auf, wenn der Benutzer Hilfe anfordert.

virtual HRESULT OnHelp();

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnHyperlinkClick

Das Framework ruft diese Methode auf, wenn der Benutzer auf einen Link klickt.

virtual HRESULT OnHyperlinkClick(const CString& strHref);

Parameter

strHref
[in] Die Zeichenfolge, die den Link darstellt.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Diese Methode ruft ShellExecute auf, bevor sie S_OK zurückgibt.

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnInit

Das Framework ruft diese Methode beim Initialisieren auf CTaskDialog .

virtual HRESULT OnInit();

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnNavigatePage

Das Framework ruft diese Methode als Reaktion auf die CTaskDialog::NavigateTo-Methode auf.

virtual HRESULT OnNavigatePage();

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnRadioButtonClick

Das Framework ruft diese Methode auf, wenn der Benutzer ein Optionsfeld-Steuerelement auswählt.

virtual HRESULT OnRadioButtonClick(int nRadioButtonID);

Parameter

nRadioButtonID
[in] Die ID des Optionsfeld-Steuerelements, auf das der Benutzer geklickt hat.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnTimer

Das Framework ruft diese Methode auf, wenn der Timer abläuft.

virtual HRESULT OnTimer(long lTime);

Parameter

Ltime
[in] Zeit in Millisekunden seit dem Erstellen oder CTaskDialog Zurücksetzen des Timers.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::OnVerificationCheckboxClick

Das Framework ruft diese Methode auf, wenn der Benutzer auf das Überprüfungskontrollkästchen klickt.

virtual HRESULT OnVerificationCheckboxClick(BOOL bChecked);

Parameter

bChecked
[in] TRUE gibt an, dass das Überprüfungskontrollkästchen aktiviert ist; FALSE gibt an, dass es nicht ist.

Rückgabewert

Die Standardimplementierung gibt S_OK zurück.

Hinweise

Überschreiben Sie diese Methode in einer abgeleiteten Klasse, um benutzerdefiniertes Verhalten zu implementieren.

CTaskDialog::RemoveAllCommandControls

Entfernt alle Befehlsschaltflächen-Steuerelemente aus dem CTaskDialog.

void RemoveAllCommandControls();

Beispiel

// 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

Entfernt alle Optionsfelder aus dem CTaskDialog.

void RemoveAllRadioButtons();

Beispiel

// 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

Aktualisiert ein Befehlsschaltflächen-Steuerelement auf der CTaskDialog.

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

Parameter

nCommandControlID
[in] Die ID des zu aktualisierenden Befehlssteuerelements.

bEnabled
[in] Ein boolescher Parameter, der angibt, ob das angegebene Befehlsschaltflächen-Steuerelement aktiviert oder deaktiviert ist.

bRequiresElevation
[in] Ein boolescher Parameter, der angibt, ob das angegebene Befehlsschaltflächen-Steuerelement eine Erhöhung erfordert.

Hinweise

Verwenden Sie diese Methode, um zu ändern, ob ein Befehlsschaltflächen-Steuerelement aktiviert ist oder eine Rechteerweiterung erfordert, nachdem es der CTaskDialog Klasse hinzugefügt wurde.

Beispiel

// 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

Aktualisiert eine Teilmenge allgemeiner Schaltflächen, die aktiviert werden sollen, und erfordert UAC-Rechteerweiterungen.

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

Parameter

nDisabledButtonMask
[in] Eine Maske für die allgemeinen Schaltflächen, die deaktiviert werden sollen.

nElevationButtonMask
[in] Eine Maske für die allgemeinen Schaltflächen, die eine Erhöhung erfordern.

Hinweise

Sie können die allgemeinen Schaltflächen für eine Instanz der CTaskDialog-Klasse festlegen, indem Sie den Konstruktor CTaskDialog::CTaskDialog und die Methode CTaskDialog::SetCommonButtons verwenden. CTaskDialog::SetCommonButtonOptions unterstützt das Hinzufügen neuer allgemeiner Schaltflächen nicht.

Wenn Sie diese Methode verwenden, um eine allgemeine Schaltfläche zu deaktivieren oder zu erhöhen, die für diese CTaskDialogOption nicht verfügbar ist, löst diese Methode eine Ausnahme mithilfe des ENSURE-Makros aus.

Diese Methode aktiviert alle Schaltflächen, die für die CTaskDialog nDisabledButtonMask verfügbar sind, aber nicht, auch wenn sie zuvor deaktiviert wurde. Diese Methode behandelt Die Rechteerweiterung auf ähnliche Weise: Sie zeichnet allgemeine Schaltflächen auf, da keine Erhöhung erforderlich ist, wenn die allgemeine Schaltfläche verfügbar ist, aber nicht in nElevationButtonMask enthalten ist.

Beispiel

// 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

Fügt allgemeine Schaltflächen zu der CTaskDialog.

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

Parameter

nButtonMask
[in] Eine Maske der Schaltflächen, die CTaskDialogder Schaltfläche hinzugefügt werden sollen.

nDisabledButtonMask
[in] Eine Maske der zu deaktivierenden Schaltflächen.

nElevationButtonMask
[in] Eine Maske der Schaltflächen, die eine Erhöhung erfordern.

Hinweise

Sie können diese Methode nicht aufrufen, nachdem das Anzeigefenster für diese Instanz der CTaskDialog Klasse erstellt wurde. Wenn Sie dies tun, löst diese Methode eine Ausnahme aus.

Die durch nButtonMask angegebenen Schaltflächen überschreiben alle allgemeinen Schaltflächen, die zuvor der CTaskDialogSchaltfläche hinzugefügt wurden. Nur die in nButtonMask angegebenen Schaltflächen sind verfügbar.

Wenn nDisabledButtonMask oder nElevationButtonMask eine Schaltfläche enthalten, die sich nicht in nButtonMask befindet, löst diese Methode eine Ausnahme mithilfe des ENSURE-Makros aus.

Standardmäßig sind alle allgemeinen Schaltflächen aktiviert und erfordern keine Erhöhung.

Beispiel

// 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

Aktualisiert den Inhalt der CTaskDialog.

void SetContent(const CString& strContent);

Parameter

strContent
[in] Die Zeichenfolge, die dem Benutzer angezeigt werden soll.

Hinweise

Der Inhalt der CTaskDialog Klasse ist der Text, der dem Benutzer im Abschnitt Standard des Dialogfelds angezeigt wird.

Beispiel

// 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

Gibt das Standardmäßige Befehlsschaltflächen-Steuerelement an.

void SetDefaultCommandControl(int nCommandControlID);

Parameter

nCommandControlID
[in] Die ID des Befehlsschaltflächen-Steuerelements als Standard.

Hinweise

Das Standardmäßige Befehlsschaltflächen-Steuerelement ist das Steuerelement, das ausgewählt wird, wenn der CTaskDialog Benutzer zum ersten Mal angezeigt wird.

Diese Methode löst eine Ausnahme aus, wenn das durch nCommandControlID angegebene Befehlsschaltflächen-Steuerelement nicht gefunden werden kann.

Beispiel

// 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

Gibt das Standard-Optionsfeld an.

void SetDefaultRadioButton(int nRadioButtonID);

Parameter

nRadioButtonID
[in] Die ID des Optionsfelds, das die Standardeinstellung sein soll.

Hinweise

Das Standard-Optionsfeld ist die Schaltfläche, die ausgewählt wird, wenn der CTaskDialog Benutzer zum ersten Mal angezeigt wird.

Diese Methode löst eine Ausnahme aus, wenn das optionsfeld, das durch nRadioButtonID angegeben ist, nicht gefunden werden kann.

Beispiel

// 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

Passt die Breite der CTaskDialog.

void SetDialogWidth(int nWidth = 0);

Parameter

nWidth
[in] Die Breite des Dialogfelds in Pixel.

Hinweise

Der Parameter nWidth muss größer oder gleich 0 sein. Andernfalls löst diese Methode eine Ausnahme aus.

Wenn nWidth auf 0 festgelegt ist, legt diese Methode das Dialogfeld auf die Standardgröße fest.

Beispiel

// 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

Aktualisiert den Erweiterungsbereich der CTaskDialog.

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

Parameter

strExpandedInformation
[in] Die Zeichenfolge, CTaskDialog die im Standard Textkörper des Dialogfelds angezeigt wird, wenn der Benutzer auf die Erweiterungsschaltfläche klickt.

strCollapsedLabel
[in] Die Zeichenfolge, die CTaskDialog neben der Erweiterungsschaltfläche angezeigt wird, wenn der erweiterte Bereich reduziert wird.

strExpandedLabel
[in] Die Zeichenfolge, die CTaskDialog neben der Erweiterungsschaltfläche angezeigt wird, wenn der erweiterte Bereich angezeigt wird.

Hinweise

Mit dem Erweiterungsbereich der CTaskDialog Klasse können Sie dem Benutzer zusätzliche Informationen bereitstellen. Der Erweiterungsbereich befindet sich im Standard Teil des CTaskDialog, direkt unterhalb des Titels und der Inhaltszeichenfolge.

Wenn die CTaskDialog erste Anzeige erfolgt, werden die erweiterten Informationen nicht angezeigt und neben der Erweiterungsschaltfläche platziert strCollapsedLabel . Wenn der Benutzer auf die Erweiterungsschaltfläche klickt, CTaskDialog wird strExpandedInformation angezeigt und die Bezeichnung in strExpandedLabel geändert.

Beispiel

// 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

Aktualisiert das Fußzeilensymbol der CTaskDialog.

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

Parameter

hFooterIcon
[in] Das neue Symbol für das CTaskDialog.

lpszFooterIcon
[in] Das neue Symbol für das CTaskDialog.

Hinweise

Das Fußzeilensymbol wird unten in der CTaskDialog-Klasse angezeigt. Er kann Fußzeilentext zugeordnet haben. Sie können den Fußzeilentext mit CTaskDialog::SetFooterText ändern.

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn der CTaskDialog Eingabeparameter angezeigt wird oder der Eingabeparameter NULL ist.

A CTaskDialog kann nur ein HICON Oder LPCWSTR als Fußzeilensymbol akzeptieren. Dies wird durch Festlegen der Option TDF_USE_HICON_FOOTER im Konstruktor oder CTaskDialog::SetOptions konfiguriert. Standardmäßig ist die CTaskDialog Verwendung LPCWSTR als Eingabetyp für das Fußzeilensymbol konfiguriert. Diese Methode generiert eine Ausnahme, wenn Sie versuchen, das Symbol mithilfe des unangemessenen Typs festzulegen.

Beispiel

// 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

Aktualisiert den Text auf der Fußzeile der CTaskDialog.

void SetFooterText(const CString& strFooterText);

Parameter

strFooterText
[in] Der neue Text für die Fußzeile.

Hinweise

Das Fußzeilensymbol wird neben dem Fußzeilentext am unteren Rand des CTaskDialogBereichs angezeigt. Sie können das Fußzeilensymbol mit CTaskDialog::SetFooterIcon ändern.

Beispiel

// 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

Aktualisiert das symbol Standard des .CTaskDialog

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

Parameter

hMainIcon
[in] Das neue Symbol.

lpszMainIcon
[in] Das neue Symbol.

Hinweise

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn der CTaskDialog Eingabeparameter angezeigt wird oder der Eingabeparameter NULL ist.

A CTaskDialog kann nur ein HICON oder LPCWSTR als Standard-Symbol akzeptieren. Sie können dies konfigurieren, indem Sie die option TDF_USE_HICON_MAIN im Konstruktor oder in der CTaskDialog::SetOptions-Methode festlegen. Standardmäßig ist die CTaskDialog Verwendung LPCWSTR als Eingabetyp für das symbol "Standard" konfiguriert. Diese Methode generiert eine Ausnahme, wenn Sie versuchen, das Symbol mithilfe des unangemessenen Typs festzulegen.

Beispiel

// 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

Aktualisiert die Standard Anweisung der CTaskDialog.

void SetMainInstruction(const CString& strInstructions);

Parameter

strInstructions
[in] Die neue Standard Anweisung.

Hinweise

Die Standard Anweisung der CTaskDialog Klasse wird dem Benutzer in einer großen fett formatierten Schriftart angezeigt. Er befindet sich im Dialogfeld unterhalb der Titelleiste.

Beispiel

// 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

Konfiguriert die Optionen für die CTaskDialog.

void SetOptions(int nOptionFlag);

Parameter

nOptionFlag
[in] Der Satz von Kennzeichnungen, die für die CTaskDialog.

Hinweise

Diese Methode löscht alle aktuellen Optionen für die CTaskDialog. Um die aktuellen Optionen beizubehalten, müssen Sie sie zuerst mit CTaskDialog::GetOptions abrufen und mit den Optionen kombinieren, die Sie festlegen möchten.

In der folgenden Tabelle sind alle gültigen Optionen aufgeführt.

Name Beschreibung
TDF_ENABLE_HYPERLINKS Aktiviert Links in der CTaskDialog.
TDF_USE_HICON_MAIN Konfiguriert die CTaskDialog Verwendung eines HICON symbols für das Standard. Die Alternative ist die Verwendung eines LPCWSTR.
TDF_USE_HICON_FOOTER Konfiguriert die CTaskDialog Verwendung eines HICON Symbols für die Fußzeile. Die Alternative ist die Verwendung eines LPCWSTR.
TDF_ALLOW_DIALOG_CANCELLATION Ermöglicht es dem Benutzer, die CTaskDialog Schaltfläche mithilfe der Tastatur oder mithilfe des Symbols in der oberen rechten Ecke des Dialogfelds zu schließen, auch wenn die Schaltfläche "Abbrechen " nicht aktiviert ist. Wenn dieses Kennzeichen nicht festgelegt ist und die Schaltfläche "Abbrechen " nicht aktiviert ist, kann der Benutzer das Dialogfeld nicht mithilfe von ALT+F4, der ESCAPE-TASTE oder der Schaltfläche zum Schließen der Titelleiste schließen.
TDF_USE_COMMAND_LINKS Konfiguriert die Verwendung von CTaskDialog Befehlsschaltflächensteuerelementen.
TDF_USE_COMMAND_LINKS_NO_ICON Konfiguriert die Verwendung von CTaskDialog Befehlsschaltflächensteuerelementen, ohne ein Symbol neben dem Steuerelement anzuzeigen. TDF_USE_COMMAND_LINKS überschreibt TDF_USE_COMMAND_LINKS_NO_ICON.
TDF_EXPAND_FOOTER_AREA Gibt an, dass der Erweiterungsbereich zurzeit erweitert ist.
TDF_EXPANDED_BY_DEFAULT Bestimmt, ob der Erweiterungsbereich standardmäßig erweitert wird.
TDF_VERIFICATION_FLAG_CHECKED Gibt an, dass das Überprüfungskontrollkästchen zurzeit aktiviert ist.
TDF_SHOW_PROGRESS_BAR Konfiguriert die CTaskDialog Anzeige einer Statusanzeige.
TDF_SHOW_MARQUEE_PROGRESS_BAR Konfiguriert die Statusanzeige so, dass sie eine Statusanzeige des Laufrahmens ist. Wenn Sie diese Option aktivieren, müssen Sie TDF_SHOW_PROGRESS_BAR auf das erwartete Verhalten festlegen.
TDF_CALLBACK_TIMER Gibt an, dass das CTaskDialog Rückrufintervall auf ca. 200 Millisekunden festgelegt ist.
TDF_POSITION_RELATIVE_TO_WINDOW Konfiguriert die CTaskDialog Zentriert werden, die relativ zum übergeordneten Fenster zentriert werden soll. Wenn dieses Flag nicht aktiviert ist, wird das CTaskDialog Flag relativ zum Monitor zentriert.
TDF_RTL_LAYOUT Konfiguriert das CTaskDialog Leselayout von rechts nach links.
TDF_NO_DEFAULT_RADIO_BUTTON Gibt an, dass kein Optionsfeld ausgewählt ist, wenn das CTaskDialog Steuerelement angezeigt wird.
TDF_CAN_BE_MINIMIZED Ermöglicht es dem Benutzer, die CTaskDialog. Um diese Option zu unterstützen, kann dies CTaskDialog nicht modal sein. MFC unterstützt diese Option nicht, da MFC keinen Modus ohne CTaskDialogModus unterstützt.

Beispiel

// 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

Konfiguriert eine Balkenleiste für das CTaskDialog Dialogfeld und fügt sie dem Dialogfeld hinzu.

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

Parameter

bEnabled
[in] TRUE, um die Festrahmenleiste zu aktivieren; FALSE, um die Leiste des Laufrahmens zu deaktivieren und aus der CTaskDialogLeiste zu entfernen.

nMarqueeSpeed
[in] Eine ganze Zahl, die die Geschwindigkeit des Laufrahmenbalkens angibt.

Hinweise

Unter dem Standard Text der CTaskDialog Klasse wird der Rahmenbalken angezeigt.

Verwenden Sie nMarqueeSpeed , um die Geschwindigkeit des Laufbalkens festzulegen. Größere Werte deuten auf eine langsamere Geschwindigkeit hin. Der Wert 0 für nMarqueeSpeed bewirkt, dass die Laufleiste mit der Standardgeschwindigkeit für Windows bewegt wird.

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn nMarqueeSpeed kleiner als 0 ist.

Beispiel

// 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

Passt die Position der Statusanzeige an.

void SetProgressBarPosition(int nProgressPos);

Parameter

nProgressPos
[in] Die Position für die Statusanzeige.

Hinweise

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn sich nProgressPos nicht im Statusleistenbereich befindet. Sie können den Bereich der Statusleiste mit CTaskDialog::SetProgressBarRange ändern.

Beispiel

// 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

Passt den Bereich der Statusanzeige an.

void SetProgressBarRange(
    int nRangeMin,
    int nRangeMax);

Parameter

nRangeMin
[in] Die untere Grenze der Statusanzeige.

nRangeMax
[in] Die obere Grenze der Statusleiste.

Hinweise

Die Position der Statusanzeige ist relativ zu nRangeMin und nRangeMax. Wenn beispielsweise nRangeMin 50 ist und nRangeMax 100 ist, ist eine Position von 75 auf halbem Weg über der Statusleiste. Verwenden Sie CTaskDialog::SetProgressBarPosition , um die Position der Statusleiste festzulegen.

Um die Statusleiste anzuzeigen, muss die Option TDF_SHOW_PROGRESS_BAR aktiviert sein, und TDF_SHOW_MARQUEE_PROGRESS_BAR nicht aktiviert werden dürfen. Diese Methode legt automatisch TDF_SHOW_PROGRESS_BAR fest und löscht TDF_SHOW_MARQUEE_PROGRESS_BAR. Verwenden Sie CTaskDialog::SetOptions , um die Optionen für diese Instanz der CTaskDialog-Klasse manuell zu ändern.

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn nRangeMin nicht kleiner als nRangeMax ist. Diese Methode löst auch eine Ausnahme aus, wenn dies CTaskDialog bereits angezeigt wird und über eine Statusanzeige für den Laufrahmen verfügt.

Beispiel

// 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

Legt den Status der Statusanzeige fest und zeigt ihn auf der CTaskDialog.

void SetProgressBarState(int nState = PBST_NORMAL);

Parameter

nState
[in] Der Status der Statusanzeige. Die möglichen Werte finden Sie im Abschnitt "Hinweise".

Hinweise

Mit dieser Methode wird eine Ausnahme mit dem ENSURE-Makro ausgelöst, wenn das CTaskDialog Makro bereits angezeigt wird und über eine Statusanzeige für das Feld verfügt.

In der folgenden Tabelle sind die möglichen Werte für "nState" aufgeführt. In all diesen Fällen füllt sich die Statusanzeige mit der regulären Farbe, bis sie die festgelegte Stoppposition erreicht. An diesem Punkt wird die Farbe basierend auf dem Zustand geändert.

Name Beschreibung
PBST_NORMAL Nachdem die Statusanzeige gefüllt wurde, ändert die CTaskDialog Farbe des Balkens nicht. Standardmäßig ist die normale Farbe grün.
PBST_ERROR Nachdem die Statusanzeige gefüllt wurde, ändert sich die CTaskDialog Farbe des Balkens in die Fehlerfarbe. Standardmäßig ist dies rot.
PBST_PAUSED Nachdem die Statusleiste gefüllt wurde, ändert sich die CTaskDialog Farbe des Balkens in die angehaltene Farbe. Standardmäßig ist dies gelb.

Sie können festlegen, wo die Statusleiste mit CTaskDialog::SetProgressBarPosition stoppt.

Beispiel

// 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

Aktiviert oder deaktiviert ein Optionsfeld.

void SetRadioButtonOptions(
    int nRadioButtonID,
    BOOL bEnabled);

Parameter

nRadioButtonID
[in] Die ID des Optionsfeld-Steuerelements.

bEnabled
[in] TRUE, um das Optionsfeld zu aktivieren; FALSE zum Deaktivieren des Optionsfelds.

Hinweise

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn nRadioButtonID keine gültige ID für ein Optionsfeld ist.

Beispiel

// 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

Legt den aktivierten Status des Überprüfungskontrollkästchens fest.

void SetVerificationCheckbox(BOOL bChecked);

Parameter

bChecked
[in] TRUE, damit das Überprüfungskontrollkästchen aktiviert ist, wenn das CTaskDialog Kontrollkästchen angezeigt wird; FALSE, damit das Überprüfungskontrollkästchen beim Anzeigen des CTaskDialog Kontrollkästchens deaktiviert ist.

Beispiel

// 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

Legt den Text fest, der rechts neben dem Überprüfungskontrollkästchen angezeigt wird.

void SetVerificationCheckboxText(CString& strVerificationText);

Parameter

strVerificationText
[in] Der Text, den diese Methode neben dem Überprüfungskontrollkästchen anzeigt.

Hinweise

Diese Methode löst eine Ausnahme mit dem ENSURE-Makro aus, wenn diese Instanz der CTaskDialog Klasse bereits angezeigt wird.

Beispiel

// 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

Legt den Titel des CTaskDialog.

void SetWindowTitle(CString& strWindowTitle);

Parameter

strWindowTitle
[in] Der neue Titel für die CTaskDialog.

Hinweise

Beispiel

// 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

Erstellt und zeigt eine 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(""));

Parameter

strContent
[in] Die für den Inhalt der CTaskDialogZeichenfolge zu verwendende Zeichenfolge.

strMainInstruction
[in] Die Standard Anweisung der CTaskDialog.

strTitle
[in] Der Titel des CTaskDialog.

nIDCommandControlsFirst
[in] Die Zeichenfolgen-ID des ersten Befehls.

nIDCommandControlsLast
[in] Die Zeichenfolgen-ID des letzten Befehls.

nCommonButtons
[in] Eine Maske der Schaltflächen, die CTaskDialogder Schaltfläche hinzugefügt werden sollen.

nTaskDialogOptions
[in] Die Gruppe der optionen, die für die CTaskDialog.

strFooter
[in] Die Zeichenfolge, die als Fußzeile verwendet werden soll.

Rückgabewert

Eine ganze Zahl, die der vom Benutzer getroffenen Auswahl entspricht.

Hinweise

Mit dieser statischen Methode können Sie eine Instanz der CTaskDialog Klasse erstellen, ohne explizit ein CTaskDialog Objekt in Ihrem Code zu erstellen. Da kein CTaskDialog Objekt vorhanden ist, können Sie keine anderen Methoden der CTaskDialog Methode aufrufen, wenn Sie diese Methode zum Anzeigen eines CTaskDialog Objekts für den Benutzer verwenden.

Diese Methode erstellt Befehlsschaltflächensteuerelemente mithilfe von Daten aus der Ressourcendatei Ihrer Anwendung. Die Zeichenfolgentabelle in der Ressourcendatei enthält mehrere Zeichenfolgen mit zugeordneten Zeichenfolgen-IDs. Diese Methode fügt ein Befehlsschaltflächen-Steuerelement für jeden gültigen Eintrag in der Zeichenfolgentabelle zwischen nIDCommandControlsFirst und nCommandControlsLast (einschließlich) hinzu. Bei diesen Befehlsschaltflächensteuerelementen ist die Zeichenfolge in der Zeichenfolgentabelle die Untertitel des Steuerelements, und die Zeichenfolgen-ID ist die ID des Steuerelements.

Eine Liste gültiger Optionen finden Sie unter "CTaskDialog::SetOptions ".

Wird CTaskDialog geschlossen, wenn der Benutzer eine allgemeine Schaltfläche, ein Befehlslink-Steuerelement oder das Schließt auswählt CTaskDialog. Der Rückgabewert ist der Bezeichner, der angibt, wie der Benutzer das Dialogfeld geschlossen hat.

Beispiel

// 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

Das Framework ruft diese Methode als Reaktion auf verschiedene Windows-Nachrichten auf.

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

Parameter

Hwnd
[in] Ein Handle für die m_hWnd Struktur für die CTaskDialog.

UNotification
[in] Der Benachrichtigungscode, der die generierte Nachricht angibt.

wParam
[in] Weitere Informationen zur Nachricht.

lParam
[in] Weitere Informationen zur Nachricht.

dwRefData
[in] Ein Zeiger auf das CTaskDialog Objekt, auf das die Rückrufnachricht angewendet wird.

Rückgabewert

Hängt vom spezifischen Benachrichtigungscode ab. Weitere Informationen finden Sie im Abschnitt Hinweise.

Hinweise

Die Standardimplementierung der TaskDialogCallback spezifischen Nachricht und ruft dann die entsprechende On-Methode der CTaskDialog-Klasse auf. Ruft beispielsweise als Reaktion auf die TDN_BUTTON_CLICKED Nachricht TaskDialogCallback CTaskDialog::OnCommandControlClick auf.

Die Werte für wParam und lParam hängen von der jeweiligen generierten Nachricht ab. Es ist möglich, dass beide Werte leer sind. In der folgenden Tabelle sind die standardbenachrichtigungen aufgeführt, die unterstützt werden und welche Werte von wParam und lParam darstellen. Wenn Sie diese Methode in einer abgeleiteten Klasse überschreiben, sollten Sie den Rückrufcode für jede Nachricht in der folgenden Tabelle implementieren.

Benachrichtigung wParam-Wert lParam-Wert
TDN_CREATED Nicht verwendet. Nicht verwendet.
TDN_NAVIGATED Nicht verwendet. Nicht verwendet.
TDN_BUTTON_CLICKED Die Befehlsschaltflächen-Steuerelement-ID. Nicht verwendet.
TDN_HYPERLINK_CLICKED Nicht verwendet. Eine LPCWSTR-Struktur , die den Link enthält.
TDN_TIMER Zeit in Millisekunden seit dem Erstellen oder CTaskDialog Zurücksetzen des Timers. Nicht verwendet.
TDN_DESTROYED Nicht verwendet. Nicht verwendet.
TDN_RADIO_BUTTON_CLICKED Die Optionsfeld-ID. Nicht verwendet.
TDN_DIALOG_CONSTRUCTED Nicht verwendet. Nicht verwendet.
TDN_VERIFICATION_CLICKED 1, wenn das Kontrollkästchen aktiviert ist, 0, wenn das nicht der Kontrollkästchen ist. Nicht verwendet.
TDN_HELP Nicht verwendet. Nicht verwendet.
TDN_EXPANDO_BUTTON_CLICKED 0, wenn die Erweiterungsfläche reduziert ist; nonzero, wenn der Erweiterungstext angezeigt wird. Nicht verwendet.

Siehe auch

Klassen
CObject-Klasse
Hierarchiediagramm
Exemplarische Vorgehensweise: Hinzufügen eines CTaskDialog zu einer Anwendung