mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 23:43:07 +02:00
Links: .NET Desktop - framework\winforms (#108)
This commit is contained in:
+10
-2
@@ -9,6 +9,7 @@ helpviewer_keywords:
|
||||
ms.assetid: c8eb2ad0-fac6-4ea2-9140-675a4a44d562
|
||||
---
|
||||
# Application Settings Architecture
|
||||
|
||||
This topic describes how the Application Settings architecture works, and explores advanced features of the architecture, such as grouped settings and settings keys.
|
||||
|
||||
The application settings architecture supports defining strongly typed settings with either application or user scope, and persisting the settings between application sessions. The architecture provides a default persistence engine for saving settings to and loading them from the local file system. The architecture also defines interfaces for supplying a custom persistence engine.
|
||||
@@ -16,6 +17,7 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
Interfaces are provided that enable custom components to persist their own settings when they are hosted in an application. By using settings keys, components can keep settings for multiple instances of the component separate.
|
||||
|
||||
## Defining Settings
|
||||
|
||||
The application settings architecture is used within both ASP.NET and Windows Forms, and it contains a number of base classes that are shared across both environments. The most important is <xref:System.Configuration.SettingsBase>, which provides access to settings through a collection, and provides low-level methods for loading and saving settings. Each environment implements its own class derived from <xref:System.Configuration.SettingsBase> to provide additional settings functionality for that environment. In a Windows Forms-based application, all application settings must be defined on a class derived from the <xref:System.Configuration.ApplicationSettingsBase> class, which adds the following functionality to the base class:
|
||||
|
||||
- Higher-level loading and saving operations
|
||||
@@ -36,6 +38,7 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
[!code-vb[ApplicationSettings.Create#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/ApplicationSettings.Create/VB/MyAppSettings.vb#1)]
|
||||
|
||||
## Settings Persistence
|
||||
|
||||
The <xref:System.Configuration.ApplicationSettingsBase> class does not itself persist or load settings; this job falls to the settings provider, a class that derives from <xref:System.Configuration.SettingsProvider>. If a derived class of <xref:System.Configuration.ApplicationSettingsBase> does not specify a settings provider through the <xref:System.Configuration.SettingsProviderAttribute>, then the default provider, <xref:System.Configuration.LocalFileSettingsProvider>, is used.
|
||||
|
||||
The configuration system that was originally released with the .NET Framework supports providing static application configuration data through either the local computer's machine.config file or within an `app.`exe.config file that you deploy with your application. The <xref:System.Configuration.LocalFileSettingsProvider> class expands this native support in the following ways:
|
||||
@@ -82,9 +85,10 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
</configuration>
|
||||
```
|
||||
|
||||
For a definition of the elements within the application settings section of a configuration file, see [Application Settings Schema](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/application-settings-schema).
|
||||
For a definition of the elements within the application settings section of a configuration file, see [Application Settings Schema](/dotnet/framework/configure-apps/file-schema/application-settings-schema).
|
||||
|
||||
### Settings Bindings
|
||||
|
||||
Application settings uses the Windows Forms data binding architecture to provide two-way communication of settings updates between the settings object and components. If you use Visual Studio to create application settings and assign them to component properties, these bindings are generated automatically.
|
||||
|
||||
You can only bind an application setting to a component that supports the <xref:System.Windows.Forms.IBindableComponent> interface. Also, the component must implement a change event for a specific bound property, or notify application settings that the property has changed through the <xref:System.ComponentModel.INotifyPropertyChanged> interface. If the component does not implement <xref:System.Windows.Forms.IBindableComponent> and you are binding through Visual Studio, the bound properties will be set the first time, but will not update. If the component implements <xref:System.Windows.Forms.IBindableComponent> but does not support property change notifications, the binding will not update in the settings file when the property is changed.
|
||||
@@ -92,6 +96,7 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
Some Windows Forms components, such as <xref:System.Windows.Forms.ToolStripItem>, do not support settings bindings.
|
||||
|
||||
### Settings Serialization
|
||||
|
||||
When <xref:System.Configuration.LocalFileSettingsProvider> must save settings to disk, it performs the following actions:
|
||||
|
||||
1. Uses reflection to examine all of the properties defined on your <xref:System.Configuration.ApplicationSettingsBase> derived class, finding those that are applied with either <xref:System.Configuration.ApplicationScopedSettingAttribute> or <xref:System.Configuration.UserScopedSettingAttribute>.
|
||||
@@ -103,6 +108,7 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
If you implement your own settings class, you can use the <xref:System.Configuration.SettingsSerializeAsAttribute> to mark a setting for either binary or custom serialization using the <xref:System.Configuration.SettingsSerializeAs> enumeration. For more information on creating your own settings class in code, see [How to: Create Application Settings](how-to-create-application-settings.md).
|
||||
|
||||
### Settings File Locations
|
||||
|
||||
The location of the `app`.exe.config and *user*.config files will differ based on how the application is installed. For a Windows Forms-based application copied onto the local computer, `app`.exe.config will reside in the same directory as the base directory of the application's main executable file, and *user*.config will reside in the location specified by the <xref:System.Windows.Forms.Application.LocalUserAppDataPath%2A?displayProperty=nameWithType> property. For an application installed by means of ClickOnce, both of these files will reside in the ClickOnce Data Directory underneath %InstallRoot%\Documents and Settings\\*username*\Local Settings.
|
||||
|
||||
The storage location of these files is slightly different if a user has enabled roaming profiles, which enables a user to define different Windows and application settings when they are using other computers within a domain. In that case, both ClickOnce applications and non-ClickOnce applications will have their `app`.exe.config and *user*.config files stored under %InstallRoot%\Documents and Settings\\*username*\Application Data.
|
||||
@@ -110,11 +116,13 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
For more information about how the Application Settings feature works with the new deployment technology, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings). For more information about the ClickOnce Data Directory, see [Accessing Local and Remote Data in ClickOnce Applications](/visualstudio/deployment/accessing-local-and-remote-data-in-clickonce-applications).
|
||||
|
||||
## Application Settings and Security
|
||||
|
||||
Application settings are designed to work in partial trust, a restricted environment that is the default for Windows Forms applications hosted over the Internet or an intranet. No special permissions beyond partial trust are needed to use application settings with the default settings provider.
|
||||
|
||||
When application settings are used in a ClickOnce application, the `user`.config file is stored in the ClickOnce data directory. The size of the application's `user`.config file cannot exceed the data directory quota set by ClickOnce. For more information, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings).
|
||||
|
||||
## Custom Settings Providers
|
||||
|
||||
In the Application Settings architecture, there is a loose coupling between the applications settings wrapper class, derived from <xref:System.Configuration.ApplicationSettingsBase>, and the associated settings provider or providers, derived from <xref:System.Configuration.SettingsProvider>. This association is defined only by the <xref:System.Configuration.SettingsProviderAttribute> applied to the wrapper class or its individual properties. If a settings provider is not explicitly specified, the default provider, <xref:System.Configuration.LocalFileSettingsProvider>, is used. As a result, this architecture supports creating and using custom settings providers.
|
||||
|
||||
For example, suppose that you want to develop and use `SqlSettingsProvider`, a provider that will store all settings data in a Microsoft SQL Server database. Your <xref:System.Configuration.SettingsProvider>-derived class would receive this information in its `Initialize` method as a parameter of type <xref:System.Collections.Specialized.NameValueCollection?displayProperty=nameWithType>. You would then implement the <xref:System.Configuration.SettingsProvider.GetPropertyValues%2A> method to retrieve your settings from the data store, and <xref:System.Configuration.SettingsProvider.SetPropertyValues%2A> to save them. Your provider can use the <xref:System.Configuration.SettingsPropertyCollection> supplied to <xref:System.Configuration.SettingsProvider.GetPropertyValues%2A> to determine the property's name, type, and scope, as well as any other settings attributes defined for that property.
|
||||
@@ -148,4 +156,4 @@ This topic describes how the Application Settings architecture works, and explor
|
||||
- [Application Settings Overview](application-settings-overview.md)
|
||||
- [Application Settings for Custom Controls](application-settings-for-custom-controls.md)
|
||||
- [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings)
|
||||
- [Application Settings Schema](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/application-settings-schema)
|
||||
- [Application Settings Schema](/dotnet/framework/configure-apps/file-schema/application-settings-schema)
|
||||
|
||||
+3
-1
@@ -9,9 +9,11 @@ helpviewer_keywords:
|
||||
ms.assetid: 64090a34-8556-4904-8ea0-20efe9f8c886
|
||||
---
|
||||
# Application Settings for Windows Forms
|
||||
|
||||
The Applications Settings feature of Windows Forms makes it easy to create, store, and maintain custom application and user preferences on the client. With Application Settings, you can store not only application data such as database connection strings, but also user-specific data, such as toolbar positions and most-recently used lists.
|
||||
|
||||
## In This Section
|
||||
|
||||
[Application Settings Overview](application-settings-overview.md)
|
||||
Discusses how to create and store settings data on behalf of your application and your users.
|
||||
|
||||
@@ -32,7 +34,7 @@ The Applications Settings feature of Windows Forms makes it easy to create, stor
|
||||
|
||||
## Related topics
|
||||
|
||||
[Windows Forms Configuration Section](https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/winforms/index)
|
||||
[Windows Forms Configuration Section](/dotnet/framework/configure-apps/file-schema/winforms/index)
|
||||
Documents the settings to enable High DPI support in Windows Forms Application starting with the .NET Framework 4.7.
|
||||
|
||||
## See also
|
||||
|
||||
@@ -18,7 +18,8 @@ This article discusses how to create and store settings data on behalf of your a
|
||||
|
||||
Application settings enables developers to save state in their application using very little custom code, and is a replacement for dynamic properties in previous versions of the .NET Framework. Application settings contains many improvements over dynamic properties, which are read-only, late-bound, and require more custom programming. The dynamic property classes have been retained in .NET Framework 2.0, but they are just shell classes that thinly wrap the application settings classes.
|
||||
|
||||
## What Are Application Settings?
|
||||
## What Are Application Settings
|
||||
|
||||
Your Windows Forms applications will often require data that's critical to running the application, but which you don't want to include directly in the application's code. If your application uses a Web Service or a database server, you may want to store this information in a separate file, so that you can change it in the future without recompiling. Similarly, your applications may require storing data that is specific to the current user. Most applications, for example, have user preferences that customize the application's appearance and behavior.
|
||||
|
||||
Application settings addresses both needs by providing an easy way to store both application-scoped and user-scoped settings on the client computer. Using Visual Studio or a code editor, you define a setting for a given property by specifying its name, data type, and scope (application or user). You can even place related settings into named groups for easier use and readability. Once defined, these settings are persisted and read back into memory automatically at run time. A pluggable architecture enables the persistence mechanism to be changed, but by default, the local file system is used.
|
||||
@@ -30,13 +31,15 @@ This article discusses how to create and store settings data on behalf of your a
|
||||
Custom controls can also save their own settings by implementing the <xref:System.Configuration.IPersistComponentSettings> interface, which exposes the <xref:System.Configuration.IPersistComponentSettings.SaveSettings%2A> method. The Windows Forms <xref:System.Windows.Forms.ToolStrip> control implements this interface to save the position of toolbars and toolbar items between application sessions. For more information about custom controls and application settings, see [Application Settings for Custom Controls](application-settings-for-custom-controls.md).
|
||||
|
||||
## Limitations of Application Settings
|
||||
|
||||
You cannot use application settings in an unmanaged application that hosts the .NET Framework. Settings will not work in such environments as Visual Studio add-ins, C++ for Microsoft Office, control hosting in Internet Explorer, or Microsoft Outlook add-ins and projects.
|
||||
|
||||
You currently cannot bind to some properties in Windows Forms. The most notable example is the <xref:System.Windows.Forms.Form.ClientSize%2A> property, as binding to this property would cause unpredictable behavior at run time. You can usually work around these issues by saving and loading these settings programmatically.
|
||||
|
||||
Application settings has no built-in facility for encrypting information automatically. You should never store security-related information, such as database passwords, in clear text. If you want to store such sensitive information, you as the application developer are responsible for making sure it is secure. If you want to store connection strings, we recommend that you use Windows Integrated Security and not resort to hard-coding passwords into the URL. For more information, see [Code Access Security and ADO.NET](https://docs.microsoft.com/dotnet/framework/data/adonet/code-access-security).
|
||||
Application settings has no built-in facility for encrypting information automatically. You should never store security-related information, such as database passwords, in clear text. If you want to store such sensitive information, you as the application developer are responsible for making sure it is secure. If you want to store connection strings, we recommend that you use Windows Integrated Security and not resort to hard-coding passwords into the URL. For more information, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security).
|
||||
|
||||
## Getting Started with Application Settings
|
||||
|
||||
If you use Visual Studio, you can define settings within the Windows Forms Designer using the **(ApplicationSettings)** property in the **Properties** window. When you define settings this way, Visual Studio automatically creates a custom managed wrapper class that associates each setting with a class property. Visual Studio also takes care of binding the setting to a property on a form or control so that the control's settings are restored automatically when its form is displayed, and saved automatically when the form is closed.
|
||||
|
||||
If you want more detailed control over your settings, you can define your own custom applications settings wrapper class. This is accomplished by deriving a class from <xref:System.Configuration.ApplicationSettingsBase>, adding a property that corresponds to each setting, and applying special attributes to these properties. For details about creating wrapper classes, see [Application Settings Architecture](application-settings-architecture.md).
|
||||
|
||||
+10
-2
@@ -9,13 +9,16 @@ helpviewer_keywords:
|
||||
- "Windows Forms, bi-directional support"
|
||||
---
|
||||
# Bi-Directional Support for Windows Forms Applications
|
||||
|
||||
You can use Visual Studio to create Windows-based applications that support bi-directional (right-to-left) languages such as Arabic and Hebrew. This includes standard forms, dialog boxes, MDI forms, and all the controls you can work with in these forms—that is, all the objects in the <xref:System.Windows.Forms.Control> namespace.
|
||||
|
||||
## Culture Support
|
||||
|
||||
Culture and UI culture settings determine how an application works with dates, times, currency, and other information. Support for culture and UI culture is the same for bi-directional languages as it is for any other languages. For more information, see [Culture-specific classes for global Windows forms and web forms](/visualstudio/ide/globalizing-and-localizing-applications).
|
||||
|
||||
## RightToLeft and RightToLeftLayout Properties
|
||||
The base <xref:System.Windows.Forms.Control> class, from which forms derive, includes a <xref:System.Windows.Forms.Control.RightToLeft%2A> property that you can set to change the reading order of a form and its controls. If you set the form's <xref:System.Windows.Forms.Control.RightToLeft%2A> property, by default controls on the form inherit this setting. However, you can also set the <xref:System.Windows.Forms.Control.RightToLeft%2A> property individually on most controls. Also see [How to: Display Right-to-Left Text in Windows Forms for Globalization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)).
|
||||
|
||||
The base <xref:System.Windows.Forms.Control> class, from which forms derive, includes a <xref:System.Windows.Forms.Control.RightToLeft%2A> property that you can set to change the reading order of a form and its controls. If you set the form's <xref:System.Windows.Forms.Control.RightToLeft%2A> property, by default controls on the form inherit this setting. However, you can also set the <xref:System.Windows.Forms.Control.RightToLeft%2A> property individually on most controls. Also see [How to: Display Right-to-Left Text in Windows Forms for Globalization](/previous-versions/visualstudio/visual-studio-2010/7d3337xw(v=vs.100)).
|
||||
|
||||
The effect of the <xref:System.Windows.Forms.Control.RightToLeft%2A> property can differ from one control to another. In some controls the property only sets the reading order, as in the <xref:System.Windows.Forms.Button>, <xref:System.Windows.Forms.TreeView> and <xref:System.Windows.Forms.ToolTip> controls. In other controls, the <xref:System.Windows.Forms.Control.RightToLeft%2A> property changes both reading order and layout. This includes the <xref:System.Windows.Forms.RadioButton>, <xref:System.Windows.Forms.ComboBox> and <xref:System.Windows.Forms.CheckBox> controls. Other controls require that the <xref:System.Windows.Forms.Form.RightToLeftLayout%2A> property be applied to mirror its layout from right to left. The following table provides details on how the <xref:System.Windows.Forms.Control.RightToLeft%2A> and <xref:System.Windows.Forms.Form.RightToLeftLayout%2A> properties affect individual Windows Forms controls.
|
||||
|
||||
@@ -71,22 +74,27 @@ You can use Visual Studio to create Windows-based applications that support bi-d
|
||||
|<xref:System.Windows.Forms.VScrollBar>|Displayed on the left side instead of right side of scrollable controls|No effect|No|
|
||||
|
||||
## Encoding
|
||||
|
||||
Windows Forms support Unicode, so you can include any character set when you create your bi-directional applications. However, not all Windows Forms controls support Unicode on all platforms.
|
||||
|
||||
## GDI+
|
||||
|
||||
You can use GDI+ to draw text with right-to-left reading order. The <xref:System.Drawing.Graphics.DrawString%2A> method, which is used to draw text, supports a `StringFormat` parameter that you can set to the <xref:System.Drawing.StringFormatFlags.DirectionRightToLeft> member of the <xref:System.Drawing.StringFormatFlags> enumeration in order to reverse the point of origin for the text.
|
||||
|
||||
## Common Dialog Boxes
|
||||
|
||||
System tools such as the File Open dialog box are under the control of Windows. They inherit language elements from the operating system. If you are using a version of Windows with the correct language settings, these dialog boxes will work correctly with bi-directional languages.
|
||||
|
||||
Similarly, message boxes go through the operating system and support bi-directional text. The captions on message box buttons are based on the current language setting. By default, message boxes do not use right-to-left reading order, but you can specify a parameter to change the reading order when the message boxes are displayed.
|
||||
|
||||
## RightToLeft, Scrollbars, and ScrollableControl
|
||||
|
||||
There is currently a limitation in Windows Forms that prevents all classes derived from <xref:System.Windows.Forms.ScrollableControl> from acting properly when both <xref:System.Windows.Forms.Control.RightToLeft%2A> is enabled and <xref:System.Windows.Forms.ScrollableControl.AutoScroll%2A> is set to <xref:System.Windows.Forms.RightToLeft.Yes>. For example, let's say that you place a control such as <xref:System.Windows.Forms.Panel>—or a container class derived from <xref:System.Windows.Forms.Panel> (such as <xref:System.Windows.Forms.FlowLayoutPanel> or <xref:System.Windows.Forms.TableLayoutPanel>)—on your form. If you set <xref:System.Windows.Forms.ScrollableControl.AutoScroll%2A> on the container to <xref:System.Windows.Forms.RightToLeft.Yes> and then set the <xref:System.Windows.Forms.Control.Anchor%2A> property on one or more of the controls inside of the container to <xref:System.Windows.Forms.AnchorStyles.Right>, then no scrollbar ever appears. The class derived from <xref:System.Windows.Forms.ScrollableControl> acts as if <xref:System.Windows.Forms.ScrollableControl.AutoScroll%2A> were set to <xref:System.Windows.Forms.RightToLeft.No>.
|
||||
|
||||
Currently, the only workaround is to nest the <xref:System.Windows.Forms.ScrollableControl> inside another <xref:System.Windows.Forms.ScrollableControl>. For instance, if you need <xref:System.Windows.Forms.TableLayoutPanel> to work in this situation, you can place it inside of a <xref:System.Windows.Forms.Panel> control and set <xref:System.Windows.Forms.ScrollableControl.AutoScroll%2A> on the <xref:System.Windows.Forms.Panel> to <xref:System.Windows.Forms.RightToLeft.Yes>.
|
||||
|
||||
## Mirroring
|
||||
|
||||
*Mirroring* refers to reversing the layout of UI elements so that they flow from right to left. In a mirrored Windows Form, for example, the Minimize, Maximize, and Close buttons appear left-most on the title bar, not right-most.
|
||||
|
||||
Setting a form or control's <xref:System.Windows.Forms.Control.RightToLeft%2A> property to `true` reverses the reading order of elements on a form, but this setting does not reverse the layout to be right-to-left— that is, it does not cause mirroring. For example, setting this property does not move the **Minimize**, **Maximize**, and **Close** buttons in the form's title bar to the left side of the form. Similarly, some controls, such as the <xref:System.Windows.Forms.TreeView> control, require mirroring in order to change their display to be appropriate for Arabic or Hebrew. You can mirror these controls by settings the <xref:System.Windows.Forms.Form.RightToLeftLayout%2A> property.
|
||||
@@ -111,4 +119,4 @@ You can use Visual Studio to create Windows-based applications that support bi-d
|
||||
|
||||
## See also
|
||||
|
||||
- [Bidirectional Support for ASP.NET Web Applications](https://docs.microsoft.com/previous-versions/aspnet/6eedwbtt(v=vs.100))
|
||||
- [Bidirectional Support for ASP.NET Web Applications](/previous-versions/aspnet/6eedwbtt(v=vs.100))
|
||||
|
||||
+3
-1
@@ -10,6 +10,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 87aac8ad-3c04-43b3-9b0c-d0b00df9ee74
|
||||
---
|
||||
# How to: Support COM Interop by Displaying a Windows Form with the ShowDialog Method
|
||||
|
||||
You can resolve Component Object Model (COM) interoperability problems by displaying your Windows Form on a .NET Framework message loop, which is created by using the <xref:System.Windows.Forms.Application.Run%2A?displayProperty=nameWithType> method.
|
||||
|
||||
To make a form work correctly from a COM client application, you must run it on a Windows Forms message loop. To do this, use one of the following approaches:
|
||||
@@ -19,6 +20,7 @@ You can resolve Component Object Model (COM) interoperability problems by displa
|
||||
- Display each Windows Form on a separate thread. For more information, see [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md).
|
||||
|
||||
## Procedure
|
||||
|
||||
Using the <xref:System.Windows.Forms.Form.ShowDialog%2A?displayProperty=nameWithType> method can be the easiest way to display a form on a .NET Framework message loop because, of all the approaches, it requires the least code to implement.
|
||||
|
||||
The <xref:System.Windows.Forms.Form.ShowDialog%2A?displayProperty=nameWithType> method suspends the unmanaged application's message loop and displays the form as a dialog box. Because the host application's message loop has been suspended, the <xref:System.Windows.Forms.Form.ShowDialog%2A?displayProperty=nameWithType> method creates a new .NET Framework message loop to process the form's messages.
|
||||
@@ -33,6 +35,6 @@ You can resolve Component Object Model (COM) interoperability problems by displa
|
||||
|
||||
## See also
|
||||
|
||||
- [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md)
|
||||
- [Windows Forms and Unmanaged Applications](windows-forms-and-unmanaged-applications.md)
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ Modifications made to the base form at run time have no affect on inherited form
|
||||
|
||||
## See also
|
||||
|
||||
- [base](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/base)
|
||||
- [base](/dotnet/csharp/language-reference/keywords/base)
|
||||
- [How to: Inherit Windows Forms](how-to-inherit-windows-forms.md)
|
||||
- [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md)
|
||||
|
||||
@@ -27,7 +27,7 @@ Introduces the `ImeMode` property, which is used to control the type of input a
|
||||
|
||||
## Related sections
|
||||
|
||||
- [Globalizing and localizing .NET applications](https://docs.microsoft.com/dotnet/standard/globalization-localization/index)
|
||||
- [Globalizing and localizing .NET applications](/dotnet/standard/globalization-localization/index)
|
||||
|
||||
- [Walkthrough: Downloading Satellite Assemblies on Demand with the ClickOnce Deployment API Using the Designer](/visualstudio/deployment/walkthrough-downloading-satellite-assemblies-on-demand-with-the-clickonce-deployment-api-using-the-designer)
|
||||
|
||||
@@ -35,12 +35,12 @@ Introduces the `ImeMode` property, which is used to control the type of input a
|
||||
|
||||
- [Walkthrough: Downloading Satellite Assemblies on Demand with the ClickOnce Deployment API](/visualstudio/deployment/walkthrough-downloading-satellite-assemblies-on-demand-with-the-clickonce-deployment-api)
|
||||
|
||||
- [How to: Set the Culture and UI Culture for Windows Forms Globalization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/b28bx3bh(v=vs.100))
|
||||
- [How to: Set the Culture and UI Culture for Windows Forms Globalization](/previous-versions/visualstudio/visual-studio-2010/b28bx3bh(v=vs.100))
|
||||
|
||||
- [How to: Create Mirrored Windows Forms and Controls](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/xwbz5ws0(v=vs.100))
|
||||
- [How to: Create Mirrored Windows Forms and Controls](/previous-versions/visualstudio/visual-studio-2010/xwbz5ws0(v=vs.100))
|
||||
|
||||
- [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100))
|
||||
- [How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control](/previous-versions/visualstudio/visual-studio-2010/1zkt8b33(v=vs.100))
|
||||
|
||||
- [Walkthrough: Localizing Windows Forms](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100))
|
||||
- [Walkthrough: Localizing Windows Forms](/previous-versions/visualstudio/visual-studio-2010/y99d1cd3(v=vs.100))
|
||||
|
||||
- [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100))
|
||||
- [Walkthrough: Creating a Layout That Adjusts Proportion for Localization](/previous-versions/visualstudio/visual-studio-2010/7k9fa71y(v=vs.100))
|
||||
|
||||
+1
-1
@@ -39,6 +39,6 @@ This procedure shows you how to copy a Windows Presentation Foundation (WPF) con
|
||||
|
||||
- <xref:System.Windows.Forms.Integration.ElementHost>
|
||||
- <xref:System.Windows.Forms.Integration.WindowsFormsHost>
|
||||
- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Using WPF Controls](using-wpf-controls.md)
|
||||
- [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio)
|
||||
|
||||
+3
-1
@@ -10,11 +10,12 @@ helpviewer_keywords:
|
||||
ms.assetid: 1e7aa347-af75-41e5-89ca-f53cab704f72
|
||||
---
|
||||
# How to: Create Application Settings
|
||||
|
||||
Using managed code, you can create new application settings and bind them to properties on your form or your form's controls, so that these settings are loaded and saved automatically at run time.
|
||||
|
||||
In the following procedure, you manually create a wrapper class that derives from <xref:System.Configuration.ApplicationSettingsBase>. To this class you add a publicly accessible property for each application setting that you want to expose.
|
||||
|
||||
You can also perform this procedure using minimal code in the Visual Studio designer. Also see [How to: Create Application Settings Using the Designer](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/wabtadw6(v=vs.100)).
|
||||
You can also perform this procedure using minimal code in the Visual Studio designer. Also see [How to: Create Application Settings Using the Designer](/previous-versions/visualstudio/visual-studio-2010/wabtadw6(v=vs.100)).
|
||||
|
||||
### To create new Application Settings programmatically
|
||||
|
||||
@@ -38,6 +39,7 @@ Using managed code, you can create new application settings and bind them to pro
|
||||
You have now successfully created a new application setting and bound it to the specified property.
|
||||
|
||||
## .NET Framework Security
|
||||
|
||||
The default settings provider, <xref:System.Configuration.LocalFileSettingsProvider>, persists information to configuration files as plain text. This limits security to the file access security provided by the operating system for the current user. Because of this, care must be taken with the information stored in configuration files. For example, one common use for application settings is to store connection strings that point to the application's data store. However, because of security concerns, such strings should not include passwords. For more information about connection strings, see <xref:System.Configuration.SpecialSetting>.
|
||||
|
||||
## See also
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ The easiest way to inherit a form or other object is to use the **Inheritance Pi
|
||||
|
||||
## See also
|
||||
|
||||
- [Inherits Statement](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/inherits-statement)
|
||||
- [using](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/using)
|
||||
- [Inherits Statement](/dotnet/visual-basic/language-reference/statements/inherits-statement)
|
||||
- [using](/dotnet/csharp/language-reference/keywords/using)
|
||||
- [Effects of Modifying a Base Form's Appearance](effects-of-modifying-base-form-appearance.md)
|
||||
- [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md)
|
||||
|
||||
@@ -34,12 +34,12 @@ For more information about inheriting forms at design time using the **Inheritan
|
||||
public class Form2 : Namespace1.Form1
|
||||
```
|
||||
|
||||
When inheriting forms, keep in mind that issues may arise with regard to event handlers being called twice, because each event is being handled by both the base class and the inherited class. For more information on how to avoid this problem, see [Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers).
|
||||
When inheriting forms, keep in mind that issues may arise with regard to event handlers being called twice, because each event is being handled by both the base class and the inherited class. For more information on how to avoid this problem, see [Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers).
|
||||
|
||||
## See also
|
||||
|
||||
- [Inherits Statement](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/inherits-statement)
|
||||
- [Imports Statement (.NET Namespace and Type)](https://docs.microsoft.com/dotnet/visual-basic/language-reference/statements/imports-statement-net-namespace-and-type)
|
||||
- [using](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/using)
|
||||
- [Inherits Statement](/dotnet/visual-basic/language-reference/statements/inherits-statement)
|
||||
- [Imports Statement (.NET Namespace and Type)](/dotnet/visual-basic/language-reference/statements/imports-statement-net-namespace-and-type)
|
||||
- [using](/dotnet/csharp/language-reference/keywords/using)
|
||||
- [Effects of Modifying a Base Form's Appearance](effects-of-modifying-base-form-appearance.md)
|
||||
- [Windows Forms Visual Inheritance](windows-forms-visual-inheritance.md)
|
||||
|
||||
+4
-1
@@ -12,6 +12,7 @@ helpviewer_keywords:
|
||||
ms.assetid: 362427f8-03d4-4826-b49f-60ab066ad322
|
||||
---
|
||||
# How to: Print a Multi-Page Text File in Windows Forms
|
||||
|
||||
It is very common for Windows-based applications to print text. The <xref:System.Drawing.Graphics> class provides methods for drawing objects (graphics or text) to a device, such as a screen or printer.
|
||||
|
||||
> [!NOTE]
|
||||
@@ -42,17 +43,19 @@ It is very common for Windows-based applications to print text. The <xref:System
|
||||
[!code-vb[System.Drawing.Printing.PrintExamples#5](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.Printing.PrintExamples/VB/Form1.vb#5)]
|
||||
|
||||
## Example
|
||||
|
||||
[!code-csharp[System.Drawing.Printing.PrintExamples#0](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Drawing.Printing.PrintExamples/CS/Form1.cs#0)]
|
||||
[!code-vb[System.Drawing.Printing.PrintExamples#0](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.Printing.PrintExamples/VB/Form1.vb#0)]
|
||||
|
||||
## Compiling the Code
|
||||
|
||||
This example requires:
|
||||
|
||||
- A text file named testPage.txt containing the text to print, located in the root of drive C:\\. Edit the code to print a different file.
|
||||
|
||||
- References to the System, System.Windows.Forms, System.Drawing assemblies.
|
||||
|
||||
- For information about building this example from the command line for Visual Basic or Visual C#, see [Building from the Command Line](https://docs.microsoft.com/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line) or [Command-line Building With csc.exe](https://docs.microsoft.com/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe). You can also build this example in Visual Studio by pasting the code into a new project.
|
||||
- For information about building this example from the command line for Visual Basic or Visual C#, see [Building from the Command Line](/dotnet/visual-basic/reference/command-line-compiler/building-from-the-command-line) or [Command-line Building With csc.exe](/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe). You can also build this example in Visual Studio by pasting the code into a new project.
|
||||
|
||||
## See also
|
||||
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@ To make a Windows Form work correctly from a COM client application, you must ru
|
||||
|
||||
There is extensive support for this feature in Visual Studio.
|
||||
|
||||
Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)).
|
||||
Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)).
|
||||
|
||||
## Example
|
||||
|
||||
@@ -39,12 +39,12 @@ This approach requires that each instance of a form runs on its own thread by us
|
||||
|
||||
## Compile the code
|
||||
|
||||
Compile the `COMForm`, `Form1`, and `FormManager` types into an assembly called `COMWinform.dll`. Register the assembly for COM interop by using one of the methods described in [Packaging an Assembly for COM](https://docs.microsoft.com/dotnet/framework/interop/packaging-an-assembly-for-co). You can now use the assembly and its corresponding type library (.tlb) file in unmanaged applications. For example, you can use the type library as a reference in a Visual Basic 6.0 executable project.
|
||||
Compile the `COMForm`, `Form1`, and `FormManager` types into an assembly called `COMWinform.dll`. Register the assembly for COM interop by using one of the methods described in [Packaging an Assembly for COM](/dotnet/framework/interop/packaging-an-assembly-for-co). You can now use the assembly and its corresponding type library (.tlb) file in unmanaged applications. For example, you can use the type library as a reference in a Visual Basic 6.0 executable project.
|
||||
|
||||
## See also
|
||||
|
||||
- [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [Packaging an Assembly for COM](https://docs.microsoft.com/dotnet/framework/interop/packaging-an-assembly-for-co)
|
||||
- [Registering Assemblies with COM](https://docs.microsoft.com/dotnet/framework/interop/registering-assemblies-with-co)
|
||||
- [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [Packaging an Assembly for COM](/dotnet/framework/interop/packaging-an-assembly-for-co)
|
||||
- [Registering Assemblies with COM](/dotnet/framework/interop/registering-assemblies-with-co)
|
||||
- [How to: Support COM Interop by Displaying a Windows Form with the ShowDialog Method](com-interop-by-displaying-a-windows-form-shadow.md)
|
||||
- [Windows Forms and Unmanaged Applications Overview](windows-forms-and-unmanaged-applications-overview.md)
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ The following procedures show how to test for a valid birth date using either th
|
||||
|
||||
-or-
|
||||
|
||||
- If you are a Visual Basic developer and you created your application settings using the Project Designer, you can retrieve your settings by using the [My.Settings Object](https://docs.microsoft.com/dotnet/visual-basic/language-reference/objects/my-settings-object).
|
||||
- If you are a Visual Basic developer and you created your application settings using the Project Designer, you can retrieve your settings by using the [My.Settings Object](/dotnet/visual-basic/language-reference/objects/my-settings-object).
|
||||
|
||||
-or-
|
||||
|
||||
|
||||
+4
-1
@@ -7,9 +7,11 @@ helpviewer_keywords:
|
||||
ms.assetid: babf8af3-8000-46e2-8c68-a42127efabba
|
||||
---
|
||||
# Networking in Windows Forms Applications
|
||||
|
||||
The .NET Framework provides classes for displaying Web pages, downloading Web content, interacting with file transfer protocol (FTP) sites, and consuming Web Services, making it easy to build network functionality into your application. The following resources will help you understand the networking technologies of the .NET Framework and how you can integrate them into Windows Forms.
|
||||
|
||||
## Reference
|
||||
|
||||
<xref:System.Net>
|
||||
The root namespace for classes in the .NET Framework that handle network connectivity.
|
||||
|
||||
@@ -23,7 +25,8 @@ The .NET Framework provides classes for displaying Web pages, downloading Web co
|
||||
A managed wrapper class for the `WebBrowser` control that is included with Windows.
|
||||
|
||||
## Related Sections
|
||||
[Network Programming in the .NET Framework](https://docs.microsoft.com/dotnet/framework/network-programming/index)
|
||||
|
||||
[Network Programming in the .NET Framework](/dotnet/framework/network-programming/index)
|
||||
An introduction to networking in the .NET Framework.
|
||||
|
||||
[Windows Forms Data Binding](../windows-forms-data-binding.md)
|
||||
|
||||
@@ -19,4 +19,4 @@ You can also use Windows Forms controls in WPF-based applications. For more info
|
||||
|
||||
## See also
|
||||
|
||||
- [WPF and Windows Forms interoperation](https://docs.microsoft.com/dotnet/framework/wpf/advanced/wpf-and-windows-forms-interoperation)
|
||||
- [WPF and Windows Forms interoperation](/dotnet/framework/wpf/advanced/wpf-and-windows-forms-interoperation)
|
||||
|
||||
+1
-1
@@ -130,6 +130,6 @@ A WPF control hosted on a form has the same anchoring and docking behavior as ot
|
||||
- [How to: Anchor and Dock Child Controls in a TableLayoutPanel Control](../controls/how-to-anchor-and-dock-child-controls-in-a-tablelayoutpanel-control.md)
|
||||
- [How to: Align a Control to the Edges of Forms at Design Time](../controls/how-to-align-a-control-to-the-edges-of-forms-at-design-time.md)
|
||||
- [Walkthrough: Arranging Controls on Windows Forms Using Snaplines](../controls/walkthrough-arranging-controls-on-windows-forms-using-snaplines.md)
|
||||
- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Using WPF Controls](using-wpf-controls.md)
|
||||
- [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio)
|
||||
|
||||
+1
-1
@@ -83,6 +83,6 @@ You can assign different WPF content to an <xref:System.Windows.Forms.Integratio
|
||||
|
||||
- <xref:System.Windows.Forms.Integration.ElementHost>
|
||||
- <xref:System.Windows.Forms.Integration.WindowsFormsHost>
|
||||
- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Using WPF Controls](using-wpf-controls.md)
|
||||
- [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio)
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ This walkthrough will address the five accessibility requirements for the Certif
|
||||
|
||||
For more information, see [Resources for Designing Accessible Applications](/visualstudio/ide/reference/resources-for-designing-accessible-applications).
|
||||
|
||||
For information on supporting varying keyboard layouts, see [Best Practices for Developing World-Ready Applications](https://docs.microsoft.com/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps).
|
||||
For information on supporting varying keyboard layouts, see [Best Practices for Developing World-Ready Applications](/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps).
|
||||
|
||||
## Creating the Project
|
||||
|
||||
@@ -285,7 +285,7 @@ In this application, no information is conveyed by sound alone. If you use sound
|
||||
|
||||
#### To supply information by some other means than sound
|
||||
|
||||
1. Make the title bar flash by using the Windows API function FlashWindow. For an example of how to call Windows API functions, see [Walkthrough: Calling Windows APIs](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/walkthrough-calling-windows-apis).
|
||||
1. Make the title bar flash by using the Windows API function FlashWindow. For an example of how to call Windows API functions, see [Walkthrough: Calling Windows APIs](/dotnet/visual-basic/programming-guide/com-interop/walkthrough-calling-windows-apis).
|
||||
|
||||
> [!NOTE]
|
||||
> The user may have the Windows SoundSentry service enabled, which will also cause the window to flash when the system sounds are played through the computer's built-in speaker.
|
||||
|
||||
+3
-3
@@ -90,9 +90,9 @@ To add a WPF control to a Windows Form:
|
||||
|
||||
Windows Forms and WPF are different technologies, but they are designed to interoperate closely. To provide richer appearance and behavior in your applications, try the following:
|
||||
|
||||
- Host a Windows Forms control in a WPF page. For more information, see [Walkthrough: Hosting a Windows Forms Control in WPF](https://docs.microsoft.com/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf).
|
||||
- Host a Windows Forms control in a WPF page. For more information, see [Walkthrough: Hosting a Windows Forms Control in WPF](/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf).
|
||||
|
||||
- Apply Windows Forms visual styles to your WPF content. For more information, see [How to: Enable Visual Styles in a Hybrid Application](https://docs.microsoft.com/dotnet/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application).
|
||||
- Apply Windows Forms visual styles to your WPF content. For more information, see [How to: Enable Visual Styles in a Hybrid Application](/dotnet/framework/wpf/advanced/how-to-enable-visual-styles-in-a-hybrid-application).
|
||||
|
||||
- Change the style of your WPF content. For more information, see [Walkthrough: Styling WPF Content](walkthrough-styling-wpf-content.md).
|
||||
|
||||
@@ -100,6 +100,6 @@ Windows Forms and WPF are different technologies, but they are designed to inter
|
||||
|
||||
- <xref:System.Windows.Forms.Integration.ElementHost>
|
||||
- <xref:System.Windows.Forms.Integration.WindowsFormsHost>
|
||||
- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Using WPF Controls](using-wpf-controls.md)
|
||||
- [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio)
|
||||
|
||||
@@ -55,7 +55,7 @@ You can apply different styling to a WPF control to change its appearance and be
|
||||
|
||||
`UserControl1` opens in the WPF Designer.
|
||||
|
||||
1. In XAML view, insert the following XAML after the `<UserControl>` opening tag. This XAML creates a gradient with a contrasting gradient border. When the control is clicked, the gradients are changed to generate a pressed button look. For more information, see [Styling and Templating](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
1. In XAML view, insert the following XAML after the `<UserControl>` opening tag. This XAML creates a gradient with a contrasting gradient border. When the control is clicked, the gradients are changed to generate a pressed button look. For more information, see [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview).
|
||||
|
||||
```xaml
|
||||
<UserControl.Resources>
|
||||
@@ -132,8 +132,8 @@ You can apply different styling to a WPF control to change its appearance and be
|
||||
|
||||
- <xref:System.Windows.Forms.Integration.ElementHost>
|
||||
- <xref:System.Windows.Forms.Integration.WindowsFormsHost>
|
||||
- [Migration and Interoperability](https://docs.microsoft.com/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Migration and Interoperability](/dotnet/framework/wpf/advanced/migration-and-interoperability)
|
||||
- [Using WPF Controls](using-wpf-controls.md)
|
||||
- [Design XAML in Visual Studio](/visualstudio/xaml-tools/designing-xaml-in-visual-studio)
|
||||
- [XAML Overview (WPF)](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
- [XAML Overview (WPF)](/dotnet/desktop-wpf/fundamentals/xaml)
|
||||
- [Styling and Templating](/dotnet/desktop-wpf/fundamentals/styles-templates-overview)
|
||||
|
||||
+13
-8
@@ -10,14 +10,16 @@ helpviewer_keywords:
|
||||
ms.assetid: 0a26d99d-8135-4895-8760-c9a2b5f67f14
|
||||
---
|
||||
# Windows Forms and Unmanaged Applications Overview
|
||||
|
||||
Windows Forms applications and controls can interoperate with unmanaged applications, with some caveats. The following sections describe the scenarios and configurations that Windows Forms applications and controls support and those that they do not support.
|
||||
|
||||
## Windows Forms Controls and ActiveX Applications
|
||||
|
||||
With the exception of Microsoft Internet Explorer and Microsoft Foundation Classes (MFC), Windows Forms controls are not supported in applications designed to host ActiveX controls. Other applications and development tools that are capable of hosting ActiveX controls, including the ActiveX test containers from versions of Visual Studio that are earlier than Visual Studio .NET 2003, are not supported hosts for Windows Forms controls.
|
||||
|
||||
These constraints also apply to the use of Windows Forms controls through Component Object Model COM interop. The use of a Windows Forms control through a COM callable wrapper (CCW) is supported only in Internet Explorer. For more information about COM interop, see
|
||||
|
||||
[COM Interop](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/index).
|
||||
[COM Interop](/dotnet/visual-basic/programming-guide/com-interop/index).
|
||||
|
||||
The following table shows the available ActiveX hosting support for Windows Forms controls.
|
||||
|
||||
@@ -27,6 +29,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
|.NET Framework version 1.1 and later|Internet Explorer 5.01 and later versions<br /><br /> Microsoft Foundation Classes (MFC) 7.0 and later|
|
||||
|
||||
## Hosting Windows Forms components as ActiveX controls
|
||||
|
||||
In the .NET Framework 1.1, support was extended to include MFC 7.0 and later versions. This support includes any container that is fully compatible with the MFC 7.0 and later ActiveX control container.
|
||||
|
||||
However, registration of Windows Forms controls as ActiveX controls is not supported. Also, calling the `com.ms.win32.Ole32.CoCreateInstance` method for Windows Forms controls is not supported. Only managed activation of Windows Forms controls is supported. Once you create a Windows Forms control, you can host it in an MFC application just as with an ActiveX control.
|
||||
@@ -34,6 +37,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
To use Windows Forms controls in your unmanaged application, you must either host the CLR using the unmanaged CLR hosting APIs or use the C++ interop features. Using the C++ interop features is the recommended solution.
|
||||
|
||||
## Windows Forms in COM client applications
|
||||
|
||||
When you open a Windows Form from a COM client application, such as a Visual Basic 6.0 application or an MFC application, the form may behave unexpectedly. For example, when you press the TAB key, the focus does not change from one control to another control. When you press the ENTER key while a command button has focus, the button's <xref:System.Windows.Forms.Control.Click> event is not raised. You may also experience unexpected behavior for keystrokes or mouse activity.
|
||||
|
||||
This behavior occurs because the unmanaged application does not implement the message loop support that Windows Forms requires to work correctly. The message loop provided by the COM client application is fundamentally different from the Windows Forms message loop.
|
||||
@@ -41,6 +45,7 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
An application's message loop is an internal program loop that retrieves messages from a thread's message queue, translates them, and then sends them to the application to be handled. The message loop for a Windows Form does not have the same architecture as message loops that earlier applications, such as Visual Basic 6.0 applications and MFC applications, provide. The window messages that are posted to the message loop may be handled differently than the Windows Form expects. Therefore, unexpected behavior may occur. Some keystroke combinations may not work, some mouse activity may not work, or some events may not be raised as expected.
|
||||
|
||||
## Resolving Interoperability Issues
|
||||
|
||||
You can resolve these problems by displaying the form on a .NET Framework message loop, which is created by using the <xref:System.Windows.Forms.Application.Run%2A?displayProperty=nameWithType> method.
|
||||
|
||||
To make a Windows Form work correctly from a COM client application, you must run it on a Windows Forms message loop. To do this, use one of the following approaches:
|
||||
@@ -52,12 +57,12 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
## See also
|
||||
|
||||
- [Windows Forms and Unmanaged Applications](windows-forms-and-unmanaged-applications.md)
|
||||
- [COM Interop](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/index)
|
||||
- [COM Interoperability in .NET Framework Applications](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications)
|
||||
- [COM Interoperability Samples](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2008/cxcz83xf(v=vs.90))
|
||||
- [Aximp.exe (Windows Forms ActiveX Control Importer)](https://docs.microsoft.com/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer)
|
||||
- [Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [Packaging an Assembly for COM](https://docs.microsoft.com/dotnet/framework/interop/packaging-an-assembly-for-co)
|
||||
- [Registering Assemblies with COM](https://docs.microsoft.com/dotnet/framework/interop/registering-assemblies-with-co)
|
||||
- [COM Interop](/dotnet/visual-basic/programming-guide/com-interop/index)
|
||||
- [COM Interoperability in .NET Framework Applications](/dotnet/visual-basic/programming-guide/com-interop/com-interoperability-in-net-framework-applications)
|
||||
- [COM Interoperability Samples](/previous-versions/visualstudio/visual-studio-2008/cxcz83xf(v=vs.90))
|
||||
- [Aximp.exe (Windows Forms ActiveX Control Importer)](/dotnet/framework/tools/aximp-exe-windows-forms-activex-control-importer)
|
||||
- [Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
- [Packaging an Assembly for COM](/dotnet/framework/interop/packaging-an-assembly-for-co)
|
||||
- [Registering Assemblies with COM](/dotnet/framework/interop/registering-assemblies-with-co)
|
||||
- [How to: Support COM Interop by Displaying a Windows Form with the ShowDialog Method](com-interop-by-displaying-a-windows-form-shadow.md)
|
||||
- [How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md)
|
||||
|
||||
+6
-2
@@ -10,9 +10,11 @@ helpviewer_keywords:
|
||||
ms.assetid: 81bc100c-fa49-4614-85a6-0f7ab59eac8a
|
||||
---
|
||||
# Windows Forms and Unmanaged Applications
|
||||
|
||||
Windows Forms applications and controls can interoperate with unmanaged applications, with some caveats. The following sections describe the scenarios and configurations that Windows Forms applications and controls support and those that they do not support.
|
||||
|
||||
## In This Section
|
||||
|
||||
[Windows Forms and Unmanaged Applications Overview](windows-forms-and-unmanaged-applications-overview.md)
|
||||
Offers general information about how to use and implement Windows Forms controls that work with unmanaged applications.
|
||||
|
||||
@@ -22,9 +24,10 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
[How to: Support COM Interop by Displaying Each Windows Form on Its Own Thread](how-to-support-com-interop-by-displaying-each-windows-form-on-its-own-thread.md)
|
||||
Provides a code example that shows how to run a Windows Form on its own thread.
|
||||
|
||||
Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](https://docs.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)).
|
||||
Also see [Walkthrough: Supporting COM Interop by Displaying Each Windows Form on Its Own Thread](/previous-versions/visualstudio/visual-studio-2010/ms233639(v=vs.100)).
|
||||
|
||||
## Reference
|
||||
|
||||
<xref:System.Windows.Forms.Form.ShowDialog%2A?displayProperty=nameWithType>
|
||||
Used to create a separate thread for a Windows Form.
|
||||
|
||||
@@ -35,5 +38,6 @@ Windows Forms applications and controls can interoperate with unmanaged applicat
|
||||
Marshals calls from an unmanaged application to a form.
|
||||
|
||||
## Related Sections
|
||||
[Exposing .NET Framework Components to COM](https://docs.microsoft.com/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
|
||||
[Exposing .NET Framework Components to COM](/dotnet/framework/interop/exposing-dotnet-components-to-co)
|
||||
Offers general information about how to use .NET Framework types in unmanaged applications.
|
||||
|
||||
+6
-3
@@ -12,11 +12,13 @@ helpviewer_keywords:
|
||||
ms.assetid: 857eb737-3602-4d49-bd8b-f70d33ace345
|
||||
---
|
||||
# Windows Forms Visual Inheritance
|
||||
|
||||
Occasionally, you may decide that a project calls for a form similar to one that you have created in a previous project. Or, you may want to create a basic form with settings such as a watermark or certain control layout that you will then use again within a project, with each iteration containing modifications to the original form template. Form inheritance enables you to create a base form and then inherit from it and make modifications while preserving whatever original settings you need.
|
||||
|
||||
You can create derived-class forms programmatically or by using the Visual Inheritance picker.
|
||||
|
||||
## In This Section
|
||||
|
||||
[How to: Inherit Windows Forms](how-to-inherit-windows-forms.md)
|
||||
Gives directions for creating inherited forms in code.
|
||||
|
||||
@@ -33,11 +35,12 @@ Occasionally, you may decide that a project calls for a form similar to one that
|
||||
Gives directions for using the `GenerateMember` and `Modifiers` properties, which are relevant when the Windows Forms Designer generates a member variable for a component.
|
||||
|
||||
## Related Sections
|
||||
[Inheritance basics (Visual Basic)](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics)
|
||||
|
||||
[Inheritance basics (Visual Basic)](/dotnet/visual-basic/programming-guide/language-features/objects-and-classes/inheritance-basics)
|
||||
Describes how to define Visual Basic classes that serve as the basis for other classes.
|
||||
|
||||
[class](https://docs.microsoft.com/dotnet/csharp/language-reference/keywords/class)
|
||||
[class](/dotnet/csharp/language-reference/keywords/class)
|
||||
Describes the C# approach of classes, in which single inheritance is allowed.
|
||||
|
||||
[Troubleshooting Inherited Event Handlers in Visual Basic](https://docs.microsoft.com/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers)
|
||||
[Troubleshooting Inherited Event Handlers in Visual Basic](/dotnet/visual-basic/programming-guide/language-features/events/troubleshooting-inherited-event-handlers)
|
||||
Lists common issues that arise with event handlers in inherited components
|
||||
|
||||
Reference in New Issue
Block a user