Kelas CTaskDialog
Kotak dialog pop-up yang berfungsi seperti kotak pesan tetapi dapat menampilkan informasi tambahan kepada pengguna. Ini CTaskDialog
juga mencakup fungsionalitas untuk mengumpulkan informasi dari pengguna.
Sintaks
class CTaskDialog : public CObject
Anggota
Konstruktor
Nama | Deskripsi |
---|---|
CTaskDialog::CTaskDialog | Membuat CTaskDialog objek. |
Metode
Nama | Deskripsi |
---|---|
CTaskDialog::AddCommandControl | Menambahkan kontrol tombol perintah ke CTaskDialog . |
CTaskDialog::AddRadioButton | Menambahkan tombol radio ke CTaskDialog . |
CTaskDialog::ClickCommandControl | Klik kontrol tombol perintah atau tombol umum secara terprogram. |
CTaskDialog::ClickRadioButton | Klik tombol radio secara terprogram. |
CTaskDialog::D oModal |
CTaskDialog Menampilkan . |
CTaskDialog::GetCommonButtonCount | Mengambil jumlah tombol umum yang tersedia. |
CTaskDialog::GetCommonButtonFlag | Mengonversi tombol Windows standar ke jenis tombol umum yang terkait dengan CTaskDialog kelas. |
CTaskDialog::GetCommonButtonId | Mengonversi salah satu jenis tombol umum yang CTaskDialog terkait dengan kelas ke tombol Windows standar. |
CTaskDialog::GetOptions | Mengembalikan bendera opsi untuk ini CTaskDialog . |
CTaskDialog::GetSelectedCommandControlID | Mengembalikan kontrol tombol perintah terpilih. |
CTaskDialog::GetSelectedRadioButtonID | Mengembalikan tombol radio terpilih. |
CTaskDialog::GetVerificationCheckboxState | Mengambil status kotak centang verifikasi. |
CTaskDialog::IsCommandControlEnabled | Menentukan apakah kontrol tombol perintah atau tombol umum diaktifkan. |
CTaskDialog::IsRadioButtonEnabled | Menentukan apakah tombol radio diaktifkan. |
CTaskDialog::IsSupported | Menentukan apakah komputer yang menjalankan aplikasi mendukung CTaskDialog . |
CTaskDialog::LoadCommandControls | Menambahkan kontrol tombol perintah dengan menggunakan data dari tabel string. |
CTaskDialog::LoadRadioButtons | Menambahkan tombol radio dengan menggunakan data dari tabel string. |
CTaskDialog::NavigateTo | Mentransfer fokus ke yang lain CTaskDialog . |
CTaskDialog::OnCommandControlClick | Kerangka kerja memanggil metode ini ketika pengguna mengklik kontrol tombol perintah. |
CTaskDialog::OnCreate | Kerangka kerja memanggil metode ini setelah membuat CTaskDialog . |
CTaskDialog::OnDestroy | Kerangka kerja memanggil metode ini segera sebelum menghancurkan CTaskDialog . |
CTaskDialog::OnExpandButtonClick | Kerangka kerja memanggil metode ini ketika pengguna mengklik tombol ekspansi. |
CTaskDialog::OnHelp | Kerangka kerja memanggil metode ini ketika pengguna meminta bantuan. |
CTaskDialog::OnHyperlinkClick | Kerangka kerja memanggil metode ini ketika pengguna mengklik hyperlink. |
CTaskDialog::OnInit | Kerangka kerja memanggil metode ini ketika diinisialisasi CTaskDialog . |
CTaskDialog::OnNavigatePage | Kerangka kerja memanggil metode ini ketika pengguna memindahkan fokus sehubungan dengan kontrol pada CTaskDialog . |
CTaskDialog::OnRadioButtonClick | Kerangka kerja memanggil metode ini ketika pengguna memilih kontrol tombol radio. |
CTaskDialog::OnTimer | Kerangka kerja memanggil metode ini ketika timer kedaluwarsa. |
CTaskDialog::OnVerificationCheckboxClick | Kerangka kerja memanggil metode ini saat pengguna mengklik kotak centang verifikasi. |
CTaskDialog::RemoveAllCommandControls | Menghapus semua kontrol perintah dari CTaskDialog . |
CTaskDialog::RemoveAllRadioButtons | Menghapus semua tombol radio dari CTaskDialog . |
CTaskDialog::SetCommandControlOptions | Memperbarui kontrol tombol perintah pada CTaskDialog . |
CTaskDialog::SetCommonButtonOptions | Memperbarui subset tombol umum untuk diaktifkan dan memerlukan elevasi UAC. |
CTaskDialog::SetCommonButtons | Menambahkan tombol umum ke CTaskDialog . |
CTaskDialog::SetContent | Memperbarui konten CTaskDialog . |
CTaskDialog::SetDefaultCommandControl | Menentukan kontrol tombol perintah default. |
CTaskDialog::SetDefaultRadioButton | Menentukan tombol radio default. |
CTaskDialog::SetDialogWidth | Menyesuaikan lebar CTaskDialog . |
CTaskDialog::SetExpansionArea | Memperbarui area ekspansi .CTaskDialog |
CTaskDialog::SetFooterIcon | Memperbarui ikon footer untuk CTaskDialog . |
CTaskDialog::SetFooterText | Memperbarui teks pada footer CTaskDialog . |
CTaskDialog::SetMainIcon | Memperbarui ikon CTaskDialog utama . |
CTaskDialog::SetMainInstruction | Memperbarui instruksi utama dari CTaskDialog . |
CTaskDialog::SetOptions | Mengonfigurasi opsi untuk CTaskDialog . |
CTaskDialog::SetProgressBarMarquee | Mengonfigurasi bilah marquee untuk CTaskDialog dan menambahkannya ke kotak dialog. |
CTaskDialog::SetProgressBarPosition | Menyesuaikan posisi bilah kemajuan. |
CTaskDialog::SetProgressBarRange | Menyesuaikan rentang bilah kemajuan. |
CTaskDialog::SetProgressBarState | Mengatur status bilah kemajuan dan menampilkannya di CTaskDialog . |
CTaskDialog::SetRadioButtonOptions | Mengaktifkan atau menonaktifkan tombol radio. |
CTaskDialog::SetVerificationCheckbox | Mengatur status kotak centang verifikasi yang dicentang. |
CTaskDialog::SetVerificationCheckboxText | Mengatur teks di sisi kanan kotak centang verifikasi. |
CTaskDialog::SetWindowTitle | Mengatur judul CTaskDialog . |
CTaskDialog::ShowDialog | Membuat dan menampilkan CTaskDialog . |
CTaskDialog::TaskDialogCallback | Kerangka kerja memanggil ini sebagai respons terhadap berbagai pesan Windows. |
Anggota Data
Nama | Deskripsi |
---|---|
m_aButtons |
Array kontrol tombol perintah untuk CTaskDialog . |
m_aRadioButtons |
Array kontrol tombol radio untuk CTaskDialog . |
m_bVerified |
TRUE menunjukkan kotak centang verifikasi dicentang; FALSE menunjukkan tidak. |
m_footerIcon |
Ikon di footer CTaskDialog . |
m_hWnd |
Handel ke jendela untuk CTaskDialog . |
m_mainIcon |
Ikon utama .CTaskDialog |
m_nButtonDisabled |
Masker yang menunjukkan tombol umum mana yang dinonaktifkan. |
m_nButtonElevation |
Masker yang menunjukkan tombol umum mana yang memerlukan elevasi UAC. |
m_nButtonId |
ID kontrol tombol perintah yang dipilih. |
m_nCommonButton |
Masker yang menunjukkan tombol umum mana yang ditampilkan pada CTaskDialog . |
m_nDefaultCommandControl |
ID kontrol tombol perintah yang dipilih saat CTaskDialog ditampilkan. |
m_nDefaultRadioButton |
ID kontrol tombol radio yang dipilih saat CTaskDialog ditampilkan. |
m_nFlags |
Masker yang menunjukkan opsi untuk CTaskDialog . |
m_nProgressPos |
Posisi saat ini untuk bilah kemajuan. Nilai ini harus antara m_nProgressRangeMin dan m_nProgressRangeMax . |
m_nProgressRangeMax |
Nilai maksimum untuk bilah kemajuan. |
m_nProgressRangeMin |
Nilai minimum untuk bilah kemajuan. |
m_nProgressState |
Status bilah kemajuan. Untuk informasi selengkapnya, lihat CTaskDialog::SetProgressBarState. |
m_nRadioId |
ID kontrol tombol radio terpilih. |
m_nWidth |
Lebar CTaskDialog piksel dalam. |
m_strCollapse |
String yang CTaskDialog ditampilkan di sebelah kanan kotak ekspansi saat informasi yang diperluas disembunyikan. |
m_strContent |
String konten dari CTaskDialog . |
m_strExpand |
String yang CTaskDialog ditampilkan di sebelah kanan kotak ekspansi saat informasi yang diperluas ditampilkan. |
m_strFooter |
Footer dari CTaskDialog . |
m_strInformation |
Informasi yang diperluas untuk CTaskDialog . |
m_strMainInstruction |
Instruksi utama dari CTaskDialog . |
m_strTitle |
Judul .CTaskDialog |
m_strVerification |
String yang CTaskDialog ditampilkan di sebelah kanan kotak centang verifikasi. |
Keterangan
Kelas CTaskDialog
menggantikan kotak pesan Windows standar dan memiliki fungsionalitas tambahan seperti kontrol baru untuk mengumpulkan informasi dari pengguna. Kelas ini berada di pustaka MFC di Visual Studio 2010 dan yang lebih baru.
CTaskDialog
tersedia dimulai dengan Windows Vista. Versi Windows yang lebih lama tidak dapat menampilkan CTaskDialog
objek. Gunakan CTaskDialog::IsSupported
untuk menentukan pada runtime apakah pengguna saat ini dapat menampilkan kotak dialog tugas. Kotak pesan Windows standar masih didukung.
CTaskDialog
hanya tersedia saat Anda membuat aplikasi dengan menggunakan pustaka Unicode.
Memiliki CTaskDialog
dua konstruktor yang berbeda. Satu konstruktor memungkinkan Anda menentukan dua tombol perintah dan maksimum enam kontrol tombol reguler. Anda dapat menambahkan lebih banyak tombol perintah setelah membuat CTaskDialog
. Konstruktor kedua tidak mendukung tombol perintah apa pun, tetapi Anda dapat menambahkan kontrol tombol reguler dalam jumlah tak terbatas. Untuk informasi selengkapnya tentang konstruktor, lihat CTaskDialog::CTaskDialog.
Gambar berikut menunjukkan sampel CTaskDialog
untuk mengilustrasikan lokasi beberapa kontrol.
Sampel CTaskDialog
Persyaratan
Sistem operasi minimum yang diperlukan: Windows Vista
Header: afxtaskdialog.h
CTaskDialog::AddCommandControl
Menambahkan kontrol tombol perintah baru ke CTaskDialog
.
void AddCommandControl(
int nCommandControlID,
const CString& strCaption,
BOOL bEnabled = TRUE,
BOOL bRequiresElevation = FALSE);
Parameter
nCommandControlID
[di] Nomor identifikasi kontrol perintah.
strCaption
[di] String yang CTaskDialog
ditampilkan kepada pengguna. Gunakan string ini untuk menjelaskan tujuan perintah.
bEnabled
[di] Parameter Boolean yang menunjukkan apakah tombol baru diaktifkan atau dinonaktifkan.
bRequiresElevation
[di] Parameter Boolean yang menunjukkan apakah perintah memerlukan elevasi.
Keterangan
CTaskDialog Class
dapat menampilkan kontrol tombol perintah dalam jumlah tak terbatas. Namun, jika menampilkan CTaskDialog
kontrol tombol perintah apa pun, tombol tersebut dapat menampilkan maksimum enam tombol.
CTaskDialog
Jika tidak memiliki kontrol tombol perintah, tombol tersebut dapat menampilkan sejumlah tombol yang tidak terbatas.
Saat pengguna memilih kontrol tombol perintah, tombol CTaskDialog
akan ditutup. Jika aplikasi Anda menampilkan kotak dialog dengan menggunakan CTaskDialog::D oModal, DoModal
mengembalikan nCommandControlID dari kontrol tombol perintah yang dipilih.
Contoh
// 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
Menambahkan tombol radio ke CTaskDialog
.
void CTaskDialog::AddRadioButton(
int nRadioButtonID,
const CString& strCaption,
BOOL bEnabled = TRUE);
Parameter
nRadioButtonID
[di] Nomor identifikasi tombol radio.
strCaption
[di] String yang ditampilkan di CTaskDialog
samping tombol radio.
bEnabled
[di] Parameter Boolean yang menunjukkan apakah tombol radio diaktifkan.
Keterangan
Tombol radio untuk Kelas CTaskDialog memungkinkan Anda mengumpulkan informasi dari pengguna. Gunakan fungsi CTaskDialog::GetSelectedRadioButtonID untuk menentukan tombol radio mana yang dipilih.
CTaskDialog
Tidak mengharuskan parameter nRadioButtonID unik untuk setiap tombol radio. Namun, Anda mungkin mengalami perilaku tak terduga jika Anda tidak menggunakan pengidentifikasi yang berbeda untuk setiap tombol radio.
Contoh
// 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
Klik kontrol tombol perintah atau tombol umum secara terprogram.
protected:
void ClickCommandControl(int nCommandControlID) const;
Parameter
nCommandControlID
[di] ID perintah kontrol yang akan diklik.
Keterangan
Metode ini menghasilkan pesan windows TDM_CLICK_BUTTON.
CTaskDialog::ClickRadioButton
Klik tombol radio secara terprogram.
protected:
void ClickRadioButton(int nRadioButtonID) const;
Parameter
nRadioButtonID
[di] ID tombol radio yang akan diklik.
Keterangan
Metode ini menghasilkan pesan windows TDM_CLICK_RADIO_BUTTON.
CTaskDialog::CTaskDialog
Membuat instans Kelas CTaskDialog.
CTaskDialog(
const CString& strContent,
const CString& strMainInstruction,
const CString& strTitle,
int nCommonButtons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON,
int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
const CString& strFooter = _T(""));
CTaskDialog(
const CString& strContent,
const CString& strMainInstruction,
const CString& strTitle,
int nIDCommandControlsFirst,
int nIDCommandControlsLast,
int nCommonButtons,
int nTaskDialogOptions = TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS,
const CString& strFooter = _T(""));
Parameter
strContent
[di] String yang digunakan untuk konten CTaskDialog
.
strMainInstruction
[di] Instruksi utama dari CTaskDialog
.
strTitle
[di] Judul .CTaskDialog
nCommonButtons
[di] Masker tombol umum untuk ditambahkan ke CTaskDialog
.
nTaskDialogOptions
[di] Sekumpulan opsi yang akan digunakan untuk CTaskDialog
.
strFooter
[di] String yang digunakan sebagai footer.
nIDCommandControlsFirst
[di] ID string dari perintah pertama.
nIDCommandControlsLast
[di] ID string dari perintah terakhir.
Keterangan
Ada dua cara untuk menambahkan CTaskDialog
ke aplikasi Anda. Cara pertama adalah menggunakan salah satu konstruktor untuk membuat CTaskDialog
dan menampilkannya menggunakan CTaskDialog::D oModal. Cara kedua adalah menggunakan fungsi statis CTaskDialog::ShowDialog, yang memungkinkan Anda menampilkan CTaskDialog
tanpa membuat CTaskDialog
objek secara eksplisit.
Konstruktor kedua membuat kontrol tombol perintah dengan menggunakan data dari file sumber daya aplikasi Anda. Tabel string dalam file sumber daya memiliki beberapa string dengan ID string terkait. Metode ini menambahkan kontrol tombol perintah untuk setiap entri yang valid dalam tabel string antara nIDCommandControlsFirst dan nCommandControlsLast, inklusif. Untuk kontrol tombol perintah ini, string dalam tabel string adalah keterangan kontrol dan ID string adalah ID kontrol.
Lihat CTaskDialog::SetOptions untuk daftar opsi yang valid.
Contoh
// TODO: Replace the strings below with the appropriate message,
// main instruction, and dialog title
CString message("This is an important message to the user.");
CString mainInstruction("Important!\nPlease read!");
CString title("Alert Dialog");
CTaskDialog taskDialog(message, mainInstruction, title,
TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);
// Setting new information to be able to reuse the dialog resource
taskDialog.SetWindowTitle(L"New title for the task dialog");
taskDialog.SetContent(L"New message to show the user.");
taskDialog.SetMainInstruction(L"Even more important!");
taskDialog.SetMainIcon(TD_ERROR_ICON);
taskDialog.SetDialogWidth(300);
// Add a footer
taskDialog.SetFooterText(L"Footer information for the dialog.");
taskDialog.SetFooterIcon(TD_INFORMATION_ICON);
// Add expansion information
taskDialog.SetExpansionArea(L"Additional information\non two lines.",
L"Click here for more information.",
L"Click here to hide the extra information.");
// Change the options to show the expanded information by default.
// It is necessary to retrieve the current options first.
int options = taskDialog.GetOptions();
options |= TDF_EXPANDED_BY_DEFAULT;
taskDialog.SetOptions(options);
taskDialog.DoModal();
CTaskDialog::D oModal
CTaskDialog
Menunjukkan dan membuatnya modal.
INT_PTR DoModal (HWND hParent = ::GetActiveWindow());
Parameter
hParent
[di] Jendela induk untuk CTaskDialog
.
Tampilkan Nilai
Bilangan bulat yang sesuai dengan pilihan yang dibuat oleh pengguna.
Keterangan
Menampilkan instans CTaskDialog ini. Aplikasi kemudian menunggu pengguna menutup kotak dialog.
Menutup CTaskDialog
saat pengguna memilih tombol umum, kontrol tautan perintah, atau menutup CTaskDialog
. Nilai yang dikembalikan adalah pengidentifikasi yang menunjukkan cara pengguna menutup kotak dialog.
Contoh
// 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
Mengambil jumlah tombol umum.
int GetCommonButtonCount() const;
Tampilkan Nilai
Jumlah tombol umum yang tersedia.
Keterangan
Tombol umum adalah tombol default yang Anda berikan ke CTaskDialog::CTaskDialog. Kelas CTaskDialog menampilkan tombol di sepanjang bagian bawah kotak dialog.
Daftar tombol yang dijumlahkan disediakan di CommCtrl.h.
CTaskDialog::GetCommonButtonFlag
Mengonversi tombol Windows standar ke jenis tombol umum yang terkait dengan Kelas CTaskDialog.
int GetCommonButtonFlag(int nButtonId) const;
Parameter
nButtonId
[di] Nilai tombol Windows standar.
Tampilkan Nilai
Nilai tombol umum yang CTaskDialog
sesuai. Jika tidak ada tombol umum yang sesuai, metode ini mengembalikan 0.
CTaskDialog::GetCommonButtonId
Mengonversi salah satu jenis tombol umum yang terkait dengan Kelas CTaskDialog ke tombol Windows standar.
int GetCommonButtonId(int nFlag);
Parameter
nFlag
[di] Jenis tombol umum yang CTaskDialog
terkait dengan kelas .
Tampilkan Nilai
Nilai tombol Windows standar yang sesuai. Jika tidak ada tombol Windows yang sesuai, metode mengembalikan 0.
CTaskDialog::GetOptions
Mengembalikan bendera opsi untuk ini CTaskDialog
.
int GetOptions() const;
Tampilkan Nilai
Bendera untuk CTaskDialog
.
Keterangan
Untuk informasi selengkapnya tentang opsi yang tersedia untuk Kelas CTaskDialog, lihat CTaskDialog::SetOptions.
Contoh
// 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
Mengembalikan kontrol tombol perintah terpilih.
int GetSelectedCommandControlID() const;
Tampilkan Nilai
ID kontrol tombol perintah yang saat ini dipilih.
Keterangan
Anda tidak perlu menggunakan metode ini untuk mengambil ID tombol perintah yang dipilih pengguna. ID tersebut dikembalikan oleh CTaskDialog::D oModal atau CTaskDialog::ShowDialog.
Contoh
// 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
Mengembalikan tombol radio terpilih.
int GetSelectedRadioButtonID() const;
Tampilkan Nilai
ID tombol radio terpilih.
Keterangan
Anda dapat menggunakan metode ini setelah pengguna menutup kotak dialog untuk mengambil tombol radio yang dipilih.
Contoh
// 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
Mengambil status kotak centang verifikasi.
BOOL GetVerificationCheckboxState() const;
Tampilkan Nilai
TRUE jika kotak centang dicentang, FALSE jika tidak.
Contoh
// 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
Menentukan apakah kontrol atau tombol tombol perintah diaktifkan.
BOOL IsCommandControlEnabled(int nCommandControlID) const;
Parameter
nCommandControlID
[di] ID kontrol atau tombol tombol perintah untuk menguji.
Tampilkan Nilai
TRUE jika kontrol diaktifkan, FALSE jika tidak.
Keterangan
Anda dapat menggunakan metode ini untuk menentukan ketersediaan kedua kontrol tombol perintah dan tombol umum Kelas CTaskDialog
*.
Jika nCommandControlID bukan pengidentifikasi yang valid untuk tombol umum CTaskDialog
atau kontrol tombol perintah, metode ini akan menampilkan pengecualian.
Contoh
// 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
Menentukan apakah tombol radio diaktifkan.
BOOL IsRadioButtonEnabled(int nRadioButtonID) const;
Parameter
nRadioButtonID
[di] ID tombol radio untuk diuji.
Tampilkan Nilai
TRUE jika tombol radio diaktifkan, FALSE jika tidak.
Keterangan
Jika nRadioButtonID bukan pengidentifikasi yang valid untuk tombol radio, metode ini akan menampilkan pengecualian.
Contoh
// 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
Menentukan apakah komputer yang menjalankan aplikasi mendukung CTaskDialog
.
static BOOL IsSupported();
Tampilkan Nilai
TRUE jika komputer mendukung CTaskDialog
; FALSE jika tidak.
Keterangan
Gunakan fungsi ini untuk menentukan pada runtime jika komputer yang menjalankan aplikasi Anda mendukung CTaskDialog
kelas . Jika komputer tidak mendukung CTaskDialog
, Anda harus memberikan metode lain untuk mengomunikasikan informasi kepada pengguna. Aplikasi Anda akan crash jika mencoba menggunakan CTaskDialog
di komputer yang tidak mendukung CTaskDialog
kelas.
Contoh
// 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
Menambahkan kontrol tombol perintah dengan menggunakan data dari tabel string.
void LoadCommandControls(
int nIDCommandControlsFirst,
int nIDCommandControlsLast);
Parameter
nIDCommandControlsFirst
[di] ID string dari perintah pertama.
nIDCommandControlsLast
[di] ID string dari perintah terakhir.
Keterangan
Metode ini membuat kontrol tombol perintah dengan menggunakan data dari file sumber daya aplikasi Anda. Tabel string dalam file sumber daya memiliki beberapa string dengan ID string terkait. Kontrol tombol perintah baru yang ditambahkan dengan menggunakan metode ini menggunakan string untuk keterangan kontrol dan ID string untuk ID kontrol. Rentang string yang dipilih disediakan oleh nIDCommandControlsFirst dan nCommandControlsLast, inklusif. Jika ada entri kosong dalam rentang, metode tidak menambahkan kontrol tombol perintah untuk entri tersebut.
Secara default, kontrol tombol perintah baru diaktifkan dan tidak memerlukan elevasi.
Contoh
// 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
Menambahkan kontrol tombol radio dengan menggunakan data dari tabel string.
void LoadRadioButtons(
int nIDRadioButtonsFirst,
int nIDRadioButtonsLast);
Parameter
nIDRadioButtonsFirst
[di] ID string tombol radio pertama.
nIDRadioButtonsLast
[di] ID string tombol radio terakhir.
Keterangan
Metode ini membuat tombol radio dengan menggunakan data dari file sumber daya aplikasi Anda. Tabel string dalam file sumber daya memiliki beberapa string dengan ID string terkait. Tombol radio baru yang ditambahkan dengan menggunakan metode ini menggunakan string untuk keterangan tombol radio dan ID string untuk ID tombol radio. Rentang string yang dipilih disediakan oleh nIDRadioButtonsFirst dan nRadioButtonsLast, inklusif. Jika ada entri kosong dalam rentang, metode tidak menambahkan tombol radio untuk entri tersebut.
Secara default, tombol radio baru diaktifkan.
Contoh
// 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::NavigateTo
Mentransfer fokus ke yang lain CTaskDialog
.
protected:
void NavigateTo(CTaskDialog& oTaskDialog) const;
Parameter
oTaskDialog
[di] yang CTaskDialog
menerima fokus.
Keterangan
Metode ini menyembunyikan saat ini CTaskDialog
ketika menampilkan oTaskDialog.
oTaskDialog ditampilkan di lokasi yang sama dengan saat ini CTaskDialog
.
CTaskDialog::OnCommandControlClick
Kerangka kerja memanggil metode ini ketika pengguna mengklik kontrol tombol perintah.
virtual HRESULT OnCommandControlClick(int nCommandControlID);
Parameter
nCommandControlID
[di] ID kontrol tombol perintah yang dipilih pengguna.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnCreate
Kerangka kerja memanggil metode ini setelah membuat CTaskDialog
.
virtual HRESULT OnCreate();
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnDestroy
Kerangka kerja memanggil metode ini segera sebelum menghancurkan CTaskDialog
.
virtual HRESULT OnDestroy();
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnExpandButtonClick
Kerangka kerja memanggil metode ini ketika pengguna mengklik tombol ekspansi.
virtual HRESULT OnExpandButtonClicked(BOOL bExpanded);
Parameter
bExpanded
[di] Nilai bukan nol menunjukkan informasi tambahan ditampilkan; 0 menunjukkan informasi tambahan disembunyikan.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnHelp
Kerangka kerja memanggil metode ini ketika pengguna meminta bantuan.
virtual HRESULT OnHelp();
Tampilkan Nilai
Implementasi default mengembalikan S_FALSE.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnHyperlinkClick
Kerangka kerja memanggil metode ini ketika pengguna mengklik hyperlink.
virtual HRESULT OnHyperlinkClick(const CString& strHref);
Parameter
strHref
[di] String yang mewakili hyperlink.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Metode ini memanggil ShellExecute sebelum mengembalikan S_OK.
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnInit
Kerangka kerja memanggil metode ini ketika diinisialisasi CTaskDialog
.
virtual HRESULT OnInit();
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnNavigatePage
Kerangka kerja memanggil metode ini sebagai respons terhadap metode CTaskDialog::NavigateTo .
virtual HRESULT OnNavigatePage();
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnRadioButtonClick
Kerangka kerja memanggil metode ini ketika pengguna memilih kontrol tombol radio.
virtual HRESULT OnRadioButtonClick(int nRadioButtonID);
Parameter
nRadioButtonID
[di] ID kontrol tombol radio yang diklik pengguna.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnTimer
Kerangka kerja memanggil metode ini ketika timer kedaluwarsa.
virtual HRESULT OnTimer(long lTime);
Parameter
LTime
[di] Waktu dalam milidetik sejak CTaskDialog
dibuat atau timer direset.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::OnVerificationCheckboxClick
Kerangka kerja memanggil metode ini saat pengguna mengklik kotak centang verifikasi.
virtual HRESULT OnVerificationCheckboxClick(BOOL bChecked);
Parameter
bChecked
[di] TRUE menunjukkan kotak centang verifikasi dipilih; FALSE menunjukkan tidak.
Tampilkan Nilai
Implementasi default mengembalikan S_OK.
Keterangan
Ambil alih metode ini dalam kelas turunan untuk menerapkan perilaku kustom.
CTaskDialog::RemoveAllCommandControls
Menghapus semua kontrol tombol perintah dari CTaskDialog
.
void RemoveAllCommandControls();
Contoh
// 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
Menghapus semua tombol radio dari CTaskDialog
.
void RemoveAllRadioButtons();
Contoh
// 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
Memperbarui kontrol tombol perintah pada CTaskDialog
.
void SetCommandControlOptions(
int nCommandControlID,
BOOL bEnabled,
BOOL bRequiresElevation = FALSE);
Parameter
nCommandControlID
[di] ID kontrol perintah yang akan diperbarui.
bEnabled
[di] Parameter Boolean yang menunjukkan apakah kontrol tombol perintah yang ditentukan diaktifkan atau dinonaktifkan.
bRequiresElevation
[di] Parameter Boolean yang menunjukkan apakah kontrol tombol perintah yang ditentukan memerlukan elevasi.
Keterangan
Gunakan metode ini untuk mengubah apakah kontrol tombol perintah diaktifkan atau memerlukan elevasi setelah ditambahkan ke CTaskDialog
kelas .
Contoh
// 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
Memperbarui subset tombol umum untuk diaktifkan dan memerlukan elevasi UAC.
void SetCommonButtonOptions(
int nDisabledButtonMask,
int nElevationButtonMask = 0);
Parameter
nDisabledButtonMask
[di] Masker untuk tombol umum untuk dinonaktifkan.
nElevationButtonMask
[di] Masker untuk tombol umum yang memerlukan elevasi.
Keterangan
Anda dapat mengatur tombol umum yang tersedia untuk instans Kelas CTaskDialog dengan menggunakan konstruktor CTaskDialog::CTaskDialog dan metode CTaskDialog::SetCommonButtons.
CTaskDialog::SetCommonButtonOptions
tidak mendukung penambahan tombol umum baru.
Jika Anda menggunakan metode ini untuk menonaktifkan atau meningkatkan tombol umum yang tidak tersedia untuk ini CTaskDialog
, metode ini melemparkan pengecualian dengan menggunakan makro ENSURE .
Metode ini memungkinkan tombol apa pun yang tersedia untuk CTaskDialog
tetapi tidak ada di nDisabledButtonMask, bahkan jika sebelumnya dinonaktifkan. Metode ini memperlakukan elevasi dengan cara yang sama: metode ini merekam tombol umum karena tidak memerlukan elevasi jika tombol umum tersedia tetapi tidak termasuk dalam nElevationButtonMask.
Contoh
// 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
Menambahkan tombol umum ke CTaskDialog
.
void SetCommonButtons(
int nButtonMask,
int nDisabledButtonMask = 0,
int nElevationButtonMask = 0);
Parameter
nButtonMask
[di] Masker tombol untuk ditambahkan ke CTaskDialog
.
nDisabledButtonMask
[di] Masker tombol untuk dinonaktifkan.
nElevationButtonMask
[di] Masker tombol yang membutuhkan elevasi.
Keterangan
Anda tidak dapat memanggil metode ini setelah jendela tampilan untuk instans CTaskDialog
kelas ini dibuat. Jika Anda melakukannya, metode ini melemparkan pengecualian.
Tombol yang ditunjukkan oleh nButtonMask mengambil alih tombol umum yang sebelumnya ditambahkan ke CTaskDialog
. Hanya tombol yang ditunjukkan dalam nButtonMask yang tersedia.
Jika nDisabledButtonMask atau nElevationButtonMask berisi tombol yang tidak ada di nButtonMask, metode ini melempar pengecualian dengan menggunakan makro ENSURE.
Secara default, semua tombol umum diaktifkan dan tidak memerlukan elevasi.
Contoh
// 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
Memperbarui konten CTaskDialog
.
void SetContent(const CString& strContent);
Parameter
strContent
[di] String yang akan ditampilkan kepada pengguna.
Keterangan
Konten CTaskDialog
kelas adalah teks yang ditampilkan kepada pengguna di bagian utama kotak dialog.
Contoh
// 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
Menentukan kontrol tombol perintah default.
void SetDefaultCommandControl(int nCommandControlID);
Parameter
nCommandControlID
[di] ID kontrol tombol perintah menjadi default.
Keterangan
Kontrol tombol perintah default adalah kontrol yang dipilih saat CTaskDialog
pertama kali ditampilkan kepada pengguna.
Metode ini memberikan pengecualian jika tidak dapat menemukan kontrol tombol perintah yang ditentukan oleh nCommandControlID.
Contoh
// 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
Menentukan tombol radio default.
void SetDefaultRadioButton(int nRadioButtonID);
Parameter
nRadioButtonID
[di] ID tombol radio menjadi default.
Keterangan
Tombol radio default adalah tombol yang dipilih saat CTaskDialog
pertama kali ditampilkan kepada pengguna.
Metode ini melemparkan pengecualian jika tidak dapat menemukan tombol radio yang ditentukan oleh nRadioButtonID.
Contoh
// 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
Menyesuaikan lebar CTaskDialog
.
void SetDialogWidth(int nWidth = 0);
Parameter
nWidth
[di] Lebar kotak dialog, dalam piksel.
Keterangan
Parameter nWidth harus lebih besar dari atau sama dengan 0. Jika tidak, metode ini memberikan pengecualian.
Jika nWidth diatur ke 0, metode ini mengatur kotak dialog ke ukuran default.
Contoh
// 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
Memperbarui area ekspansi .CTaskDialog
void SetExpansionArea(
const CString& strExpandedInformation,
const CString& strCollapsedLabel = _T(""),
const CString& strExpandedLabel = _T(""));
Parameter
strExpandedInformation
[di] String yang CTaskDialog
ditampilkan dalam isi utama kotak dialog saat pengguna mengklik tombol ekspansi.
strCollapsedLabel
[di] String yang ditampilkan di CTaskDialog
samping tombol ekspansi saat area yang diperluas diciutkan.
strExpandedLabel
[di] String yang ditampilkan di CTaskDialog
samping tombol ekspansi saat area yang diperluas ditampilkan.
Keterangan
Area CTaskDialog
ekspansi kelas memungkinkan Anda memberikan informasi tambahan kepada pengguna. Area ekspansi berada di bagian CTaskDialog
utama , yang terletak tepat di bawah judul dan string konten.
CTaskDialog
Ketika pertama kali ditampilkan, itu tidak menampilkan informasi yang diperluas dan diletakkan strCollapsedLabel
di samping tombol ekspansi. Ketika pengguna mengklik tombol ekspansi, CTaskDialog
strExpandedInformation ditampilkan dan mengubah label menjadi strExpandedLabel.
Contoh
// 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
Memperbarui ikon footer dari CTaskDialog
.
void SetFooterIcon(HICON hFooterIcon);
void SetFooterIcon(LPCWSTR lpszFooterIcon);
Parameter
hFooterIcon
[di] Ikon baru untuk CTaskDialog
.
lpszFooterIcon
[di] Ikon baru untuk CTaskDialog
.
Keterangan
Ikon footer ditampilkan di bagian bawah Kelas CTaskDialog. Ini dapat memiliki teks footer terkait. Anda dapat mengubah teks footer dengan CTaskDialog::SetFooterText.
Metode ini memberikan pengecualian dengan makro ENSURE jika CTaskDialog
ditampilkan atau parameter input adalah NULL.
Hanya CTaskDialog
dapat menerima HICON
atau LPCWSTR
sebagai ikon footer. Ini dikonfigurasi dengan mengatur opsi TDF_USE_HICON_FOOTER di konstruktor atau CTaskDialog::SetOptions. Secara default, dikonfigurasi CTaskDialog
untuk digunakan LPCWSTR
sebagai jenis input untuk ikon footer. Metode ini menghasilkan pengecualian jika Anda mencoba mengatur ikon menggunakan jenis yang tidak pantas.
Contoh
// 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
Memperbarui teks pada footer CTaskDialog
.
void SetFooterText(const CString& strFooterText);
Parameter
strFooterText
[di] Teks baru untuk footer.
Keterangan
Ikon footer muncul di samping teks footer di bagian CTaskDialog
bawah . Anda dapat mengubah ikon footer dengan CTaskDialog::SetFooterIcon.
Contoh
// 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
Memperbarui ikon CTaskDialog
utama .
void SetMainIcon(HICON hMainIcon);
void SetMainIcon(LPCWSTR lpszMainIcon);
Parameter
hMainIcon
[di] Ikon baru.
lpszMainIcon
[di] Ikon baru.
Keterangan
Metode ini memberikan pengecualian dengan makro ENSURE jika CTaskDialog
ditampilkan atau parameter input adalah NULL.
Hanya CTaskDialog
dapat menerima HICON
atau LPCWSTR
sebagai ikon utama. Anda dapat mengonfigurasi ini dengan mengatur opsi TDF_USE_HICON_MAIN di konstruktor atau di metode CTaskDialog::SetOptions . Secara default, dikonfigurasi CTaskDialog
untuk digunakan LPCWSTR
sebagai jenis input untuk ikon utama. Metode ini menghasilkan pengecualian jika Anda mencoba mengatur ikon menggunakan jenis yang tidak pantas.
Contoh
// 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
Memperbarui instruksi utama dari CTaskDialog
.
void SetMainInstruction(const CString& strInstructions);
Parameter
strInstructions
[di] Instruksi utama baru.
Keterangan
Instruksi CTaskDialog
utama kelas adalah teks yang ditampilkan kepada pengguna dalam font tebal besar. Ini terletak di kotak dialog di bawah bilah judul.
Contoh
// 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
Mengonfigurasi opsi untuk CTaskDialog
.
void SetOptions(int nOptionFlag);
Parameter
nOptionFlag
[di] Kumpulan bendera yang akan digunakan untuk CTaskDialog
.
Keterangan
Metode ini menghapus semua opsi saat ini untuk CTaskDialog
. Untuk mempertahankan opsi saat ini, Anda harus mengambilnya terlebih dahulu dengan CTaskDialog::GetOptions dan menggabungkannya dengan opsi yang ingin Anda atur.
Tabel berikut mencantumkan semua opsi yang valid.
Nama | Deskripsi |
---|---|
TDF_ENABLE_HYPERLINKS | Mengaktifkan hyperlink di CTaskDialog . |
TDF_USE_HICON_MAIN |
CTaskDialog Mengonfigurasi untuk menggunakan HICON ikon utama. Alternatifnya adalah menggunakan LPCWSTR . |
TDF_USE_HICON_FOOTER |
CTaskDialog Mengonfigurasi untuk menggunakan HICON ikon footer. Alternatifnya adalah menggunakan LPCWSTR . |
TDF_ALLOW_DIALOG_CANCELLATION | Memungkinkan pengguna untuk menutup CTaskDialog dengan menggunakan keyboard atau dengan menggunakan ikon di sudut kanan atas kotak dialog, bahkan jika tombol Batal tidak diaktifkan. Jika bendera ini tidak diatur dan tombol Batalkan tidak diaktifkan, pengguna tidak dapat menutup kotak dialog dengan menggunakan Alt+F4, tombol Escape, atau tombol tutup bilah judul. |
TDF_USE_COMMAND_LINKS |
CTaskDialog Mengonfigurasi untuk menggunakan kontrol tombol perintah. |
TDF_USE_COMMAND_LINKS_NO_ICON |
CTaskDialog Mengonfigurasi untuk menggunakan kontrol tombol perintah tanpa menampilkan ikon di samping kontrol. TDF_USE_COMMAND_LINKS mengambil alih TDF_USE_COMMAND_LINKS_NO_ICON. |
TDF_EXPAND_FOOTER_AREA | Menunjukkan area ekspansi saat ini diperluas. |
TDF_EXPANDED_BY_DEFAULT | Menentukan apakah area ekspansi diperluas secara default. |
TDF_VERIFICATION_FLAG_CHECKED | Menunjukkan kotak centang verifikasi saat ini dipilih. |
TDF_SHOW_PROGRESS_BAR |
CTaskDialog Mengonfigurasi untuk menampilkan bilah kemajuan. |
TDF_SHOW_MARQUEE_PROGRESS_BAR | Mengonfigurasi bilah kemajuan menjadi bilah kemajuan marquee. Jika Mengaktifkan opsi ini, Anda harus mengatur TDF_SHOW_PROGRESS_BAR agar memiliki perilaku yang diharapkan. |
TDF_CALLBACK_TIMER | Menunjukkan bahwa CTaskDialog interval panggilan balik diatur ke sekitar 200 milidetik. |
TDF_POSITION_RELATIVE_TO_WINDOW | Mengonfigurasi untuk dipusatkan CTaskDialog relatif terhadap jendela induk. Jika bendera ini tidak diaktifkan, dipusatkan CTaskDialog relatif terhadap monitor. |
TDF_RTL_LAYOUT |
CTaskDialog Mengonfigurasi untuk tata letak baca kanan-ke-kiri. |
TDF_NO_DEFAULT_RADIO_BUTTON | Menunjukkan bahwa tidak ada tombol radio yang dipilih saat CTaskDialog muncul. |
TDF_CAN_BE_MINIMIZED | Memungkinkan pengguna untuk meminimalkan CTaskDialog . Untuk mendukung opsi ini, CTaskDialog tidak dapat dimodifikasi. MFC tidak mendukung opsi ini karena MFC tidak mendukung modeless CTaskDialog . |
Contoh
// 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
Mengonfigurasi bilah marquee untuk CTaskDialog
dan menambahkannya ke kotak dialog.
void SetProgressBarMarquee(
BOOL bEnabled = TRUE,
int nMarqueeSpeed = 0);
Parameter
bEnabled
[di] TRUE untuk mengaktifkan bilah marquee; FALSE untuk menonaktifkan bilah marquee dan menghapusnya dari CTaskDialog
.
nMarqueeSpeed
[di] Bilangan bulat yang menunjukkan kecepatan bilah marquee.
Keterangan
Bilah marquee muncul di bawah teks CTaskDialog
utama kelas.
Gunakan nMarqueeSpeed untuk mengatur kecepatan bilah marquee; nilai yang lebih besar menunjukkan kecepatan yang lebih lambat. Nilai 0 untuk nMarqueeSpeed membuat bilah marquee bergerak pada kecepatan default untuk Windows.
Metode ini memberikan pengecualian dengan makro ENSURE jika nMarqueeSpeed kurang dari 0.
Contoh
// 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
Menyesuaikan posisi bilah kemajuan.
void SetProgressBarPosition(int nProgressPos);
Parameter
nProgressPos
[di] Posisi untuk bilah kemajuan.
Keterangan
Metode ini melemparkan pengecualian dengan makro ENSURE jika nProgressPos tidak berada dalam rentang bilah kemajuan. Anda dapat mengubah rentang bilah kemajuan dengan CTaskDialog::SetProgressBarRange.
Contoh
// 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
Menyesuaikan rentang bilah kemajuan.
void SetProgressBarRange(
int nRangeMin,
int nRangeMax);
Parameter
nRangeMin
[di] Batas bawah bilah kemajuan.
nRangeMax
[di] Batas atas bilah kemajuan.
Keterangan
Posisi bilah kemajuan relatif terhadap nRangeMin dan nRangeMax. Misalnya, jika nRangeMin adalah 50 dan nRangeMax adalah 100, posisi 75 berada setengah di seluruh bilah kemajuan. Gunakan CTaskDialog::SetProgressBarPosition untuk mengatur posisi bilah kemajuan.
Untuk menampilkan bilah kemajuan, opsi TDF_SHOW_PROGRESS_BAR harus diaktifkan dan TDF_SHOW_MARQUEE_PROGRESS_BAR tidak boleh diaktifkan. Metode ini secara otomatis mengatur TDF_SHOW_PROGRESS_BAR dan menghapus TDF_SHOW_MARQUEE_PROGRESS_BAR. Gunakan CTaskDialog::SetOptions untuk mengubah opsi secara manual untuk instans Kelas CTaskDialog ini.
Metode ini memberikan pengecualian dengan makro ENSURE jika nRangeMin tidak kurang dari nRangeMax. Metode ini juga melemparkan pengecualian jika CTaskDialog
sudah ditampilkan dan memiliki bilah kemajuan marquee.
Contoh
// 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
Mengatur status bilah kemajuan dan menampilkannya di CTaskDialog
.
void SetProgressBarState(int nState = PBST_NORMAL);
Parameter
nState
[di] Status bilah kemajuan. Lihat bagian Keterangan untuk nilai yang mungkin.
Keterangan
Metode ini memberikan pengecualian dengan makro ENSURE jika CTaskDialog
sudah ditampilkan dan memiliki bilah kemajuan marquee.
Tabel berikut mencantumkan nilai yang mungkin untuk nState. Dalam semua kasus ini, bilah kemajuan akan diisi dengan warna reguler sampai mencapai posisi berhenti yang ditunjuk. Pada saat itu akan berubah warna berdasarkan status.
Nama | Deskripsi |
---|---|
PBST_NORMAL | Setelah bilah kemajuan terisi, CTaskDialog tidak mengubah warna bilah. Secara default, warna reguler berwarna hijau. |
PBST_ERROR | Setelah bilah kemajuan terisi, mengubah CTaskDialog warna bilah menjadi warna kesalahan. Secara default, ini berwarna merah. |
PBST_PAUSED | Setelah bilah kemajuan terisi, mengubah CTaskDialog warna bilah ke warna yang dijeda. Secara default, ini berwarna kuning. |
Anda dapat mengatur di mana bilah kemajuan berhenti dengan CTaskDialog::SetProgressBarPosition.
Contoh
// 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
Mengaktifkan atau menonaktifkan tombol radio.
void SetRadioButtonOptions(
int nRadioButtonID,
BOOL bEnabled);
Parameter
nRadioButtonID
[di] ID kontrol tombol radio.
bEnabled
[di] TRUE untuk mengaktifkan tombol radio; FALSE untuk menonaktifkan tombol radio.
Keterangan
Metode ini melemparkan pengecualian dengan makro ENSURE jika nRadioButtonID bukan ID yang valid untuk tombol radio.
Contoh
// 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
Mengatur status kotak centang verifikasi yang dicentang.
void SetVerificationCheckbox(BOOL bChecked);
Parameter
bChecked
[di] TRUE untuk memilih kotak centang verifikasi saat CTaskDialog
ditampilkan; FALSE agar kotak centang verifikasi tidak dipilih saat CTaskDialog
ditampilkan.
Contoh
// 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
Mengatur teks yang ditampilkan di sebelah kanan kotak centang verifikasi.
void SetVerificationCheckboxText(CString& strVerificationText);
Parameter
strVerificationText
[di] Teks yang ditampilkan metode ini di samping kotak centang verifikasi.
Keterangan
Metode ini melemparkan pengecualian dengan makro ENSURE jika instans CTaskDialog
kelas ini sudah ditampilkan.
Contoh
// 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
Mengatur judul CTaskDialog
.
void SetWindowTitle(CString& strWindowTitle);
Parameter
strWindowTitle
[di] Judul baru untuk CTaskDialog
.
Keterangan
Contoh
// 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
Membuat dan menampilkan 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
[di] String yang digunakan untuk konten CTaskDialog
.
strMainInstruction
[di] Instruksi utama dari CTaskDialog
.
strTitle
[di] Judul .CTaskDialog
nIDCommandControlsFirst
[di] ID string dari perintah pertama.
nIDCommandControlsLast
[di] ID string dari perintah terakhir.
nCommonButtons
[di] Masker tombol untuk ditambahkan ke CTaskDialog
.
nTaskDialogOptions
[di] Sekumpulan opsi yang akan digunakan untuk CTaskDialog
.
strFooter
[di] String yang digunakan sebagai footer.
Tampilkan Nilai
Bilangan bulat yang sesuai dengan pilihan yang dibuat oleh pengguna.
Keterangan
Metode statis ini memungkinkan Anda membuat instans CTaskDialog
kelas tanpa secara eksplisit membuat CTaskDialog
objek dalam kode Anda. Karena tidak CTaskDialog
ada objek, Anda tidak dapat memanggil metode CTaskDialog
lain jika Anda menggunakan metode ini untuk menampilkan CTaskDialog
kepada pengguna.
Metode ini membuat kontrol tombol perintah dengan menggunakan data dari file sumber daya aplikasi Anda. Tabel string dalam file sumber daya memiliki beberapa string dengan ID string terkait. Metode ini menambahkan kontrol tombol perintah untuk setiap entri yang valid dalam tabel string antara nIDCommandControlsFirst dan nCommandControlsLast, inklusif. Untuk kontrol tombol perintah ini, string dalam tabel string adalah keterangan kontrol dan ID string adalah ID kontrol.
Lihat CTaskDialog::SetOptions untuk daftar opsi yang valid.
Menutup CTaskDialog
saat pengguna memilih tombol umum, kontrol tautan perintah, atau menutup CTaskDialog
. Nilai yang dikembalikan adalah pengidentifikasi yang menunjukkan cara pengguna menutup kotak dialog.
Contoh
// 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
Kerangka kerja memanggil metode ini sebagai respons terhadap berbagai pesan Windows.
friend:
HRESULT TaskDialogCallback(
HWND hWnd,
UINT uNotification,
WPARAM wParam,
LPARAM lParam,
LONG_PTR dwRefData);
Parameter
hwnd
[di] Handel ke m_hWnd
struktur untuk CTaskDialog
.
uNotification
[di] Kode pemberitahuan yang menentukan pesan yang dihasilkan.
wParam
[di] Informasi selengkapnya tentang pesan.
lParam
[di] Informasi selengkapnya tentang pesan.
dwRefData
[di] Penunjuk ke CTaskDialog
objek tempat pesan panggilan balik diterapkan.
Tampilkan Nilai
Tergantung pada kode pemberitahuan tertentu. Lihat bagian Keterangan untuk informasi lebih lanjut.
Keterangan
Implementasi TaskDialogCallback
default menangani pesan tertentu lalu memanggil metode On yang sesuai dari Kelas CTaskDialog. Misalnya, sebagai respons terhadap pesan TDN_BUTTON_CLICKED, TaskDialogCallback
memanggil CTaskDialog::OnCommandControlClick.
Nilai untuk wParam dan lParam bergantung pada pesan tertentu yang dihasilkan. Dimungkinkan agar salah satu atau kedua nilai ini kosong. Tabel berikut mencantumkan pemberitahuan default yang didukung dan apa yang diwakili nilai wParam dan lParam . Jika Anda mengambil alih metode ini di kelas turunan, Anda harus menerapkan kode panggilan balik untuk setiap pesan dalam tabel berikut.
Pesan Pemberitahuan | Nilai wParam | Nilai lParam |
---|---|---|
TDN_CREATED | Tidak digunakan. | Tidak digunakan. |
TDN_NAVIGATED | Tidak digunakan. | Tidak digunakan. |
TDN_BUTTON_CLICKED | ID kontrol tombol perintah. | Tidak digunakan. |
TDN_HYPERLINK_CLICKED | Tidak digunakan. | Struktur LPCWSTR yang berisi tautan . |
TDN_TIMER | Waktu dalam milidetik sejak CTaskDialog dibuat atau timer direset. |
Tidak digunakan. |
TDN_DESTROYED | Tidak digunakan. | Tidak digunakan. |
TDN_RADIO_BUTTON_CLICKED | ID tombol radio. | Tidak digunakan. |
TDN_DIALOG_CONSTRUCTED | Tidak digunakan. | Tidak digunakan. |
TDN_VERIFICATION_CLICKED | 1 jika kotak centang dicentang, 0 jika tidak. | Tidak digunakan. |
TDN_HELP | Tidak digunakan. | Tidak digunakan. |
TDN_EXPANDO_BUTTON_CLICKED | 0 jika area ekspansi diciutkan; bukan nol jika teks ekspansi ditampilkan. | Tidak digunakan. |
Lihat juga
Kelas
Kelas CObject
Bagan Hierarki
Panduan: Menambahkan CTaskDialog ke Aplikasi