Skip to content

Commit

Permalink
Merge pull request #9388 from MicrosoftDocs/main638237631702801299syn…
Browse files Browse the repository at this point in the history
…c_temp

For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
  • Loading branch information
learn-build-service-prod[bot] authored Jun 30, 2023
2 parents ce39082 + 5f33a59 commit 0176da3
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 81 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Create a simple WCF Service in Windows Forms
description: In this walkthrough, create a Windows Communication Foundation (WCF) service in Visual Studio, test it, and then access it from a Windows Forms application.
ms.date: 11/04/2016
ms.date: 06/30/2023
ms.topic: conceptual
dev_langs:
- VB
Expand Down Expand Up @@ -117,31 +117,29 @@ The WCF tools are not installed with the .NET workload; use the Visual Studio In

### Reference the WCF service

1. On the **File** menu, point to **Add** and then click **New Project**.
1. On the **File** menu, point to **Add > New Project**. Choose **Windows Forms App (.NET Framework)** project.

2. In the **New Project** dialog box, expand the **Visual Basic** or **Visual C#** node, select **Windows**, and then select **Windows Forms Application**. Click **OK** to open the project.
1. Right-click on the project node, and click **Add > Service Reference**. The **Add Service Reference** dialog box appears.

![Windows Forms Application project](../data-tools/media/wcf7.png)
1. In the **Add Service Reference** dialog box, click **Discover**.

3. Right-click **WindowsApplication1** and click **Add Service Reference**. The **Add Service Reference** dialog box appears.

4. In the **Add Service Reference** dialog box, click **Discover**.

![The Add Service Reference dialog box](../data-tools/media/wcf8.png)
![Screenshot showing the Add Service Reference dialog box.](../data-tools/media/vs-2022/add-service-reference-dialog-box.png)

**Service1** displays in the **Services** pane.

5. Click **OK** to add the service reference.
1. Click **OK** to add the service reference.

### Build a client application

1. In **Solution Explorer**, double-click **Form1.vb** or **Form1.cs** to open the Windows Forms Designer if it is not already open.

2. From the **Toolbox**, drag a `TextBox` control, a `Label` control, and a `Button` control onto the form.
1. Open the **Toolbox** by clicking on **View** > **Toolbox** (or **Ctrl**+**Alt**+**X** on the keyboard).

1. From the **Toolbox**, drag a `TextBox` control, a `Label` control, and a `Button` control onto the form.

![Adding controls to the form](../data-tools/media/wcf9.png)
[ ![Screenshot showing adding controls to the form.](../data-tools/media/vs-2022/windows-communication-foundation-client-app.png) ](../data-tools/media/vs-2022/windows-communication-foundation-client-app.png#lightbox)

3. Double-click the `Button`, and add the following code in the `Click` event handler:
1. Double-click the `Button`, and add the following code in the `Click` event handler:

### [C#](#tab/csharp)
:::code language="csharp" source="../snippets/csharp/VS_Snippets_VBCSharp/wcfwalkthrough/cs/form1.cs" id="Snippet3":::
Expand All @@ -150,11 +148,11 @@ The WCF tools are not installed with the .NET workload; use the Visual Studio In
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_VBCSharp/wcfwalkthrough/vb/form1.vb" id="Snippet3":::
---

4. In **Solution Explorer**, right-click **WindowsApplication1** and click **Set as StartUp Project**.
1. In **Solution Explorer**, right-click the project node (for example, **WindowsFormsApp1**), and click **Set as StartUp Project**.

5. Press **F5** to run the project. Enter some text and click the button. The label displays "You entered:" and shows the text that you entered.
1. Press **F5** to run the project. Enter some text and click the button. The label displays "You entered:" and shows the text that you entered.

![The form showing the result](../data-tools/media/wcf10.png)
![Screenshot of the running form showing the result.](../data-tools/media/vs-2022/windows-forms-app.png)

## See also

Expand Down
8 changes: 4 additions & 4 deletions docs/designers/disable-dpi-awareness.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Fix DPI display issues in Windows Form Designer
description: Disable DPI awareness to fix scaling issues with Windows Forms Designer on HDPI monitors.
ms.date: 02/28/2023
ms.date: 06/29/2023
author: TerryGLee
ms.author: tglee
manager: jmartens
Expand All @@ -13,7 +13,7 @@ ms.custom: contperf-fy23q2; engagement-fy23

[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]

In this article, you learn how to address rendering issues due to scaling limitations of the Windows Forms Designer on HDPI monitors by [running Visual Studio as a DPI-unaware process](#restart-visual-studio-as-a-dpi-unaware-process). HDPI stands for high dots per inch, with each dot representing a physical device pixel.
In this article, you learn how to address rendering issues due to scaling limitations of the Windows Forms Designer on HDPI monitors by [running Visual Studio as a DPI-unaware process](#restart-visual-studio-as-a-dpi-unaware-process). HDPI stands for high dots per inch, with each dot representing a physical device pixel.

Higher pixel density creates sharper images, and display scaling sizes elements properly. Without proper scaling, user interface (UI) elements and text are too tiny to use effectively and can overlap. To help remedy this issue, Windows automatically scales the UI percentile to match the DPI setting. For example, a DPI setting of 100% represents 96 DPI and 125% is 120 DPI. Monitors used to ship with 96 pixels per inch, which Windows used as the baseline for 100% bitmap drawing. However, as display technology advanced, monitors now ship with panels of 300 DPI or higher.

Expand All @@ -23,15 +23,15 @@ When an application declares itself to be DPI-aware, it's a statement specifying

By default, Visual Studio is a dots per inch (DPI)-aware application, which means the display scales automatically. However, **Windows Forms Designer** is a DPI-unaware app, so it appears as a bitmap at 96 DPI. Without autoscaling support, issues and overlapping arises when opening forms on HDPI monitors, like in this image:

![Windows Forms Designer on HDPI monitor](./media/win-forms-designer-hdpi-1.gif)
![Screenshot of Windows Forms Designer on HDPI monitor that shows issues due to lack of autoscaling support.](./media/win-forms-designer-hdpi-1.gif)

When you open a form in **Windows Forms Designer** on an HDPI monitor, Visual Studio displays an info bar that displays the monitor's current scaling percentage (for example, 150%/144 DPI), an option to restart Visual Studio at 100% scaling to match Windows Forms Designer, and further information. Restarting at 100% scaling makes VS DPI-unaware, allowing for proper rendering without overlap.

:::image type="content" source="media/scaling-gold-bar-message-1.png" alt-text="Screenshot of the information bar in Visual Studio to restart in DPI-unaware mode.":::

> [!TIP]
> 1. If you closed the information bar and want to restart Visual Studio as DPI-unaware, [use the DevEnv.exe tool](#use-the-devenvexe-tool).
> 2. If you aren't working in the designer, you can ignore the information bar. You can also [disable notifications](#disable-notifications) so that the information bar doesn't continue to appear.
> 1. If you aren't working in the designer, you can ignore the information bar. You can also [disable notifications](#disable-notifications) so that the information bar doesn't continue to appear.
## Restart Visual Studio as a DPI-unaware process

Expand Down
Binary file modified docs/designers/media/scaling-gold-bar-message-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions docs/designers/scaling-percentage-display-setting-message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Scaling on your main display is set to X%
description: Learn about the scaling percentage settings message you see with Windows Forms Designer on HDPI monitors, and what to do next.
ms.date: 06/29/2023
ms.topic: ui-reference
author: TerryGLee
ms.author: tglee
manager: jmartens
ms.technology: vs-ide-designers
ms.workload:
- "multiple"
ms.custom: engagement-fy23
---
# Scaling on your main display is set to X%

[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]

When you open a form in **Windows Forms Designer** on an HDPI monitor, Visual Studio displays an information bar with a message that includes the monitor's current scaling percentage and an option to restart Visual Studio at 100% scaling. Restarting at 100% scaling allows for proper rendering without overlap.

:::image type="content" source="media/scaling-gold-bar-message-1.png" alt-text="Screenshot of the information bar in Visual Studio to restart in DPI-unaware mode.":::

## Why this message appears and what to do about it

Here's why the message appears:

- Windows Forms Designer is [DPI-unaware](disable-dpi-awareness.md#windows-forms-designer-is-dpi-unaware), while Visual Studio is DPI-aware.
- To accurately display Forms elements in the Designer, you can set Visual Studio to 100% scaling so that it, too, is DPI-unaware.
- When Visual Studio is set to 100% scaling, fonts might appear blurry and you might see issues in other designers, such as the XAML Designer, which are DPI-aware.

Here's what to do about it:

- Select the **Restart Visual Studio with 100% scaling** link in the message on the information bar to [restart Visual Studio as a DPI-unaware process](disable-dpi-awareness.md#restart-visual-studio-as-a-dpi-unaware-process), which means that it restarts at 100% scaling (96 DPI).
- You can also [set the scaling size in Windows](disable-dpi-awareness.md#use-windows-to-set-your-display-scaling-to-100) to 100%, but it can make the user interface (UI) too small to be usable.
- When Visual Studio runs as DPI-unaware, the designer layout issues are resolved. However, fonts might appear blurry and issues can appear in other designers such as the XAML Designer.
- If you've previously set Visual Studio to 100% scaling and want to re-enable DPI awareness, select the **Restart Visual Studio with automatic scaling** link in the information bar to restart Visual Studio as DPI-aware.

## Next steps

For more information about HDPI scaling issues and detailed, step-by-step instructions on how to fix them, see [HDPI/scaling issues with Windows Forms Designer in Visual Studio](disable-dpi-awareness.md).
Loading

0 comments on commit 0176da3

Please sign in to comment.