Skip to content

Migrate WinForms content #2076

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 23 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
updates
  • Loading branch information
adegeo committed May 2, 2025
commit a53cd61d2a7be8c153acc8d42fb089c1bfb1b657
8 changes: 7 additions & 1 deletion dotnet-desktop-guide/breadcrumb/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
items:
- name: Controls
tocHref: /dotnet/desktop/winforms/controls/
topicHref: /dotnet/desktop/winforms/controls/overview
topicHref: /dotnet/desktop/winforms/controls/index
- name: Design
tocHref: /dotnet/desktop/winforms/controls-design/
topicHref: /dotnet/desktop/winforms/controls-design/index
- name: Design
tocHref: /dotnet/desktop/winforms/advanced/
topicHref: /dotnet/desktop/winforms/advanced/index
- name: Windows Presentation Foundation
tocHref: /dotnet/desktop/wpf/
topicHref: /dotnet/desktop/wpf/index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ms.assetid: 15abda8b-0527-47c7-aedb-77ab595f2bf1
---
# Additional Security Considerations in Windows Forms

[!INCLUDE [net-framework-only](includes/net-framework-only.md)]

.NET Framework security settings might cause your application to run differently in a partial trust environment than on your local computer. The .NET Framework restricts access to such critical local resources as the file system, network, and unmanaged APIs, among other things. The security settings affect the ability to call the Microsoft Windows API or other APIs that cannot be verified by the security system. Security also affects other aspects of your application, including file and data access, and printing. For more information about file and data access in a partial trust environment, see [More Secure File and Data Access in Windows Forms](more-secure-file-and-data-access-in-windows-forms.md). For more information about printing in a partial trust environment, see [More Secure Printing in Windows Forms](more-secure-printing-in-windows-forms.md).

The following sections discuss how to work with the Clipboard, perform window manipulation, and call the Windows API from applications that are running in a partial trust environment.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Custom user-drawn controls
title: Custom owner-drawn controls
description: "Learn about how custom controls differ from user controls by not providing a visual design surface and relying on user-supplied code for drawing."
author: adegeo
ms.topic: overview #Don't change
Expand Down
6 changes: 3 additions & 3 deletions dotnet-desktop-guide/winforms/controls/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,9 @@ items:
href: ../controls-design/usercontrol-overview.md
- name: How to create a user control
href: ../controls-design/how-to-create-usercontrol.md
- name: Custom user-drawn controls
- name: Extend an existing control
href: ../controls-design/how-to-extend-existing.md
- name: Custom owner-drawn controls
items:
- name: What is a custom control?
href: ../controls-design/custom-controls-overview.md
Expand All @@ -1131,8 +1133,6 @@ items:
href: how-to-implement-a-custom-layout-engine.md
- name: Control properties
items:
- name: Extend an existing control
href: ../controls-design/how-to-extend-existing.md
- name: Defining a Property
href: defining-a-property-in-windows-forms-controls.md
- name: Property-Changed Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The .NET Framework 4.7 also adds a number of new helper methods and properties t

## Versioning considerations

In addition to running on .NET Framework 4.7 and Windows 10 Creators Update, your application may also run in an environment in which it isn't compatible with high DPI improvements. In this case, you'll need to develop a fallback for your application. You can do this to perform [custom drawing](./controls/user-drawn-controls.md) to handle scaling.
In addition to running on .NET Framework 4.7 and Windows 10 Creators Update, your application may also run in an environment in which it isn't compatible with high DPI improvements. In this case, you'll need to develop a fallback for your application. You can do this to perform [custom drawing](./controls-design/custom-controls-overview.md) to handle scaling.

To do this, you also need to determine the operating system on which your app is running. You can do that with code like the following:

Expand Down
10 changes: 10 additions & 0 deletions dotnet-desktop-guide/winforms/includes/net-framework-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
author: adegeo
ms.author: adegeo
ms.date: 05/01/2025
ms.service: dotnet-framework
ms.topic: include
---

> [!IMPORTANT]
> This content only applies to .NET Framework unless otherwise specified.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author: adegeo
ms.author: adegeo
ms.date: 06/15/2023
ms.date: 05/01/2025
ms.service: dotnet-framework
ms.topic: include
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ms.assetid: 3cd3e55b-2f5e-40dd-835d-f50f7ce08967
---
# More Secure File and Data Access in Windows Forms

[!INCLUDE [net-framework-only](includes/net-framework-only.md)]

The .NET Framework uses permissions to help protect resources and data. Where your application can read or write data depends on the permissions granted to the application. When your application runs in a partial trust environment, you might not have access to your data or you might have to change the way you access the data.

When you encounter a security restriction, you have two options: assert the permission (assuming it has been granted to your application), or use a version of the feature written to work in partial trust. The following sections discuss how to work with file, database, and registry access from applications that are running in a partial trust environment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ms.assetid: 48fd36ac-872f-4de0-902a-e52969cd4367
---
# More Secure Printing in Windows Forms

[!INCLUDE [net-framework-only](includes/net-framework-only.md)]

Windows Forms applications frequently include printing abilities. The .NET Framework uses the <xref:System.Drawing.Printing.PrintingPermission> class to control access to printing capabilities and the associated <xref:System.Drawing.Printing.PrintingPermissionLevel> enumeration value to indicate the level of access. By default, printing is enabled by default in the Local Intranet and Internet zones; however, the level of access is restricted in both zones. Whether your application can print, requires user interaction, or cannot print depends upon the permission value granted to the application. By default, the Local Intranet zone receives <xref:System.Drawing.Printing.PrintingPermissionLevel.DefaultPrinting> access and the Intranet zone receives <xref:System.Drawing.Printing.PrintingPermissionLevel.SafePrinting> access.

The following table shows the functionality available at each printing permission level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ms.assetid: 4810dc9f-ea23-4ce1-8ea1-657f0ff1d820
---
# Security in Windows Forms Overview

[!INCLUDE [net-framework-only](includes/net-framework-only.md)]

Before the release of the .NET Framework, all code running on a user's computer had the same rights or permissions to access resources that a user of the computer had. For example, if the user was allowed to access the file system, the code was allowed to access the file system; if the user was allowed to access a database, the code was allowed to access that database. Although these rights or permissions may be acceptable for code in executables that the user has explicitly installed on the local computer, they may not be acceptable for potentially malicious code coming from the Internet or a local Intranet. This code should not be able to access the user's computer resources without permission.

The .NET Framework introduces an infrastructure called Code Access Security that lets you differentiate the permissions, or rights, that code has from the rights that the user has. By default, code coming from the Internet and the Intranet can only run in what is known as partial trust. Partial trust subjects an application to a series of restrictions: among other things, an application is restricted from accessing the local hard disk, and cannot run unmanaged code. The .NET Framework controls the resources that code is allowed to access based on the identity of that code: where it came from, whether it has a [Strong-Named Assemblies](/dotnet/standard/assembly/strong-named), whether it is signed with a certificate, and so on.
Expand Down
2 changes: 2 additions & 0 deletions dotnet-desktop-guide/winforms/windows-forms-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ms.assetid: 932d438a-5285-46d8-a958-8c93d0ad6cae
---
# Windows Forms Security

[!INCLUDE [net-framework-only](includes/net-framework-only.md)]

Windows Forms features a security model that is code-based (security levels are set for code, regardless of the user running the code). This is in addition to any security schemas that may be in place already on your computer system. These can include those in the browser (such as the zone-based security available in Internet Explorer) or the operating system (such as the credential-based security of Windows NT).

## In This Section
Expand Down