Skip to content

Commit 3057606

Browse files
authored
Merge pull request #5772 from MicrosoftDocs/main
2/10/2025 AM Publish
2 parents 8f664c9 + 220b690 commit 3057606

File tree

5 files changed

+70
-115
lines changed

5 files changed

+70
-115
lines changed

docs/cpp/stdcall.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The **`__stdcall`** calling convention is used to call Win32 API functions. The
1313
## Syntax
1414

1515
> *return-type* **`__stdcall`** *function-name*[**`(`** *argument-list* **`)`**]
16+
>
17+
> **`auto`** **`__stdcall`** *function-name*[**`(`** *argument-list* **`)`**] [ **`->`** *return-type* ]
1618
1719
## Remarks
1820

docs/mfc/reference/ctaskdialog-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ virtual HRESULT OnHelp();
685685

686686
### Return Value
687687

688-
The default implementation returns S_OK.
688+
The default implementation returns S_FALSE.
689689

690690
### Remarks
691691

Lines changed: 51 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
description: "Learn more about: Walkthrough: Adding a CTaskDialog to an Application"
2+
description: "Learn how to add a CTaskDialog to a MFC application"
33
title: "Walkthrough: Adding a CTaskDialog to an Application"
4-
ms.date: "04/25/2019"
4+
ms.date: "2/7/2025"
55
helpviewer_keywords: ["CTaskDialog, adding", "walkthroughs [MFC], dialogs"]
6-
ms.assetid: 3a62abb8-2d86-4bec-bdb8-5784d5f9a9f8
76
---
8-
# Walkthrough: Adding a CTaskDialog to an Application
7+
# Walkthrough: Adding a CTaskDialog to an application
98

10-
This walkthrough introduces the [CTaskDialog Class](../mfc/reference/ctaskdialog-class.md) and shows you how to add one to your application.
9+
This walkthrough introduces the [`CTaskDialog` class](../mfc/reference/ctaskdialog-class.md) and shows how to add it to your application.
1110

12-
The `CTaskDialog` is a task dialog box that replaces the Windows message box in Windows Vista or later. The `CTaskDialog` improves the original message box and adds functionality. The Windows message box is still supported in Visual Studio.
11+
The `CTaskDialog` is a task dialog box that replaces the Windows message box in Windows Vista or later. The `CTaskDialog` improves on the original message box and adds functionality. The Windows message box is still supported in Visual Studio.
1312

1413
> [!NOTE]
15-
> Versions of Windows earlier than Windows Vista do not support the `CTaskDialog`. You must program an alternative dialog box option if you want to show a message to a user who runs your application on an earlier version of Windows. You can use the static method [CTaskDialog::IsSupported](../mfc/reference/ctaskdialog-class.md#issupported) to determine at run time whether a user's computer can display a `CTaskDialog`. In addition, the `CTaskDialog` is only available when your application is built with the Unicode library.
14+
> Versions of Windows earlier than Windows Vista don't support the `CTaskDialog`. You must program an alternative dialog box option if you want to show a message to a user who runs your application on an earlier version of Windows. You can use the static method [CTaskDialog::IsSupported](../mfc/reference/ctaskdialog-class.md#issupported) to determine at run time whether a user's computer can display a `CTaskDialog`. In addition, the `CTaskDialog` is only available when your application is built with the Unicode library.
1615
1716
The `CTaskDialog` supports several optional elements to gather and display information. For example, a `CTaskDialog` can display command links, customized buttons, customized icons, and a footer. The `CTaskDialog` also has several methods that enable you to query the state of the task dialog box to determine what optional elements the user selected.
1817

@@ -21,83 +20,49 @@ The `CTaskDialog` supports several optional elements to gather and display infor
2120
You need the following components to complete this walkthrough:
2221

2322
- Visual Studio 2010 or later
24-
2523
- Windows Vista or later
2624

27-
## Replacing a Windows Message Box with a CTaskDialog
28-
29-
The following procedure demonstrates the most basic use of the `CTaskDialog`, which is to replace the Windows message box. This example also changes the icon associated with the task dialog box. Changing the icon makes the `CTaskDialog` appear same to the Windows message box.
30-
31-
### To Replace a Windows Message Box with a CTaskDialog
25+
## Replace the Windows message box with a CTaskDialog
3226

33-
1. Use the **MFC Application Wizard** to create an MFC application with all the default settings. See [Walkthrough: Using the New MFC Shell Controls](walkthrough-using-the-new-mfc-shell-controls.md) for instructions on how to open the wizard for your version of Visual Studio.
27+
The following demonstrates the most basic use of the `CTaskDialog`, which is to replace the Windows message box. This example also changes the icon associated with the task dialog box. Changing the icon makes the `CTaskDialog` appear similar to the Windows message box.
3428

29+
1. Use the **MFC Application Wizard** to create a Microsoft Foundation Classes (MFC) application with all the default settings. See [Walkthrough: Using the New MFC Shell Controls](walkthrough-using-the-new-mfc-shell-controls.md) for instructions on how to open the wizard for your version of Visual Studio.
3530
1. Call it *MyProject*.
36-
37-
1. Use the **Solution Explorer** to open the file MyProject.cpp.
38-
31+
1. Use the **Solution Explorer** to open `MyProject.cpp`.
3932
1. Add `#include "afxtaskdialog.h"` after the list of includes.
40-
4133
1. Find the method `CMyProjectApp::InitInstance`. Insert the following lines of code before the `return TRUE;` statement. This code creates the strings that we use in either the Windows message box or in the `CTaskDialog`.
4234

4335
```cpp
4436
CString message("My message to the user");
4537
CString dialogTitle("My Task Dialog title");
4638
CString emptyString;
47-
```
48-
49-
1. Add the following code after the code from step 4. This code guarantees that the user's computer supports the `CTaskDialog`. If the dialog isn't supported, the application displays a Windows message box instead.
5039

51-
```cpp
40+
// Check whether the user's computer supports `CTaskDialog`.
41+
// If not, display a Windows message box instead.
5242
if (CTaskDialog::IsSupported())
5343
{
54-
44+
CTaskDialog taskDialog(message, emptyString, dialogTitle, TDCBF_OK_BUTTON);
45+
taskDialog.SetMainIcon(TD_WARNING_ICON); // Set the icon to be the same as the Windows message box
46+
taskDialog.DoModal();
5547
}
5648
else
5749
{
5850
AfxMessageBox(message);
5951
}
6052
```
6153

62-
1. Insert the following code between the brackets after the **`if`** statement from step 5. This code creates the `CTaskDialog`.
63-
64-
```cpp
65-
CTaskDialog taskDialog(message, emptyString, dialogTitle, TDCBF_OK_BUTTON);
66-
```
67-
68-
1. On the next line, add the following code. This code sets the warning icon.
69-
70-
```cpp
71-
taskDialog.SetMainIcon(TD_WARNING_ICON);
72-
```
73-
74-
1. On the next line, add the following code. This code displays the task dialog box.
75-
76-
```cpp
77-
taskDialog.DoModal();
78-
```
79-
80-
You can avoid step 7 if you don't want the `CTaskDialog` to display the same icon as the Windows message box. If you avoid that step, the `CTaskDialog` has no icon when the application displays it.
81-
8254
Compile and run the application. The application displays the task dialog box after it starts.
8355

84-
## Adding Functionality to the CTaskDialog
85-
86-
The following procedure shows you how to add functionality to the `CTaskDialog` that you created in the previous procedure. The example code shows you how to execute specific instructions based on the user's selections.
87-
88-
### To Add Functionality to the CTaskDialog
56+
## Add functionality to the CTaskDialog
8957

90-
1. Navigate to the **Resource View**. If you can't see the **Resource View**, you can open it from the **View** menu.
58+
The following shows you how to add functionality to the `CTaskDialog` that you created in the previous procedure. The example code shows you how to execute specific instructions based on the user's selections.
9159

92-
1. Expand the **Resource View** until you can select the **String Table** folder. Expand it and double-click the **String Table** entry.
93-
94-
1. Scroll to the bottom of the string table and add a new entry. Change the ID to `TEMP_LINE1`. Set the caption to **Command Line 1**.
95-
96-
1. Add another new entry. Change the ID to `TEMP_LINE2`. Set the caption to **Command Line 2**.
97-
98-
1. Navigate back to MyProject.cpp.
99-
100-
1. After `CString emptyString;`, add the following code:
60+
1. Navigate to the **Resource View** via **View** > **Other Windows** > **Resource View**.
61+
1. Expand the **Resource View** to the **String Table** folder. Expand it and double-click **String Table**.
62+
1. Scroll to the bottom of the string table and add a new entry. Change the ID to `TEMP_LINE1`. Set the caption to `Command Line 1`.
63+
1. Add another new entry. Change the ID to `TEMP_LINE2`. Set the caption to `Command Line 2`.
64+
1. Navigate back to `MyProject.cpp`.
65+
1. In the `CMyProjectApp::InitInstance()` function, after `CString emptyString;` add the following code:
10166

10267
```cpp
10368
CString expandedLabel("Hide extra information");
@@ -109,67 +74,52 @@ The following procedure shows you how to add functionality to the `CTaskDialog`
10974

11075
```cpp
11176
taskDialog.SetMainInstruction(L"Warning");
112-
taskDialog.SetCommonButtons(
113-
TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);
77+
taskDialog.SetCommonButtons(TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);
11478
taskDialog.LoadCommandControls(TEMP_LINE1, TEMP_LINE2);
115-
taskDialog.SetExpansionArea(
116-
expansionInfo, collapsedLabel, expandedLabel);
79+
taskDialog.SetExpansionArea(expansionInfo, collapsedLabel, expandedLabel);
11780
taskDialog.SetFooterText(L"This is a small footnote to the user");
11881
taskDialog.SetVerificationCheckboxText(L"Remember your selection");
119-
```
120-
121-
1. Add the following line of code that displays the task dialog box to the user and retrieves the user's selection:
122-
123-
```cpp
12482
INT_PTR result = taskDialog.DoModal();
125-
```
126-
127-
1. Insert the following code after the call to `taskDialog.DoModal()`. This section of code processes the user's input:
12883

129-
```cpp
13084
if (taskDialog.GetVerificationCheckboxState())
13185
{
132-
// PROCESS IF the user selects the verification checkbox
86+
// Your code if the user selects the verification checkbox
13387
}
13488

13589
switch (result)
13690
{
137-
case TEMP_LINE1:
138-
// PROCESS IF the first command line
139-
break;
140-
case TEMP_LINE2:
141-
// PROCESS IF the second command line
142-
break;
143-
case IDYES:
144-
// PROCESS IF the user clicks yes
145-
break;
146-
case IDNO:
147-
// PROCESS IF the user clicks no
148-
break;
149-
case IDCANCEL:
150-
// PROCESS IF the user clicks cancel
151-
break;
152-
default:
153-
// This case should not be hit because closing
154-
// the dialog box results in IDCANCEL
155-
break;
91+
case TEMP_LINE1:
92+
// PROCESS IF the first command line
93+
break;
94+
case TEMP_LINE2:
95+
// PROCESS IF the second command line
96+
break;
97+
case IDYES:
98+
// PROCESS IF the user clicks yes
99+
break;
100+
case IDNO:
101+
// PROCESS IF the user clicks no
102+
break;
103+
case IDCANCEL:
104+
// PROCESS IF the user clicks cancel
105+
break;
106+
default:
107+
// This case should not be hit because closing
108+
// the dialog box results in IDCANCEL
109+
break;
156110
}
157111
```
158112

159-
In the code in step 9, replace the comments that start with `PROCESS IF` with the code that you want to execute under the specified conditions.
160-
161113
Compile and run the application. The application displays the task dialog box that uses the new controls and additional information.
162114

163115
## Displaying a CTaskDialog Without Creating a CTaskDialog Object
164116

165-
The following procedure shows you how to display a `CTaskDialog` without first creating a `CTaskDialog` object. This example continues the previous procedures.
117+
The following shows you how to display a `CTaskDialog` without first creating a `CTaskDialog` object. This example continues the previous procedures.
166118

167119
### To Display a CTaskDialog Without Creating a CTaskDialog Object
168120

169-
1. Open the MyProject.cpp file if it isn't already open.
170-
171-
1. Navigate to the closing bracket for the `if (CTaskDialog::IsSupported())` statement.
172-
121+
1. Open the `MyProject.cpp` file.
122+
1. In the `CMyProjectApp::InitInstance()` function, navigate to the closing bracket for the `if (CTaskDialog::IsSupported())` statement.
173123
1. Insert the following code immediately before the closing bracket of the **`if`** statement (before the **`else`** block):
174124

175125
```cpp
@@ -180,12 +130,12 @@ The following procedure shows you how to display a `CTaskDialog` without first c
180130
TEMP_LINE2);
181131
```
182132

183-
Compile and run the application. The application displays two task dialog boxes. The first dialog box is from the **To Add Functionality to the CTaskDialog** procedure; the second dialog box is from the last procedure.
133+
Compile and run the application. The application displays two task dialog boxes. The first dialog box is from the **To Add Functionality to the CTaskDialog** procedure; the second dialog box is from the previous procedure.
184134

185135
These examples don't demonstrate all the available options for a `CTaskDialog`, but should help you get started. See [CTaskDialog Class](../mfc/reference/ctaskdialog-class.md) for a full description of the class.
186136
187137
## See also
188138
189-
[Dialog Boxes](../mfc/dialog-boxes.md)<br/>
190-
[CTaskDialog Class](../mfc/reference/ctaskdialog-class.md)<br/>
139+
[Dialog Boxes](../mfc/dialog-boxes.md)\
140+
[CTaskDialog Class](../mfc/reference/ctaskdialog-class.md)\
191141
[CTaskDialog::CTaskDialog](../mfc/reference/ctaskdialog-class.md#ctaskdialog)

docs/preprocessor/check-stack.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
description: "Learn more about the check_stack pragma directive in Microsoft C/C++"
33
title: "check_stack pragma"
4-
ms.date: 01/22/2021
4+
ms.date: 2/7/2025
55
f1_keywords: ["vc-pragma.check_stack", "check_stack_CPP"]
6-
helpviewer_keywords: ["check_stack pragma", "pragma, check_stack", "pragma, check_stack usage table"]
6+
helpviewer_keywords: ["check_stack pragma", "pragma, check_stack"]
77
no-loc: ["pragma"]
88
---
99
# `check_stack` pragma
@@ -12,24 +12,24 @@ Instructs the compiler to turn off stack probes if **`off`** (or **`-`**) is spe
1212

1313
## Syntax
1414

15-
> **`#pragma check_stack(`** [{ **`on`** | **`off`** }] **`)`**\
15+
> **`#pragma check_stack(`** { **`on`** | **`off`** } **`)`**\
1616
> **`#pragma check_stack`** { **`+`** | **`-`** }
1717
1818
## Remarks
1919

20-
This pragma takes effect at the first function defined after the pragma is seen. Stack probes are neither a part of macros nor of functions that are generated inline.
20+
This pragma only applies to 32-bit platforms (x86, ARM32). It has no effect on 64-bit platforms.
2121

22-
If you don't give an argument for the **`check_stack`** pragma, stack checking reverts to the behavior specified on the command line. For more information, see [Compiler options](../build/reference/compiler-options.md). The interaction of the `#pragma check_stack` and the [`/Gs`](../build/reference/gs-control-stack-checking-calls.md) option is summarized in the following table.
22+
This pragma takes effect at the first function defined after the pragma is seen. Stack probes are not inserted for macros or functions that are generated inline.
2323

24-
### Using the check_stack Pragma
24+
`#pragma check_stack(off)` / `#pragma Check_stack-` is ignored if the size of the function locals is larger than 4096 or the value specified by `/Gs`.
2525

26-
| Syntax | Compiled with<br /><br /> `/Gs` option? | Action |
27-
|--|--|--|
28-
| `#pragma check_stack( )` or<br /><br /> `#pragma check_stack` | Yes | Turns off stack checking for functions that follow |
29-
| `#pragma check_stack( )` or<br /><br /> `#pragma check_stack` | No | Turns on stack checking for functions that follow |
30-
| `#pragma check_stack(on)`<br /><br /> or `#pragma check_stack +` | Yes or No | Turns on stack checking for functions that follow |
31-
| `#pragma check_stack(off)`<br /><br /> or `#pragma check_stack -` | Yes or No | Turns off stack checking for functions that follow |
26+
The default behavior of the compiler is to insert stack probes at the beginning of each function if the size of the locals exceeds 4096 or the value specified by `/Gs`.
27+
28+
Use [/Gs (Control stack checking calls)](../build/reference/gs-control-stack-checking-calls.md) to change the threshold of the locals that trigger stack probes. Use with caution.
29+
30+
Using `#pragma check_stack()` without arguments is deprecated.
3231

3332
## See also
3433

34+
[Compiler options](../build/reference/compiler-options.md)\
3535
[Pragma directives and the `__pragma` and `_Pragma` keywords](./pragma-directives-and-the-pragma-keyword.md)

docs/sanitizers/asan.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ This article covers the information you require to enable the three workflows li
8484
8585
## <a name="command-prompt"></a> Use AddressSanitizer from a developer command prompt
8686

87-
Use the **`/fsanitize=address`** compiler option in a [developer command prompt](../build/building-on-the-command-line.md#developer_command_prompt_shortcuts) to enable compiling for the AddressSanitizer runtime. The **`/fsanitize=address`** option is compatible with all existing C++ or C optimization levels (for example, `/Od`, `/O1`, `/O2`, `/O2 /GL`, and `PGO`). The option works with static and dynamic CRTs (for example, `/MD`, `/MDd`, `/MT`, and `/MTd`). It works whether you create an EXE or a DLL. Debug information is required for optimal formatting of call stacks. In the following example, `cl /fsanitize=address /Zi` is passed on the command line.
87+
Use the **`/fsanitize=address`** compiler option in a [developer command prompt](../build/building-on-the-command-line.md#developer_command_prompt_shortcuts) to enable compiling for the AddressSanitizer runtime. The **`/fsanitize=address`** option is compatible with existing C++ or C optimization levels (for example, `/Od`, `/O1`, `/O2`, and `/O2 /GL`). The option works with static and dynamic CRTs (for example, `/MD`, `/MDd`, `/MT`, and `/MTd`). It works whether you create an EXE or a DLL. Debug information is required for optimal formatting of call stacks. In the following example, `cl /fsanitize=address /Zi` is passed on the command line.
88+
89+
> [!NOTE]
90+
> AddressSanitizer doesn't support Profile-guided optimization (PGO). AddressSanitizer shouldn't be used in production.
8891
8992
The AddressSanitizer libraries (.lib files) are linked for you automatically. For more information, see [AddressSanitizer language, build, and debugging reference](asan-building.md).
9093

0 commit comments

Comments
 (0)