Skip to content

Repo sync for protected branch #4822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/code-quality/c6201.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
---
description: "Learn more about: Warning C6201"
title: Warning C6201
ms.date: 09/28/2022
ms.date: 11/17/2023
f1_keywords: ["C6201", "INDEX_EXCEEDS_MAX", "__WARNING_INDEX_EXCEEDS_MAX"]
helpviewer_keywords: ["C6201"]
ms.assetid: eefbbd77-007c-4f28-95f6-6de5ee6a27db
---
# Warning C6201

> Index '*index-name*' is out of valid index range '*minimum*' to '*maximum*' for possibly stack allocated buffer '*variable*'

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

## Remarks

Expand Down Expand Up @@ -45,3 +44,9 @@ void f()
}
}
```

## Heuristics

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.

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.
26 changes: 21 additions & 5 deletions docs/mfc/setting-the-dialog-boxs-background-color.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
---
description: "Learn more about: Setting the Dialog Box's Background Color"
title: "Setting the Dialog Box's Background Color"
ms.date: "07/12/2018"
ms.date: 11/17/2023
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"]
ms.assetid: 05ee28a4-f3ae-4203-84ac-022f266ff2ab
---
# Setting the Dialog Box's Background Color

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

See [codexpert blog](https://codexpert.ro/blog/2013/03/13/painting-the-dialog-backround/) for an example.
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:

```cpp
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return (HBRUSH)GetStockObject(DKGRAY_BRUSH);
}
```

For the previous code fragment to work:
- add `virtual HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);` to the `protected:` section of the class definition for your dialog.
- add the following to the class definition for your dialog, and change `CMyDialog` to the name of your dialog class:

```cpp
BEGIN_MESSAGE_MAP(CMyDialog, CDialogEx)
ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
```

## See also

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