Skip to content

Commit 0eabe97

Browse files
authored
Merge pull request #5113 from MicrosoftDocs/main
11/20/2023 AM Publish
2 parents 1028bd0 + 9e2b472 commit 0eabe97

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

docs/code-quality/c6201.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
22
description: "Learn more about: Warning C6201"
33
title: Warning C6201
4-
ms.date: 09/28/2022
4+
ms.date: 11/17/2023
55
f1_keywords: ["C6201", "INDEX_EXCEEDS_MAX", "__WARNING_INDEX_EXCEEDS_MAX"]
66
helpviewer_keywords: ["C6201"]
7-
ms.assetid: eefbbd77-007c-4f28-95f6-6de5ee6a27db
87
---
98
# Warning C6201
109

1110
> Index '*index-name*' is out of valid index range '*minimum*' to '*maximum*' for possibly stack allocated buffer '*variable*'
1211
13-
This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array. It may potentially cause stack overflow errors, random behavior, or crashes.
12+
This warning indicates that an integer offset into the specified stack array exceeds the maximum bounds of that array. It might potentially cause stack overflow errors, undefined behavior, or crashes.
1413

1514
## Remarks
1615

@@ -45,3 +44,9 @@ void f()
4544
}
4645
}
4746
```
47+
48+
## Heuristics
49+
50+
This analysis is limited to stack-allocated arrays. It doesn't consider, for example, arrays passed into the function with a Microsoft source code annotation language ([SAL](understanding-sal.md))-annotated length.
51+
52+
This analysis can't catch all possible out of bounds indices because not all arithmetic can be precisely analyzed. It's tuned to report cases where it can guarantee an out of bounds index is possible. The absence of a warning doesn't mean the index is guaranteed to be in bounds.
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
11
---
22
description: "Learn more about: Setting the Dialog Box's Background Color"
33
title: "Setting the Dialog Box's Background Color"
4-
ms.date: "07/12/2018"
4+
ms.date: 11/17/2023
55
helpviewer_keywords: ["CSS, background attributes in styles [MFC]", "HTML element formatting, background attributes", "colors, dialog box", "dialog boxes [MFC], colors", "background colors, dialog boxes", "MFC dialog boxes [MFC], colors"]
6-
ms.assetid: 05ee28a4-f3ae-4203-84ac-022f266ff2ab
76
---
87
# Setting the Dialog Box's Background Color
98

10-
You can set the background color of your dialog boxes by handling WM_CTLCOLOR messages for the dialog box window. The color you set is used for only the specified dialog box.
9+
You can set the background color of your dialog boxes by handling `WM_CTLCOLOR` messages for the dialog box window. The color you set is used for only the specified dialog box.
1110

12-
See [codexpert blog](https://codexpert.ro/blog/2013/03/13/painting-the-dialog-backround/) for an example.
11+
For example, the following code fragment sets the background color of the dialog box to dark grey. The `OnCtlColor` member function is called whenever the dialog box is redrawn:
12+
13+
```cpp
14+
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
15+
{
16+
return (HBRUSH)GetStockObject(DKGRAY_BRUSH);
17+
}
18+
```
19+
20+
For the previous code fragment to work:
21+
- add `virtual HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);` to the `protected:` section of the class definition for your dialog.
22+
- add the following to the class definition for your dialog, and change `CMyDialog` to the name of your dialog class:
23+
24+
```cpp
25+
BEGIN_MESSAGE_MAP(CMyDialog, CDialogEx)
26+
ON_WM_CTLCOLOR()
27+
END_MESSAGE_MAP()
28+
```
1329

1430
## See also
1531

16-
[Working with Dialog Boxes in MFC](../mfc/life-cycle-of-a-dialog-box.md)<br/>
32+
[Working with Dialog Boxes in MFC](../mfc/life-cycle-of-a-dialog-box.md)\
1733
[Handling Windows Messages in Your Dialog Box](../mfc/handling-windows-messages-in-your-dialog-box.md)

0 commit comments

Comments
 (0)